There are three positive integers A, B and C written on a blackboard. E869120 performs the following operation K times:
 - Choose one integer written on the blackboard and let the chosen integer be n. Replace the chosen integer with 2n.
What is the largest possible sum of the integers written on the blackboard after K operations?

-----Constraints-----
 - A, B and C are integers between 1 and 50 (inclusive).
 - K is an integer between 1 and 10 (inclusive).

-----Input-----
Input is given from Standard Input in the following format:
A B C
K

-----Output-----
Print the largest possible sum of the integers written on the blackboard after K operations by E869220.

-----Sample Input-----
5 3 11
1

-----Sample Output-----
30

In this sample, 5, 3, 11 are initially written on the blackboard, and E869120 can perform the operation once.

There are three choices:
 - Double 5: The integers written on the board after the operation are 10, 3, 11.
 - Double 3: The integers written on the board after the operation are 5, 6, 11.
 - Double 11: The integers written on the board after the operation are 5, 3, 22.
If he chooses 3., the sum of the integers written on the board afterwards is 5 + 3 + 22 = 30, which is the largest among 1. through 3.


Let w be a string consisting of lowercase letters.
We will call w beautiful if the following condition is satisfied:
 - Each lowercase letter of the English alphabet occurs even number of times in w.
You are given the string w. Determine if w is beautiful.

-----Constraints-----
 - 1 \leq |w| \leq 100
 - w consists of lowercase letters (a-z).

-----Input-----
The input is given from Standard Input in the following format:
w

-----Output-----
Print Yes if w is beautiful. Print No otherwise.

-----Sample Input-----
abaccaba

-----Sample Output-----
Yes

a occurs four times, b occurs twice, c occurs twice and the other letters occur zero times.


There is an empty array.
The following N operations will be performed to insert integers into the array.
In the i-th operation (1≤i≤N), b_i copies of an integer a_i are inserted into the array.
Find the K-th smallest integer in the array after the N operations.
For example, the 4-th smallest integer in the array \{1,2,2,3,3,3\} is 3.

-----Constraints-----
 - 1≤N≤10^5
 - 1≤a_i,b_i≤10^5
 - 1≤K≤b_1…+…b_n
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
N K
a_1 b_1
:
a_N b_N

-----Output-----
Print the K-th smallest integer in the array after the N operations.

-----Sample Input-----
3 4
1 1
2 2
3 3

-----Sample Output-----
3

The resulting array is the same as the one in the problem statement.


There are N balls placed in a row.
AtCoDeer the deer is painting each of these in one of the K colors of his paint cans.
For aesthetic reasons, any two adjacent balls must be painted in different colors.
Find the number of the possible ways to paint the balls.

-----Constraints-----
 - 1≦N≦1000
 - 2≦K≦1000
 - The correct answer is at most 2^{31}-1.

-----Input-----
The input is given from Standard Input in the following format:
N K

-----Output-----
Print the number of the possible ways to paint the balls.

-----Sample Input-----
2 2

-----Sample Output-----
2

We will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.


There is a circular pond with a perimeter of K meters, and N houses around them.
The i-th house is built at a distance of A_i meters from the northmost point of the pond, measured clockwise around the pond.
When traveling between these houses, you can only go around the pond.
Find the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

-----Constraints-----
 - 2 \leq K \leq 10^6
 - 2 \leq N \leq 2 \times 10^5
 - 0 \leq A_1 < ... < A_N < K
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
K N
A_1 A_2 ... A_N

-----Output-----
Print the minimum distance that needs to be traveled when you start at one of the houses and visit all the N houses.

-----Sample Input-----
20 3
5 10 15

-----Sample Output-----
10

If you start at the 1-st house and go to the 2-nd and 3-rd houses in this order, the total distance traveled will be 10.


There are two rectangles.
The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B.
The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.
Print the area of the rectangle with the larger area.
If the two rectangles have equal areas, print that area.

-----Constraints-----
 - All input values are integers.
 - 1≤A≤10^4
 - 1≤B≤10^4
 - 1≤C≤10^4
 - 1≤D≤10^4

-----Input-----
The input is given from Standard Input in the following format:
A B C D

-----Output-----
Print the area of the rectangle with the larger area.
If the two rectangles have equal areas, print that area.

-----Sample Input-----
3 5 2 7

-----Sample Output-----
15

The first rectangle has an area of 3×5=15, and the second rectangle has an area of 2×7=14.
Thus, the output should be 15, the larger area.


Takahashi is participating in a programming contest called AXC002, and he has just submitted his code to Problem A.
The problem has N test cases.
For each test case i (1\leq i \leq N), you are given a string S_i representing the verdict for that test case. Find the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively.
See the Output section for the output format.

-----Constraints-----
 - 1 \leq N \leq 10^5
 - S_i is AC, WA, TLE, or RE.

-----Input-----
Input is given from Standard Input in the following format:
N
S_1
\vdots
S_N

-----Output-----
Let C_0, C_1, C_2, and C_3 be the numbers of test cases for which the verdict is AC, WA, TLE, and RE, respectively. Print the following:
AC x C_0
WA x C_1
TLE x C_2
RE x C_3

-----Sample Input-----
6
AC
TLE
AC
AC
WA
TLE

-----Sample Output-----
AC x 3
WA x 1
TLE x 2
RE x 0

We have 3, 1, 2, and 0 test case(s) for which the verdict is AC, WA, TLE, and RE, respectively.


How many hours do we have until New Year at M o'clock (24-hour notation) on 30th, December?

-----Constraints-----
 - 1≤M≤23
 - M is an integer.

-----Input-----
Input is given from Standard Input in the following format:
M

-----Output-----
If we have x hours until New Year at M o'clock on 30th, December, print x.

-----Sample Input-----
21

-----Sample Output-----
27

We have 27 hours until New Year at 21 o'clock on 30th, December.


You are given two integers A and B as the input. Output the value of A + B.
However, if A + B is 10 or greater, output error instead.

-----Constraints-----
 - A and B are integers.
 - 1 ≤ A, B ≤ 9

-----Input-----
Input is given from Standard Input in the following format:
A B

-----Output-----
If A + B is 10 or greater, print the string error (case-sensitive); otherwise, print the value of A + B.

-----Sample Input-----
6 3

-----Sample Output-----
9


It is only six months until Christmas, and AtCoDeer the reindeer is now planning his travel to deliver gifts.

There are N houses along TopCoDeer street. The i-th house is located at coordinate a_i. He has decided to deliver gifts to all these houses.

Find the minimum distance to be traveled when AtCoDeer can start and end his travel at any positions.

-----Constraints-----
 - 1 ≤ N ≤ 100
 - 0 ≤ a_i ≤ 1000
 - a_i is an integer.

-----Input-----
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N

-----Output-----
Print the minimum distance to be traveled.

-----Sample Input-----
4
2 3 7 9

-----Sample Output-----
7

The travel distance of 7 can be achieved by starting at coordinate 9 and traveling straight to coordinate 2.

It is not possible to do with a travel distance of less than 7, and thus 7 is the minimum distance to be traveled.


Based on some criterion, Snuke divided the integers from 1 through 12 into three groups as shown in the figure below.
Given two integers x and y (1 ≤ x < y ≤ 12), determine whether they belong to the same group.

-----Constraints-----
 - x and y are integers.
 - 1 ≤ x < y ≤ 12

-----Input-----
Input is given from Standard Input in the following format:
x y

-----Output-----
If x and y belong to the same group, print Yes; otherwise, print No.

-----Sample Input-----
1 3

-----Sample Output-----
Yes


AtCoDeer the deer found two positive integers, a and b.
Determine whether the product of a and b is even or odd.

-----Constraints-----
 - 1 ≤ a,b ≤ 10000
 - a and b are integers.

-----Input-----
Input is given from Standard Input in the following format:
a b

-----Output-----
If the product is odd, print Odd; if it is even, print Even.

-----Sample Input-----
3 4

-----Sample Output-----
Even

As 3 × 4 = 12 is even, print Even.


Snuke loves puzzles.
Today, he is working on a puzzle using S- and c-shaped pieces.
In this puzzle, you can combine two c-shaped pieces into one S-shaped piece, as shown in the figure below:
Snuke decided to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces.
Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.

-----Constraints-----
 - 1 ≤ N,M ≤ 10^{12}

-----Input-----
The input is given from Standard Input in the following format:
N M

-----Output-----
Print the answer.

-----Sample Input-----
1 6

-----Sample Output-----
2

Two Scc groups can be created as follows:
 - Combine two c-shaped pieces into one S-shaped piece
 - Create two Scc groups, each from one S-shaped piece and two c-shaped pieces


Joisino is about to compete in the final round of a certain programming competition.
In this contest, there are N problems, numbered 1 through N.
Joisino knows that it takes her T_i seconds to solve problem i(1≦i≦N).
Also, there are M kinds of drinks offered to the contestants, numbered 1 through M.
If Joisino takes drink i(1≦i≦M), her brain will be stimulated and the time it takes for her to solve problem P_i will become X_i seconds.
It does not affect the time to solve the other problems.
A contestant is allowed to take exactly one of the drinks before the start of the contest.
For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink.
Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems.
Your task is to write a program to calculate it instead of her.

-----Constraints-----
 - All input values are integers.
 - 1≦N≦100
 - 1≦T_i≦10^5
 - 1≦M≦100
 - 1≦P_i≦N
 - 1≦X_i≦10^5

-----Input-----
The input is given from Standard Input in the following format:
N
T_1 T_2 ... T_N
M
P_1 X_1
P_2 X_2
:
P_M X_M

-----Output-----
For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.

-----Sample Input-----
3
2 1 4
2
1 1
2 3

-----Sample Output-----
6
9

If Joisino takes drink 1, the time it takes her to solve each problem will be 1, 1 and 4 seconds, respectively, totaling 6 seconds.
If Joisino takes drink 2, the time it takes her to solve each problem will be 2, 3 and 4 seconds, respectively, totaling 9 seconds.


Iroha is very particular about numbers. There are K digits that she dislikes: D_1, D_2, ..., D_K.
She is shopping, and now paying at the cashier.
Her total is N yen (the currency of Japan), thus she has to hand at least N yen to the cashier (and possibly receive the change).
However, as mentioned before, she is very particular about numbers. When she hands money to the cashier, the decimal notation of the amount must not contain any digits that she dislikes. Under this condition, she will hand the minimum amount of money.
Find the amount of money that she will hand to the cashier.

-----Constraints-----
 -  1 ≦ N < 10000
 -  1 ≦ K < 10
 -  0 ≦ D_1 < D_2 < … < D_K≦9
 - \{D_1,D_2,...,D_K\} ≠ \{1,2,3,4,5,6,7,8,9\}

-----Input-----
The input is given from Standard Input in the following format:
N K
D_1 D_2 … D_K

-----Output-----
Print the amount of money that Iroha will hand to the cashier.

-----Sample Input-----
1000 8
1 3 4 5 6 7 8 9

-----Sample Output-----
2000

She dislikes all digits except 0 and 2.
The smallest integer equal to or greater than N=1000 whose decimal notation contains only 0 and 2, is 2000.


There are N observatories in AtCoder Hill, called Obs. 1, Obs. 2, ..., Obs. N. The elevation of Obs. i is H_i.
There are also M roads, each connecting two different observatories. Road j connects Obs. A_j and Obs. B_j.
Obs. i is said to be good when its elevation is higher than those of all observatories that can be reached from Obs. i using just one road.
Note that Obs. i is also good when no observatory can be reached from Obs. i using just one road.
How many good observatories are there?

-----Constraints-----
 - 2 \leq N \leq 10^5
 - 1 \leq M \leq 10^5
 - 1 \leq H_i \leq 10^9
 - 1 \leq A_i,B_i \leq N
 - A_i \neq B_i
 - Multiple roads may connect the same pair of observatories.
 - All values in input are integers.

-----Input-----
Input is given from Standard Input in the following format:
N M
H_1 H_2 ... H_N
A_1 B_1
A_2 B_2
:
A_M B_M

-----Output-----
Print the number of good observatories.

-----Sample Input-----
4 3
1 2 3 4
1 3
2 3
2 4

-----Sample Output-----
2

 - From Obs. 1, you can reach Obs. 3 using just one road. The elevation of Obs. 1 is not higher than that of Obs. 3, so Obs. 1 is not good.
 - From Obs. 2, you can reach Obs. 3 and 4 using just one road. The elevation of Obs. 2 is not higher than that of Obs. 3, so Obs. 2 is not good.
 - From Obs. 3, you can reach Obs. 1 and 2 using just one road. The elevation of Obs. 3 is higher than those of Obs. 1 and 2, so Obs. 3 is good.
 - From Obs. 4, you can reach Obs. 2 using just one road. The elevation of Obs. 4 is higher than that of Obs. 2, so Obs. 4 is good.
Thus, the good observatories are Obs. 3 and 4, so there are two good observatories.


Square1001 has seen an electric bulletin board displaying the integer 1.
He can perform the following operations A and B to change this value:
 - Operation A: The displayed value is doubled.
 - Operation B: The displayed value increases by K.
Square1001 needs to perform these operations N times in total.
Find the minimum possible value displayed in the board after N operations.

-----Constraints-----
 - 1 \leq N, K \leq 10
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
K

-----Output-----
Print the minimum possible value displayed in the board after N operations.

-----Sample Input-----
4
3

-----Sample Output-----
10

The value will be minimized when the operations are performed in the following order: A, A, B, B.

In this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.


Given is an integer x that is greater than or equal to 0, and less than or equal to 1.
Output 1 if x is equal to 0, or 0 if x is equal to 1.

-----Constraints-----
 - 0 \leq x \leq 1
 - x is an integer

-----Input-----
Input is given from Standard Input in the following format:
x

-----Output-----
Print 1 if x is equal to 0, or 0 if x is equal to 1.

-----Sample Input-----
1

-----Sample Output-----
0


You are given a string S consisting of digits between 1 and 9, inclusive.
You can insert the letter + into some of the positions (possibly none) between two letters in this string.
Here, + must not occur consecutively after insertion.
All strings that can be obtained in this way can be evaluated as formulas.
Evaluate all possible formulas, and print the sum of the results.

-----Constraints-----
 - 1 \leq |S| \leq 10
 - All letters in S are digits between 1 and 9, inclusive.

-----Input-----
The input is given from Standard Input in the following format:
S

-----Output-----
Print the sum of the evaluated value over all possible formulas.

-----Sample Input-----
125

-----Sample Output-----
176

There are 4 formulas that can be obtained: 125, 1+25, 12+5 and 1+2+5. When each formula is evaluated,
 - 125
 - 1+25=26
 - 12+5=17
 - 1+2+5=8
Thus, the sum is 125+26+17+8=176.


Snuke and Raccoon have a heap of N cards. The i-th card from the top has the integer a_i written on it.
They will share these cards.
First, Snuke will take some number of cards from the top of the heap, then Raccoon will take all the remaining cards.
Here, both Snuke and Raccoon have to take at least one card.
Let the sum of the integers on Snuke's cards and Raccoon's cards be x and y, respectively.
They would like to minimize |x-y|.
Find the minimum possible value of |x-y|.

-----Constraints-----
 - 2 \leq N \leq 2 \times 10^5
 - -10^{9} \leq a_i \leq 10^{9}
 - a_i is an integer.

-----Input-----
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_{N}

-----Output-----
Print the answer.

-----Sample Input-----
6
1 2 3 4 5 6

-----Sample Output-----
1

If Snuke takes four cards from the top, and Raccoon takes the remaining two cards, x=10, y=11, and thus |x-y|=1. This is the minimum possible value.


Snuke has a favorite restaurant.
The price of any meal served at the restaurant is 800 yen (the currency of Japan), and each time a customer orders 15 meals, the restaurant pays 200 yen back to the customer.
So far, Snuke has ordered N meals at the restaurant.
Let the amount of money Snuke has paid to the restaurant be x yen, and let the amount of money the restaurant has paid back to Snuke be y yen.
Find x-y.

-----Constraints-----
 - 1 ≤ N ≤ 100

-----Input-----
The input is given from Standard Input in the following format:
N

-----Output-----
Print the answer.

-----Sample Input-----
20

-----Sample Output-----
15800

So far, Snuke has paid 16000 yen, and the restaurant has paid back 200 yen. Thus, the answer is 15800.


We have a 3×3 square grid, where each square contains a lowercase English letters.
The letter in the square at the i-th row from the top and j-th column from the left is c_{ij}.
Print the string of length 3 that can be obtained by concatenating the letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.

-----Constraints-----
 - Input consists of lowercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
c_{11}c_{12}c_{13}
c_{21}c_{22}c_{23}
c_{31}c_{32}c_{33}

-----Output-----
Print the string of length 3 that can be obtained by concatenating the letters on the diagonal connecting the top-left and bottom-right corner of the grid, from the top-left to bottom-right.

-----Sample Input-----
ant
obe
rec

-----Sample Output-----
abc

The letters in the squares on the diagonal connecting the top-left and bottom-right corner of the grid are a, b and c from top-right to bottom-left. Concatenate these letters and print abc.


Snuke has a grid consisting of three squares numbered 1, 2 and 3.
In each square, either 0 or 1 is written. The number written in Square i is s_i.
Snuke will place a marble on each square that says 1.
Find the number of squares on which Snuke will place a marble.

-----Constraints-----
 - Each of s_1, s_2 and s_3 is either 1 or 0.

-----Input-----
Input is given from Standard Input in the following format:
s_{1}s_{2}s_{3}

-----Output-----
Print the answer.

-----Sample Input-----
101

-----Sample Output-----
2

 - A marble will be placed on Square 1 and 3.


There is a hotel with the following accommodation fee:
 - X yen (the currency of Japan) per night, for the first K nights
 - Y yen per night, for the (K+1)-th and subsequent nights
Tak is staying at this hotel for N consecutive nights.
Find his total accommodation fee.

-----Constraints-----
 - 1 \leq N, K \leq 10000
 - 1 \leq Y < X \leq 10000
 - N,\,K,\,X,\,Y are integers.

-----Input-----
The input is given from Standard Input in the following format:
N
K
X
Y

-----Output-----
Print Tak's total accommodation fee.

-----Sample Input-----
5
3
10000
9000

-----Sample Output-----
48000

The accommodation fee is as follows:
 - 10000 yen for the 1-st night
 - 10000 yen for the 2-nd night
 - 10000 yen for the 3-rd night
 - 9000 yen for the 4-th night
 - 9000 yen for the 5-th night
Thus, the total is 48000 yen.


Joisino wants to evaluate the formula "A op B".
Here, A and B are integers, and the binary operator op is either + or -.
Your task is to evaluate the formula instead of her.

-----Constraints-----
 - 1≦A,B≦10^9
 - op is either + or -.

-----Input-----
The input is given from Standard Input in the following format:
A op B

-----Output-----
Evaluate the formula and print the result.

-----Sample Input-----
1 + 2

-----Sample Output-----
3

Since 1 + 2 = 3, the output should be 3.


Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) otherwise.
You are given Smeke's current rating, x. Print ABC if Smeke will participate in ABC, and print ARC otherwise.

-----Constraints-----
 - 1 ≦ x ≦ 3{,}000
 - x is an integer.

-----Input-----
The input is given from Standard Input in the following format:
x

-----Output-----
Print the answer.

-----Sample Input-----
1000

-----Sample Output-----
ABC

Smeke's current rating is less than 1200, thus the output should be ABC.


Snuke is buying a bicycle.
The bicycle of his choice does not come with a bell, so he has to buy one separately.
He has very high awareness of safety, and decides to buy two bells, one for each hand.
The store sells three kinds of bells for the price of a, b and c yen (the currency of Japan), respectively.
Find the minimum total price of two different bells.

-----Constraints-----
 - 1 \leq a,b,c \leq 10000
 - a, b and c are integers.

-----Input-----
Input is given from Standard Input in the following format:
a b c

-----Output-----
Print the minimum total price of two different bells.

-----Sample Input-----
700 600 780

-----Sample Output-----
1300

 - Buying a 700-yen bell and a 600-yen bell costs 1300 yen.
 - Buying a 700-yen bell and a 780-yen bell costs 1480 yen.
 - Buying a 600-yen bell and a 780-yen bell costs 1380 yen.
The minimum among these is 1300 yen.


You are given a image with a height of H pixels and a width of W pixels.
Each pixel is represented by a lowercase English letter.
The pixel at the i-th row from the top and j-th column from the left is a_{ij}.
Put a box around this image and output the result. The box should consist of # and have a thickness of 1.

-----Constraints-----
 - 1 ≤ H, W ≤ 100
 - a_{ij} is a lowercase English letter.

-----Input-----
Input is given from Standard Input in the following format:
H W
a_{11} ... a_{1W}
:
a_{H1} ... a_{HW}

-----Output-----
Print the image surrounded by a box that consists of # and has a thickness of 1.

-----Sample Input-----
2 3
abc
arc

-----Sample Output-----
#####
#abc#
#arc#
#####


You have an integer variable x.
Initially, x=0.
Some person gave you a string S of length N, and using the string you performed the following operation N times.
In the i-th operation, you incremented the value of x by 1 if S_i=I, and decremented the value of x by 1 if S_i=D.
Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).

-----Constraints-----
 - 1≤N≤100
 - |S|=N
 - No characters except I and D occur in S.

-----Input-----
The input is given from Standard Input in the following format:
N
S

-----Output-----
Print the maximum value taken by x during the operations.

-----Sample Input-----
5
IIDID

-----Sample Output-----
2

After each operation, the value of x becomes 1, 2, 1, 2 and 1, respectively. Thus, the output should be 2, the maximum value.


Find the number of palindromic numbers among the integers between A and B (inclusive).
Here, a palindromic number is a positive integer whose string representation in base 10 (without leading zeros) reads the same forward and backward.

-----Constraints-----
 - 10000 \leq A \leq B \leq 99999
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
A B

-----Output-----
Print the number of palindromic numbers among the integers between A and B (inclusive).

-----Sample Input-----
11009 11332

-----Sample Output-----
4

There are four integers that satisfy the conditions: 11011, 11111, 11211 and 11311.


AtCoDeer the deer recently bought three paint cans.
The color of the one he bought two days ago is a, the color of the one he bought yesterday is b, and the color of the one he bought today is c.
Here, the color of each paint can is represented by an integer between 1 and 100, inclusive.
Since he is forgetful, he might have bought more than one paint can in the same color.
Count the number of different kinds of colors of these paint cans and tell him.

-----Constraints-----
 - 1≦a,b,c≦100

-----Input-----
The input is given from Standard Input in the following format:
a b c

-----Output-----
Print the number of different kinds of colors of the paint cans.

-----Sample Input-----
3 1 4

-----Sample Output-----
3

Three different colors: 1, 3, and 4.


Snuke has N sticks.
The length of the i-th stick is l_i.
Snuke is making a snake toy by joining K of the sticks together.
The length of the toy is represented by the sum of the individual sticks that compose it.
Find the maximum possible length of the toy.

-----Constraints-----
 - 1 \leq K \leq N \leq 50
 - 1 \leq l_i \leq 50
 - l_i is an integer.

-----Input-----
Input is given from Standard Input in the following format:
N K
l_1 l_2 l_3 ... l_{N}

-----Output-----
Print the answer.

-----Sample Input-----
5 3
1 2 3 4 5

-----Sample Output-----
12

You can make a toy of length 12 by joining the sticks of lengths 3, 4 and 5, which is the maximum possible length.


Snuke lives at position x on a number line.
On this line, there are two stores A and B, respectively at position a and b, that offer food for delivery.
Snuke decided to get food delivery from the closer of stores A and B.
Find out which store is closer to Snuke's residence.
Here, the distance between two points s and t on a number line is represented by |s-t|.

-----Constraints-----
 - 1 \leq x \leq 1000
 - 1 \leq a \leq 1000
 - 1 \leq b \leq 1000
 - x, a and b are pairwise distinct.
 - The distances between Snuke's residence and stores A and B are different.

-----Input-----
Input is given from Standard Input in the following format:
x a b

-----Output-----
If store A is closer, print A; if store B is closer, print B.

-----Sample Input-----
5 2 7

-----Sample Output-----
B

The distances between Snuke's residence and stores A and B are 3 and 2, respectively.
Since store B is closer, print B.


On some day in January 2018, Takaki is writing a document. The document has a column where the current date is written in yyyy/mm/dd format. For example, January 23, 2018 should be written as 2018/01/23.
After finishing the document, she noticed that she had mistakenly wrote 2017 at the beginning of the date column. Write a program that, when the string that Takaki wrote in the date column, S, is given as input, modifies the first four characters in S to 2018 and prints it.

-----Constraints-----
 - S is a string of length 10.
 - The first eight characters in S are 2017/01/.
 - The last two characters in S are digits and represent an integer between 1 and 31 (inclusive).

-----Input-----
Input is given from Standard Input in the following format:
S

-----Output-----
Replace the first four characters in S with 2018 and print it.

-----Sample Input-----
2017/01/07

-----Sample Output-----
2018/01/07


Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string.
He will receive a headline which contains one of the strings S_1,...,S_n tomorrow.
He is excited and already thinking of what string he will create.
Since he does not know the string on the headline yet, he is interested in strings that can be created regardless of which string the headline contains.
Find the longest string that can be created regardless of which string among S_1,...,S_n the headline contains.
If there are multiple such strings, find the lexicographically smallest one among them.

-----Constraints-----
 - 1 \leq n \leq 50
 - 1 \leq |S_i| \leq 50 for every i = 1, ..., n.
 - S_i consists of lowercase English letters (a - z) for every i = 1, ..., n.

-----Input-----
Input is given from Standard Input in the following format:
n
S_1
...
S_n

-----Output-----
Print the lexicographically smallest string among the longest strings that satisfy the condition.
If the answer is an empty string, print an empty line.

-----Sample Input-----
3
cbaa
daacc
acacac

-----Sample Output-----
aac

The strings that can be created from each of cbaa, daacc and acacac, are aa, aac, aca, caa and so forth.
Among them, aac, aca and caa are the longest, and the lexicographically smallest of these three is aac.


Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?

-----Constraints-----
 - 1≤N≤1000
 - 1≤l_i≤r_i≤100000
 - No seat is occupied by more than one person.
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N

-----Output-----
Print the number of people sitting at the theater.

-----Sample Input-----
1
24 30

-----Sample Output-----
7

There are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.


In K-city, there are n streets running east-west, and m streets running north-south. Each street running east-west and each street running north-south cross each other. We will call the smallest area that is surrounded by four streets a block. How many blocks there are in K-city?

-----Constraints-----
 - 2 ≤ n, m ≤ 100

-----Input-----
Input is given from Standard Input in the following format:
n m

-----Output-----
Print the number of blocks in K-city.

-----Sample Input-----
3 4

-----Sample Output-----
6

There are six blocks, as shown below:


Snuke is giving cookies to his three goats.
He has two cookie tins. One contains A cookies, and the other contains B cookies. He can thus give A cookies, B cookies or A+B cookies to his goats (he cannot open the tins).
Your task is to determine whether Snuke can give cookies to his three goats so that each of them can have the same number of cookies.

-----Constraints-----
 - 1 \leq A,B \leq 100
 - Both A and B are integers.

-----Input-----
Input is given from Standard Input in the following format:
A B

-----Output-----
If it is possible to give cookies so that each of the three goats can have the same number of cookies, print Possible; otherwise, print Impossible.

-----Sample Input-----
4 5

-----Sample Output-----
Possible

If Snuke gives nine cookies, each of the three goats can have three cookies.


E869120 found a chest which is likely to contain treasure.

However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.

He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with ?.
One more thing he found is a sheet of paper with the following facts written on it:
 - Condition 1: The string S contains a string T as a contiguous substring.
 - Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.
Print the string S.

If such a string does not exist, print UNRESTORABLE.

-----Constraints-----
 - 1 \leq |S'|, |T| \leq 50
 - S' consists of lowercase English letters and ?.
 - T consists of lowercase English letters.

-----Input-----
Input is given from Standard Input in the following format:
S
T'

-----Output-----
Print the string S.

If such a string does not exist, print UNRESTORABLE instead.

-----Sample Input-----
?tc????
coder

-----Sample Output-----
atcoder

There are 26 strings that satisfy Condition 1: atcoder, btcoder, ctcoder,..., ztcoder.
Among them, the lexicographically smallest is atcoder, so we can say S = atcoder.


Takahashi is a user of a site that hosts programming contests.

When a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:
 - Let the current rating of the user be a.
 - Suppose that the performance of the user in the contest is b.
 - Then, the new rating of the user will be the avarage of a and b.
For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.
Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest.

Find the performance required to achieve it.

-----Constraints-----
 - 0 \leq R, G \leq 4500
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
R
G

-----Output-----
Print the performance required to achieve the objective.

-----Sample Input-----
2002
2017

-----Sample Output-----
2032

Takahashi's current rating is 2002.

If his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.


You are given two segments $[l_1; r_1]$ and $[l_2; r_2]$ on the $x$-axis. It is guaranteed that $l_1 < r_1$ and $l_2 < r_2$. Segments may intersect, overlap or even coincide with each other. [Image] The example of two segments on the $x$-axis.

Your problem is to find two integers $a$ and $b$ such that $l_1 \le a \le r_1$, $l_2 \le b \le r_2$ and $a \ne b$. In other words, you have to choose two distinct integer points in such a way that the first point belongs to the segment $[l_1; r_1]$ and the second one belongs to the segment $[l_2; r_2]$.

It is guaranteed that the answer exists. If there are multiple answers, you can print any of them.

You have to answer $q$ independent queries.

-----Input-----

The first line of the input contains one integer $q$ ($1 \le q \le 500$) — the number of queries.

Each of the next $q$ lines contains four integers $l_{1_i}, r_{1_i}, l_{2_i}$ and $r_{2_i}$ ($1 \le l_{1_i}, r_{1_i}, l_{2_i}, r_{2_i} \le 10^9, l_{1_i} < r_{1_i}, l_{2_i} < r_{2_i}$) — the ends of the segments in the $i$-th query.

-----Output-----

Print $2q$ integers. For the $i$-th query print two integers $a_i$ and $b_i$ — such numbers that $l_{1_i} \le a_i \le r_{1_i}$, $l_{2_i} \le b_i \le r_{2_i}$ and $a_i \ne b_i$. Queries are numbered in order of the input.

It is guaranteed that the answer exists. If there are multiple answers, you can print any.

-----Example-----
Input
5
1 2 1 2
2 6 3 4
2 4 1 3
1 2 1 3
1 4 5 8

Output
2 1
3 4
3 2
1 2
3 7


Given head, the head of a linked list, determine if the linked list has a cycle in it.

There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to. Note that pos is not passed as a parameter.

Return true if there is a cycle in the linked list. Otherwise, return false.

Input: head = [3,2,0,-4], pos = 1
Output: true
Explanation: There is a cycle in the linked list, where the tail connects to the 1st node (0-indexed).

Input: head = [1,2], pos = 0
Output: true
Explanation: There is a cycle in the linked list, where the tail connects to the 0th node.

Input: head = [1], pos = -1
Output: false
Explanation: There is no cycle in the linked list.

Constraints:

The number of the nodes in the list is in the range [0, 104].
-105 <= Node.val <= 105
pos is -1 or a valid index in the linked-list.


Given an array of integers, return indices of the two numbers such that they add up to a specific target.

You may assume that each input would have exactly one solution, and you may not use the same element twice.

Example:

Given nums = [2, 7, 11, 15], target = 9,

Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].