Score : <var>100</var> points

Problem Statement

Takahashi wants to print a document with <var>N</var> pages double-sided, where two pages of data can be printed on one sheet of paper.

At least how many sheets of paper does he need?

Constraints

<var>N</var> is an integer.

<var>1 \leq N \leq 100</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the answer.

Sample Input 1

5

Sample Output 1

3

By printing the <var>1</var>-st, <var>2</var>-nd pages on the <var>1</var>-st sheet, <var>3</var>-rd and <var>4</var>-th pages on the <var>2</var>-nd sheet, and <var>5</var>-th page on the <var>3</var>-rd sheet, we can print all the data on <var>3</var> sheets of paper.

Sample Input 2

2

Sample Output 2

1

Sample Input 3

100

Sample Output 3

50


Score : <var>200</var> points

Problem Statement

AtCoDeer the deer found two rectangles lying on the table, each with height <var>1</var> and width <var>W</var>.
If we consider the surface of the desk as a two-dimensional plane, the first rectangle covers the vertical range of <var>[0,1]</var> and the horizontal range of <var>[a,a+W]</var>, and the second rectangle covers the vertical range of <var>[1,2]</var> and the horizontal range of <var>[b,b+W]</var>, as shown in the following figure:

AtCoDeer will move the second rectangle horizontally so that it connects with the first rectangle.
Find the minimum distance it needs to be moved.

Constraints

All input values are integers.

<var>1≤W≤10^5</var>

<var>1≤a,b≤10^5</var>

Input

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

<var>W</var> <var>a</var> <var>b</var>

Output

Print the minimum distance the second rectangle needs to be moved.

Sample Input 1

3 2 6

Sample Output 1

1

This input corresponds to the figure in the statement. In this case, the second rectangle should be moved to the left by a distance of <var>1</var>.

Sample Input 2

3 1 3

Sample Output 2

0

The rectangles are already connected, and thus no move is needed.

Sample Input 3

5 10 1

Sample Output 3

4


Score : <var>300</var> points

Problem Statement

You have a pot and <var>N</var> ingredients. Each ingredient has a real number parameter called value, and the value of the <var>i</var>-th ingredient <var>(1 \leq i \leq N)</var> is <var>v_i</var>.

When you put two ingredients in the pot, they will vanish and result in the formation of a new ingredient. The value of the new ingredient will be <var>(x + y) / 2</var> where <var>x</var> and <var>y</var> are the values of the ingredients consumed, and you can put this ingredient again in the pot.

After you compose ingredients in this way <var>N-1</var> times, you will end up with one ingredient. Find the maximum possible value of this ingredient.

Constraints

<var>2 \leq N \leq 50</var>

<var>1 \leq v_i \leq 1000</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>v_1</var> <var>v_2</var> <var>\ldots</var> <var>v_N</var>

Output

Print a decimal number (or an integer) representing the maximum possible value of the last ingredient remaining.

Your output will be judged correct when its absolute or relative error from the judge's output is at most <var>10^{-5}</var>.

Sample Input 1

2
3 4

Sample Output 1

3.5

If you start with two ingredients, the only choice is to put both of them in the pot. The value of the ingredient resulting from the ingredients of values <var>3</var> and <var>4</var> is <var>(3 + 4) / 2 = 3.5</var>.

Printing 3.50001, 3.49999, and so on will also be accepted.

Sample Input 2

3
500 300 200

Sample Output 2

375

You start with three ingredients this time, and you can choose what to use in the first composition. There are three possible choices:

Use the ingredients of values <var>500</var> and <var>300</var> to produce an ingredient of value <var>(500 + 300) / 2 = 400</var>. The next composition will use this ingredient and the ingredient of value <var>200</var>, resulting in an ingredient of value <var>(400 + 200) / 2 = 300</var>.

Use the ingredients of values <var>500</var> and <var>200</var> to produce an ingredient of value <var>(500 + 200) / 2 = 350</var>. The next composition will use this ingredient and the ingredient of value <var>300</var>, resulting in an ingredient of value <var>(350 + 300) / 2 = 325</var>.

Use the ingredients of values <var>300</var> and <var>200</var> to produce an ingredient of value <var>(300 + 200) / 2 = 250</var>. The next composition will use this ingredient and the ingredient of value <var>500</var>, resulting in an ingredient of value <var>(250 + 500) / 2 = 375</var>.

Thus, the maximum possible value of the last ingredient remaining is <var>375</var>.

Printing 375.0 and so on will also be accepted.

Sample Input 3

5
138 138 138 138 138

Sample Output 3

138


Score : <var>200</var> points

Problem Statement

Takahashi has <var>A</var> cookies, and Aoki has <var>B</var> cookies.
Takahashi will do the following action <var>K</var> times:

If Takahashi has one or more cookies, eat one of his cookies.

Otherwise, if Aoki has one or more cookies, eat one of Aoki's cookies.

If they both have no cookies, do nothing.

In the end, how many cookies will Takahashi and Aoki have, respectively?

Constraints

<var>0 \leq A \leq 10^{12}</var>

<var>0 \leq B \leq 10^{12}</var>

<var>0 \leq K \leq 10^{12}</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>K</var>

Output

Print the numbers of Takahashi's and Aoki's cookies after <var>K</var> actions.

Sample Input 1

2 3 3

Sample Output 1

0 2

Takahashi will do the following:

He has two cookies, so he eats one of them.

Now he has one cookie left, and he eats it.

Now he has no cookies left, but Aoki has three, so Takahashi eats one of them.

Thus, in the end, Takahashi will have <var>0</var> cookies, and Aoki will have <var>2</var>.

Sample Input 2

500000000000 500000000000 1000000000000

Sample Output 2

0 0

Watch out for overflows.


Score : <var>200</var> points

Problem Statement

You are given a string <var>S</var> consisting of lowercase English letters.
Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in <var>S</var>.
If every lowercase English letter occurs in <var>S</var>, print None instead.

Constraints

<var>1 \leq |S| \leq 10^5</var> (<var>|S|</var> is the length of string <var>S</var>.)

<var>S</var> consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the lexicographically smallest lowercase English letter that does not occur in <var>S</var>.
If every lowercase English letter occurs in <var>S</var>, print None instead.

Sample Input 1

atcoderregularcontest

Sample Output 1

b

The string atcoderregularcontest contains a, but does not contain b.

Sample Input 2

abcdefghijklmnopqrstuvwxyz

Sample Output 2

None

This string contains every lowercase English letter.

Sample Input 3

fajsonlslfepbjtsaayxbymeskptcumtwrmkkinjxnnucagfrg

Sample Output 3

d


Score : <var>200</var> points

Problem Statement

Given <var>N</var> integers <var>A_1, ..., A_N</var>, compute <var>A_1 \times ... \times A_N</var>.

However, if the result exceeds <var>10^{18}</var>, print -1 instead.

Constraints

<var>2 \leq N \leq 10^5</var>

<var>0 \leq A_i \leq 10^{18}</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>...</var> <var>A_N</var>

Output

Print the value <var>A_1 \times ... \times A_N</var> as an integer, or -1 if the value exceeds <var>10^{18}</var>.

Sample Input 1

2
1000000000 1000000000

Sample Output 1

1000000000000000000

We have <var>1000000000 \times 1000000000 = 1000000000000000000</var>.

Sample Input 2

3
101 9901 999999000001

Sample Output 2

-1

We have <var>101 \times 9901 \times 999999000001 = 1000000000000000001</var>, which exceeds <var>10^{18}</var>, so we should print -1 instead.

Sample Input 3

31
4 1 5 9 2 6 5 3 5 8 9 7 9 3 2 3 8 4 6 2 6 4 3 3 8 3 2 7 9 5 0

Sample Output 3

0


Score : <var>200</var> points

Problem Statement

The word internationalization is sometimes abbreviated to i18n.
This comes from the fact that there are <var>18</var> letters between the first i and the last n.

You are given a string <var>s</var> of length at least <var>3</var> consisting of lowercase English letters.
Abbreviate <var>s</var> in the same way.

Constraints

<var>3 ≤ |s| ≤ 100</var> (<var>|s|</var> denotes the length of <var>s</var>.)

<var>s</var> consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

<var>s</var>

Output

Print the abbreviation of <var>s</var>.

Sample Input 1

internationalization

Sample Output 1

i18n

Sample Input 2

smiles

Sample Output 2

s4s

Sample Input 3

xyz

Sample Output 3

x1z


Score : <var>100</var> points

Problem Statement

There are <var>N</var> stones, numbered <var>1, 2, \ldots, N</var>.
For each <var>i</var> (<var>1 \leq i \leq N</var>), the height of Stone <var>i</var> is <var>h_i</var>.

There is a frog who is initially on Stone <var>1</var>.
He will repeat the following action some number of times to reach Stone <var>N</var>:

If the frog is currently on Stone <var>i</var>, jump to Stone <var>i + 1</var> or Stone <var>i + 2</var>. Here, a cost of <var>|h_i - h_j|</var> is incurred, where <var>j</var> is the stone to land on.

Find the minimum possible total cost incurred before the frog reaches Stone <var>N</var>.

Constraints

All values in input are integers.

<var>2 \leq N \leq 10^5</var>

<var>1 \leq h_i \leq 10^4</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>h_1</var> <var>h_2</var> <var>\ldots</var> <var>h_N</var>

Output

Print the minimum possible total cost incurred.

Sample Input 1

4
10 30 40 20

Sample Output 1

30

If we follow the path <var>1</var> → <var>2</var> → <var>4</var>, the total cost incurred would be <var>|10 - 30| + |30 - 20| = 30</var>.

Sample Input 2

2
10 10

Sample Output 2

0

If we follow the path <var>1</var> → <var>2</var>, the total cost incurred would be <var>|10 - 10| = 0</var>.

Sample Input 3

6
30 10 60 10 60 50

Sample Output 3

40

If we follow the path <var>1</var> → <var>3</var> → <var>5</var> → <var>6</var>, the total cost incurred would be <var>|30 - 60| + |60 - 60| + |60 - 50| = 40</var>.


Score : <var>400</var> points

Problem Statement

There are <var>N</var> persons called Person <var>1</var> through Person <var>N</var>.

You are given <var>M</var> facts that "Person <var>A_i</var> and Person <var>B_i</var> are friends." The same fact may be given multiple times.

If <var>X</var> and <var>Y</var> are friends, and <var>Y</var> and <var>Z</var> are friends, then <var>X</var> and <var>Z</var> are also friends. There is no friendship that cannot be derived from the <var>M</var> given facts.

Takahashi the evil wants to divide the <var>N</var> persons into some number of groups so that every person has no friend in his/her group.

At least how many groups does he need to make?

Constraints

<var>2 \leq N \leq 2\times 10^5</var>

<var>0 \leq M \leq 2\times 10^5</var>

<var>1\leq A_i,B_i\leq N</var>

<var>A_i \neq B_i</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>A_1</var> <var>B_1</var>
<var>\vdots</var>
<var>A_M</var> <var>B_M</var>

Output

Print the answer.

Sample Input 1

5 3
1 2
3 4
5 1

Sample Output 1

3

Dividing them into three groups such as <var>\{1,3\}</var>, <var>\{2,4\}</var>, and <var>\{5\}</var> achieves the goal.

Sample Input 2

4 10
1 2
2 1
1 2
2 1
1 2
1 3
1 4
2 3
2 4
3 4

Sample Output 2

4

Sample Input 3

10 4
3 1
4 1
5 9
2 6

Sample Output 3

3


Score : <var>400</var> points

Problem Statement

We have <var>N</var> dice arranged in a line from left to right. The <var>i</var>-th die from the left shows <var>p_i</var> numbers from <var>1</var> to <var>p_i</var> with equal probability when thrown.

We will choose <var>K</var> adjacent dice, throw each of them independently, and compute the sum of the numbers shown. Find the maximum possible value of the expected value of this sum.

Constraints

<var>1 ≤ K ≤ N ≤ 200000</var>

<var>1 ≤ p_i ≤ 1000</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>p_1</var> ... <var>p_N</var>

Output

Print the maximum possible value of the expected value of the sum of the numbers shown.

Your output will be considered correct when its absolute or relative error from our answer is at most <var>10^{-6}</var>.

Sample Input 1

5 3
1 2 2 4 5

Sample Output 1

7.000000000000

When we throw the third, fourth, and fifth dice from the left, the expected value of the sum of the numbers shown is <var>7</var>. This is the maximum value we can achieve.

Sample Input 2

4 1
6 6 6 6

Sample Output 2

3.500000000000

Regardless of which die we choose, the expected value of the number shown is <var>3.5</var>.

Sample Input 3

10 4
17 13 13 12 15 20 10 13 17 11

Sample Output 3

32.000000000000


Score : <var>100</var> points

Problem Statement

We have weather records at AtCoder Town for some consecutive three days. A string of length <var>3</var>, <var>S</var>, represents the records - if the <var>i</var>-th character is S, it means it was sunny on the <var>i</var>-th day; if that character is R, it means it was rainy on that day.

Find the maximum number of consecutive rainy days in this period.

Constraints

<var>|S| = 3</var>

Each character of <var>S</var> is S or R.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the maximum number of consecutive rainy days in the period.

Sample Input 1

RRS

Sample Output 1

2

We had rain on the <var>1</var>-st and <var>2</var>-nd days in the period. Here, the maximum number of consecutive rainy days is <var>2</var>, so we should print <var>2</var>.

Sample Input 2

SSS

Sample Output 2

0

It was sunny throughout the period. We had no rainy days, so we should print <var>0</var>.

Sample Input 3

RSR

Sample Output 3

1

We had rain on the <var>1</var>-st and <var>3</var>-rd days - two "streaks" of one rainy day, so we should print <var>1</var>.


Score : <var>100</var> points

Problem Statement

You will be given an integer <var>a</var> and a string <var>s</var> consisting of lowercase English letters as input.

Write a program that prints <var>s</var> if <var>a</var> is not less than <var>3200</var> and prints red if <var>a</var> is less than <var>3200</var>.

Constraints

<var>2800 \leq a < 5000</var>

<var>s</var> is a string of length between <var>1</var> and <var>10</var> (inclusive).

Each character of <var>s</var> is a lowercase English letter.

Input

Input is given from Standard Input in the following format:

<var>a</var>
<var>s</var>

Output

If <var>a</var> is not less than <var>3200</var>, print <var>s</var>; if <var>a</var> is less than <var>3200</var>, print red.

Sample Input 1

3200
pink

Sample Output 1

pink

<var>a = 3200</var> is not less than <var>3200</var>, so we print <var>s =</var> pink.

Sample Input 2

3199
pink

Sample Output 2

red

<var>a = 3199</var> is less than <var>3200</var>, so we print red.

Sample Input 3

4049
red

Sample Output 3

red

<var>a = 4049</var> is not less than <var>3200</var>, so we print <var>s =</var> red.


Score : <var>100</var> points

Problem Statement

You are given two positive integers <var>a</var> and <var>b</var>.
Let <var>x</var> be the average of <var>a</var> and <var>b</var>.
Print <var>x</var> rounded up to the nearest integer.

Constraints

<var>a</var> and <var>b</var> are integers.

<var>1 \leq a, b \leq 100</var>

Input

Input is given from Standard Input in the following format:

<var>a</var> <var>b</var>

Output

Print <var>x</var> rounded up to the nearest integer.

Sample Input 1

1 3

Sample Output 1

2

The average of <var>1</var> and <var>3</var> is <var>2.0</var>, and it will be rounded up to the nearest integer, <var>2</var>.

Sample Input 2

7 4

Sample Output 2

6

The average of <var>7</var> and <var>4</var> is <var>5.5</var>, and it will be rounded up to the nearest integer, <var>6</var>.

Sample Input 3

5 5

Sample Output 3

5


Score : <var>100</var> points

Problem Statement

We have three boxes <var>A</var>, <var>B</var>, and <var>C</var>, each of which contains an integer.

Currently, the boxes <var>A</var>, <var>B</var>, and <var>C</var> contain the integers <var>X</var>, <var>Y</var>, and <var>Z</var>, respectively.

We will now do the operations below in order. Find the content of each box afterward.

Swap the contents of the boxes <var>A</var> and <var>B</var>

Swap the contents of the boxes <var>A</var> and <var>C</var>

Constraints

<var>1 \leq X,Y,Z \leq 100</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>X</var> <var>Y</var> <var>Z</var>

Output

Print the integers contained in the boxes <var>A</var>, <var>B</var>, and <var>C</var>, in this order, with space in between.

Sample Input 1

1 2 3

Sample Output 1

3 1 2

After the contents of the boxes <var>A</var> and <var>B</var> are swapped, <var>A</var>, <var>B</var>, and <var>C</var> contain <var>2</var>, <var>1</var>, and <var>3</var>, respectively.

Then, after the contents of <var>A</var> and <var>C</var> are swapped, <var>A</var>, <var>B</var>, and <var>C</var> contain <var>3</var>, <var>1</var>, and <var>2</var>, respectively.

Sample Input 2

100 100 100

Sample Output 2

100 100 100

Sample Input 3

41 59 31

Sample Output 3

31 41 59


Score : <var>200</var> points

Problem Statement

Snuke has decided to construct a string that starts with A and ends with Z, by taking out a substring of a string <var>s</var> (that is, a consecutive part of <var>s</var>).

Find the greatest length of the string Snuke can construct. Here, the test set guarantees that there always exists a substring of <var>s</var> that starts with A and ends with Z.

Constraints

<var>1 ≦ |s| ≦ 200{,}000</var>

<var>s</var> consists of uppercase English letters.

There exists a substring of <var>s</var> that starts with A and ends with Z.

Input

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

<var>s</var>

Output

Print the answer.

Sample Input 1

QWERTYASDFZXCV

Sample Output 1

5

By taking out the seventh through eleventh characters, it is possible to construct ASDFZ, which starts with A and ends with Z.

Sample Input 2

ZABCZ

Sample Output 2

4

Sample Input 3

HASFJGHOGAKZZFEGA

Sample Output 3

12


Score: <var>100</var> points

Problem Statement

M-kun is a competitor in AtCoder, whose highest rating is <var>X</var>.

In this site, a competitor is given a kyu (class) according to his/her highest rating. For ratings from <var>400</var> through <var>1999</var>, the following kyus are given:

From <var>400</var> through <var>599</var>: <var>8</var>-kyu

From <var>600</var> through <var>799</var>: <var>7</var>-kyu

From <var>800</var> through <var>999</var>: <var>6</var>-kyu

From <var>1000</var> through <var>1199</var>: <var>5</var>-kyu

From <var>1200</var> through <var>1399</var>: <var>4</var>-kyu

From <var>1400</var> through <var>1599</var>: <var>3</var>-kyu

From <var>1600</var> through <var>1799</var>: <var>2</var>-kyu

From <var>1800</var> through <var>1999</var>: <var>1</var>-kyu

What kyu does M-kun have?

Constraints

<var>400 \leq X \leq 1999</var>

<var>X</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

Print the kyu M-kun has, as an integer.
For example, if he has <var>8</var>-kyu, print 8.

Sample Input 1

725

Sample Output 1

7

M-kun's highest rating is <var>725</var>, which corresponds to <var>7</var>-kyu.

Thus, 7 is the correct output.

Sample Input 2

1600

Sample Output 2

2

M-kun's highest rating is <var>1600</var>, which corresponds to <var>2</var>-kyu.

Thus, 2 is the correct output.


Score : <var>100</var> points

Problem Statement

Given is an integer <var>r</var>.

How many times is the area of a circle of radius <var>r</var> larger than the area of a circle of radius <var>1</var>?

It can be proved that the answer is always an integer under the constraints given.

Constraints

<var>1 \leq r \leq 100</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>r</var>

Output

Print the area of a circle of radius <var>r</var>, divided by the area of a circle of radius <var>1</var>, as an integer.

Sample Input 1

2

Sample Output 1

4

The area of a circle of radius <var>2</var> is <var>4</var> times larger than the area of a circle of radius <var>1</var>.

Note that output must be an integer - for example, 4.0 will not be accepted.

Sample Input 2

100

Sample Output 2

10000


Score : <var>300</var> points

Problem Statement

Takahashi is a teacher responsible for a class of <var>N</var> students.

The students are given distinct student numbers from <var>1</var> to <var>N</var>.

Today, all the students entered the classroom at different times.

According to Takahashi's record, there were <var>A_i</var> students in the classroom when student number <var>i</var> entered the classroom (including student number <var>i</var>).

From these records, reconstruct the order in which the students entered the classroom.

Constraints

<var> 1 \le N \le 10^5 </var>

<var> 1 \le A_i \le N </var>

<var> A_i \neq A_j </var> <var>(i \neq j)</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>A_2</var> <var>\ldots</var> <var>A_N</var>

Output

Print the student numbers of the students in the order the students entered the classroom.

Sample Input 1

3
2 3 1

Sample Output 1

3 1 2

First, student number <var>3</var> entered the classroom.

Then, student number <var>1</var> entered the classroom.

Finally, student number <var>2</var> entered the classroom.

Sample Input 2

5
1 2 3 4 5

Sample Output 2

1 2 3 4 5

Sample Input 3

8
8 2 7 3 4 5 6 1

Sample Output 3

8 2 4 5 6 7 3 1


Score : <var>200</var> points

Problem Statement

There are <var>N</var> positive integers written on a blackboard: <var>A_1, ..., A_N</var>.

Snuke can perform the following operation when all integers on the blackboard are even:

Replace each integer <var>X</var> on the blackboard by <var>X</var> divided by <var>2</var>.

Find the maximum possible number of operations that Snuke can perform.

Constraints

<var>1 \leq N \leq 200</var>

<var>1 \leq A_i \leq 10^9</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>A_2</var> ... <var>A_N</var>

Output

Print the maximum possible number of operations that Snuke can perform.

Sample Input 1

3
8 12 40

Sample Output 1

2

Initially, <var>[8, 12, 40]</var> are written on the blackboard.
Since all those integers are even, Snuke can perform the operation.

After the operation is performed once, <var>[4, 6, 20]</var> are written on the blackboard.
Since all those integers are again even, he can perform the operation.

After the operation is performed twice, <var>[2, 3, 10]</var> are written on the blackboard.
Now, there is an odd number <var>3</var> on the blackboard, so he cannot perform the operation any more.

Thus, Snuke can perform the operation at most twice.

Sample Input 2

4
5 6 8 10

Sample Output 2

0

Since there is an odd number <var>5</var> on the blackboard already in the beginning, Snuke cannot perform the operation at all.

Sample Input 3

6
382253568 723152896 37802240 379425024 404894720 471526144

Sample Output 3

8


Score : <var>300</var> points

Problem Statement

Takahashi is standing on a multiplication table with infinitely many rows and columns.

The square <var>(i,j)</var> contains the integer <var>i \times j</var>. Initially, Takahashi is standing at <var>(1,1)</var>.

In one move, he can move from <var>(i,j)</var> to either <var>(i+1,j)</var> or <var>(i,j+1)</var>.

Given an integer <var>N</var>, find the minimum number of moves needed to reach a square that contains <var>N</var>.

Constraints

<var>2 \leq N \leq 10^{12}</var>

<var>N</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the minimum number of moves needed to reach a square that contains the integer <var>N</var>.

Sample Input 1

10

Sample Output 1

5

<var>(2,5)</var> can be reached in five moves. We cannot reach a square that contains <var>10</var> in less than five moves.

Sample Input 2

50

Sample Output 2

13

<var>(5, 10)</var> can be reached in <var>13</var> moves.

Sample Input 3

10000000019

Sample Output 3

10000000018

Both input and output may be enormous.


Score : <var>100</var> points

Problem Statement

You are given a positive integer <var>N</var>.
Find the minimum positive integer divisible by both <var>2</var> and <var>N</var>.

Constraints

<var>1 \leq N \leq 10^9</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the minimum positive integer divisible by both <var>2</var> and <var>N</var>.

Sample Input 1

3

Sample Output 1

6

<var>6</var> is divisible by both <var>2</var> and <var>3</var>.
Also, there is no positive integer less than <var>6</var> that is divisible by both <var>2</var> and <var>3</var>.
Thus, the answer is <var>6</var>.

Sample Input 2

10

Sample Output 2

10

Sample Input 3

999999999

Sample Output 3

1999999998


Score : <var>200</var> points

Problem Statement

You are visiting a large electronics store to buy a refrigerator and a microwave.

The store sells <var>A</var> kinds of refrigerators and <var>B</var> kinds of microwaves. The <var>i</var>-th refrigerator ( <var>1 \le i \le A</var> ) is sold at <var>a_i</var> yen (the currency of Japan), and the <var>j</var>-th microwave ( <var>1 \le j \le B</var> ) is sold at <var>b_j</var> yen.

You have <var>M</var> discount tickets. With the <var>i</var>-th ticket ( <var>1 \le i \le M</var> ), you can get a discount of <var>c_i</var> yen from the total price when buying the <var>x_i</var>-th refrigerator and the <var>y_i</var>-th microwave together. Only one ticket can be used at a time.

You are planning to buy one refrigerator and one microwave. Find the minimum amount of money required.

Constraints

All values in input are integers.

<var> 1 \le A \le 10^5 </var>

<var> 1 \le B \le 10^5 </var>

<var> 1 \le M \le 10^5 </var>

<var> 1 \le a_i , b_i , c_i \le 10^5 </var>

<var> 1 \le x_i \le A </var>

<var> 1 \le y_i \le B </var>

<var> c_i \le a_{x_i} + b_{y_i} </var>

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>M</var>
<var>a_1</var> <var>a_2</var> <var>...</var> <var>a_A</var>
<var>b_1</var> <var>b_2</var> <var>...</var> <var>b_B</var>
<var>x_1</var> <var>y_1</var> <var>c_1</var>
<var>\vdots</var>
<var>x_M</var> <var>y_M</var> <var>c_M</var>

Output

Print the answer.

Sample Input 1

2 3 1
3 3
3 3 3
1 2 1

Sample Output 1

5

With the ticket, you can get the <var>1</var>-st refrigerator and the <var>2</var>-nd microwave for <var>3+3-1=5</var> yen.

Sample Input 2

1 1 2
10
10
1 1 5
1 1 10

Sample Output 2

10

Note that you cannot use more than one ticket at a time.

Sample Input 3

2 2 1
3 5
3 5
2 2 2

Sample Output 3

6

You can get the <var>1</var>-st refrigerator and the <var>1</var>-st microwave for <var>6</var> yen, which is the minimum amount to pay in this case.
Note that using a ticket is optional.


Score : <var>200</var> points

Problem Statement

A ball will bounce along a number line, making <var>N + 1</var> bounces. It will make the first bounce at coordinate <var>D_1 = 0</var>, and the <var>i</var>-th bounce <var>(2 \leq i \leq N+1)</var> at coordinate <var>D_i = D_{i-1} + L_{i-1}</var>.

How many times will the ball make a bounce where the coordinate is at most <var>X</var>?

Constraints

<var>1 \leq N \leq 100</var>

<var>1 \leq L_i \leq 100</var>

<var>1 \leq X \leq 10000</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>X</var>
<var>L_1</var> <var>L_2</var> <var>...</var> <var>L_{N-1}</var> <var>L_N</var>

Output

Print the number of times the ball will make a bounce where the coordinate is at most <var>X</var>.

Sample Input 1

3 6
3 4 5

Sample Output 1

2

The ball will make a bounce at the coordinates <var>0</var>, <var>3</var>, <var>7</var> and <var>12</var>, among which two are less than or equal to <var>6</var>.

Sample Input 2

4 9
3 3 3 3

Sample Output 2

4

The ball will make a bounce at the coordinates <var>0</var>, <var>3</var>, <var>6</var>, <var>9</var> and <var>12</var>, among which four are less than or equal to <var>9</var>.


Score : <var>100</var> points

Problem Statement

In AtCoder City, there are three stations numbered <var>1</var>, <var>2</var>, and <var>3</var>.

Each of these stations is operated by one of the two railway companies, A and B. A string <var>S</var> of length <var>3</var> represents which company operates each station. If <var>S_i</var> is A, Company A operates Station <var>i</var>; if <var>S_i</var> is B, Company B operates Station <var>i</var>.

To improve the transportation condition, for each pair of a station operated by Company A and one operated by Company B, there will be a bus service connecting them.

Determine if there is a pair of stations that will be connected by a bus service.

Constraints

Each character of <var>S</var> is A or B.

<var>|S| = 3</var>

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

If there is a pair of stations that will be connected by a bus service, print Yes; otherwise, print No.

Sample Input 1

ABA

Sample Output 1

Yes

Company A operates Station <var>1</var> and <var>3</var>, while Company B operates Station <var>2</var>.

There will be a bus service between Station <var>1</var> and <var>2</var>, and between Station <var>2</var> and <var>3</var>, so print Yes.

Sample Input 2

BBA

Sample Output 2

Yes

Company B operates Station <var>1</var> and <var>2</var>, while Company A operates Station <var>3</var>.

There will be a bus service between Station <var>1</var> and <var>3</var>, and between Station <var>2</var> and <var>3</var>, so print Yes.

Sample Input 3

BBB

Sample Output 3

No

Company B operates all the stations. Thus, there will be no bus service, so print No.


Score : <var>300</var> points

Problem Statement

Given is a string <var>S</var>. Let <var>T</var> be the concatenation of <var>K</var> copies of <var>S</var>.
We can repeatedly perform the following operation: choose a character in <var>T</var> and replace it with a different character.
Find the minimum number of operations required to satisfy the following condition: any two adjacent characters in <var>T</var> are different.

Constraints

<var>1 \leq |S| \leq 100</var>

<var>S</var> consists of lowercase English letters.

<var>1 \leq K \leq 10^9</var>

<var>K</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>S</var>
<var>K</var>

Output

Print the minimum number of operations required.

Sample Input 1

issii
2

Sample Output 1

4

<var>T</var> is issiiissii.  For example, we can rewrite it into ispiqisyhi, and now any two adjacent characters are different.

Sample Input 2

qq
81

Sample Output 2

81

Sample Input 3

cooooooooonteeeeeeeeeest
999993333

Sample Output 3

8999939997


Score: <var>300</var> points

Problem Statement

Find the minimum prime number greater than or equal to <var>X</var>.

Notes

A prime number is an integer greater than <var>1</var> that cannot be evenly divided by any positive integer except <var>1</var> and itself.

For example, <var>2</var>, <var>3</var>, and <var>5</var> are prime numbers, while <var>4</var> and <var>6</var> are not.

Constraints

<var> 2 \le X \le 10^5 </var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

Print the minimum prime number greater than or equal to <var>X</var>.

Sample Input 1

20

Sample Output 1

23

The minimum prime number greater than or equal to <var>20</var> is <var>23</var>.

Sample Input 2

2

Sample Output 2

2

<var>X</var> itself can be a prime number.

Sample Input 3

99992

Sample Output 3

100003


Score : <var>300</var> points

Problem Statement

There are <var>N+1</var> towns. The <var>i</var>-th town is being attacked by <var>A_i</var> monsters.

We have <var>N</var> heroes. The <var>i</var>-th hero can defeat monsters attacking the <var>i</var>-th or <var>(i+1)</var>-th town, for a total of at most <var>B_i</var> monsters.

What is the maximum total number of monsters the heroes can cooperate to defeat?

Constraints

All values in input are integers.

<var>1 \leq N \leq 10^5</var>

<var>1 \leq A_i \leq 10^9</var>

<var>1 \leq B_i \leq 10^9</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>A_2</var> <var>...</var> <var>A_{N+1}</var>
<var>B_1</var> <var>B_2</var> <var>...</var> <var>B_N</var>

Output

Print the maximum total number of monsters the heroes can defeat.

Sample Input 1

2
3 5 2
4 5

Sample Output 1

9

If the heroes choose the monsters to defeat as follows, they can defeat nine monsters in total, which is the maximum result.

The first hero defeats two monsters attacking the first town and two monsters attacking the second town.

The second hero defeats three monsters attacking the second town and two monsters attacking the third town.

Sample Input 2

3
5 6 3 8
5 100 8

Sample Output 2

22

Sample Input 3

2
100 1 1
1 100

Sample Output 3

3


Score : <var>200</var> points

Problem Statement

There is a rectangle in the <var>xy</var>-plane, with its lower left corner at <var>(0, 0)</var> and its upper right corner at <var>(W, H)</var>. Each of its sides is parallel to the <var>x</var>-axis or <var>y</var>-axis. Initially, the whole region within the rectangle is painted white.

Snuke plotted <var>N</var> points into the rectangle. The coordinate of the <var>i</var>-th (<var>1 ≦ i ≦ N</var>) point was <var>(x_i, y_i)</var>.

Then, he created an integer sequence <var>a</var> of length <var>N</var>, and for each <var>1 ≦ i ≦ N</var>, he painted some region within the rectangle black, as follows:

If <var>a_i = 1</var>, he painted the region satisfying <var>x < x_i</var> within the rectangle.

If <var>a_i = 2</var>, he painted the region satisfying <var>x > x_i</var> within the rectangle.

If <var>a_i = 3</var>, he painted the region satisfying <var>y < y_i</var> within the rectangle.

If <var>a_i = 4</var>, he painted the region satisfying <var>y > y_i</var> within the rectangle.

Find the area of the white region within the rectangle after he finished painting.

Constraints

<var>1 ≦ W, H ≦ 100</var>

<var>1 ≦ N ≦ 100</var>

<var>0 ≦ x_i ≦ W</var> (<var>1 ≦ i ≦ N</var>)

<var>0 ≦ y_i ≦ H</var> (<var>1 ≦ i ≦ N</var>)

<var>W</var>, <var>H</var> (21:32, added), <var>x_i</var> and <var>y_i</var> are integers.

<var>a_i</var> (<var>1 ≦ i ≦ N</var>) is <var>1, 2, 3</var> or <var>4</var>.

Input

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

<var>W</var> <var>H</var> <var>N</var>
<var>x_1</var> <var>y_1</var> <var>a_1</var>
<var>x_2</var> <var>y_2</var> <var>a_2</var>
<var>:</var>
<var>x_N</var> <var>y_N</var> <var>a_N</var>

Output

Print the area of the white region within the rectangle after Snuke finished painting.

Sample Input 1

5 4 2
2 1 1
3 3 4

Sample Output 1

9

The figure below shows the rectangle before Snuke starts painting.

First, as <var>(x_1, y_1) = (2, 1)</var> and <var>a_1 = 1</var>, he paints the region satisfying <var>x < 2</var> within the rectangle:

Then, as <var>(x_2, y_2) = (3, 3)</var> and <var>a_2 = 4</var>, he paints the region satisfying <var>y > 3</var> within the rectangle:

Now, the area of the white region within the rectangle is <var>9</var>.

Sample Input 2

5 4 3
2 1 1
3 3 4
1 4 2

Sample Output 2

0

It is possible that the whole region within the rectangle is painted black.

Sample Input 3

10 10 5
1 6 1
4 1 3
6 9 4
9 4 2
3 1 3

Sample Output 3

64


Score : <var>100</var> points

Problem Statement

You are given a <var>4</var>-character string <var>S</var> consisting of uppercase English letters.
Determine if <var>S</var> consists of exactly two kinds of characters which both appear twice in <var>S</var>.

Constraints

The length of <var>S</var> is <var>4</var>.

<var>S</var> consists of uppercase English letters.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

If <var>S</var> consists of exactly two kinds of characters which both appear twice in <var>S</var>, print Yes; otherwise, print No.

Sample Input 1

ASSA

Sample Output 1

Yes

<var>S</var> consists of A and S which both appear twice in <var>S</var>.

Sample Input 2

STOP

Sample Output 2

No

Sample Input 3

FFEE

Sample Output 3

Yes

Sample Input 4

FREE

Sample Output 4

No


Score : <var>300</var> points

Problem Statement

You drew lottery <var>N</var> times. In the <var>i</var>-th draw, you got an item of the kind represented by a string <var>S_i</var>.

How many kinds of items did you get?

Constraints

<var>1 \leq N \leq 2\times 10^5</var>

<var>S_i</var> consists of lowercase English letters and has a length between <var>1</var> and <var>10</var> (inclusive).

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>S_1</var>
<var>:</var>
<var>S_N</var>

Output

Print the number of kinds of items you got.

Sample Input 1

3
apple
orange
apple

Sample Output 1

2

You got two kinds of items: apple and orange.

Sample Input 2

5
grape
grape
grape
grape
grape

Sample Output 2

1

Sample Input 3

4
aaaa
a
aaa
aa

Sample Output 3

4


Score : <var>100</var> points

Problem Statement

There are three airports A, B and C, and flights between each pair of airports in both directions.

A one-way flight between airports A and B takes <var>P</var> hours, a one-way flight between airports B and C takes <var>Q</var> hours, and a one-way flight between airports C and A takes <var>R</var> hours.

Consider a route where we start at one of the airports, fly to another airport and then fly to the other airport.

What is the minimum possible sum of the flight times?

Constraints

<var>1 \leq P,Q,R \leq 100</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>P</var> <var>Q</var> <var>R</var>

Output

Print the minimum possible sum of the flight times.

Sample Input 1

1 3 4

Sample Output 1

4

The sum of the flight times in the route A <var>\rightarrow</var> B <var>\rightarrow</var> C: <var>1 + 3 = 4</var> hours

The sum of the flight times in the route A <var>\rightarrow</var> C <var>\rightarrow</var> C: <var>4 + 3 = 7</var> hours

The sum of the flight times in the route B <var>\rightarrow</var> A <var>\rightarrow</var> C: <var>1 + 4 = 5</var> hours

The sum of the flight times in the route B <var>\rightarrow</var> C <var>\rightarrow</var> A: <var>3 + 4 = 7</var> hours

The sum of the flight times in the route C <var>\rightarrow</var> A <var>\rightarrow</var> B: <var>4 + 1 = 5</var> hours

The sum of the flight times in the route C <var>\rightarrow</var> B <var>\rightarrow</var> A: <var>3 + 1 = 4</var> hours

The minimum of these is <var>4</var> hours.

Sample Input 2

3 2 3

Sample Output 2

5


Score : <var>400</var> points

Problem Statement

You have a sequence <var>A</var> composed of <var>N</var> positive integers: <var>A_{1}, A_{2}, \cdots, A_{N}</var>.

You will now successively do the following <var>Q</var> operations:

In the <var>i</var>-th operation, you replace every element whose value is <var>B_{i}</var> with <var>C_{i}</var>.

For each <var>i</var> <var>(1 \leq i \leq Q)</var>, find <var>S_{i}</var>: the sum of all elements in <var>A</var> just after the <var>i</var>-th operation.

Constraints

All values in input are integers.

<var> 1 \leq N, Q, A_{i}, B_{i}, C_{i} \leq 10^{5} </var>

<var> B_{i} \neq C_{i} </var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_{1}</var> <var>A_{2}</var> <var>\cdots</var> <var>A_{N}</var>
<var>Q</var>
<var>B_{1}</var> <var>C_{1}</var>
<var>B_{2}</var> <var>C_{2}</var>
<var>\vdots</var>
<var>B_{Q}</var> <var>C_{Q}</var>

Output

Print <var>Q</var> integers <var>S_{i}</var> to Standard Output in the following format:

<var>S_{1}</var>
<var>S_{2}</var>
<var>\vdots</var>
<var>S_{Q}</var>

Note that <var>S_{i}</var> may not fit into a <var>32</var>-bit integer.

Sample Input 1

4
1 2 3 4
3
1 2
3 4
2 4

Sample Output 1

11
12
16

Initially, the sequence <var>A</var> is <var>1,2,3,4</var>.

After each operation, it becomes the following:

<var>2, 2, 3, 4</var>

<var>2, 2, 4, 4</var>

<var>4, 4, 4, 4</var>

Sample Input 2

4
1 1 1 1
3
1 2
2 1
3 5

Sample Output 2

8
4
4

Note that the sequence <var>A</var> may not contain an element whose value is <var>B_{i}</var>.

Sample Input 3

2
1 2
3
1 100
2 100
100 1000

Sample Output 3

102
200
2000


Score : <var>100</var> points

Problem Statement

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 <var>a</var>, <var>b</var> and <var>c</var> yen (the currency of Japan), respectively.
Find the minimum total price of two different bells.

Constraints

<var>1 \leq a,b,c \leq 10000</var>

<var>a</var>, <var>b</var> and <var>c</var> are integers.

Input

Input is given from Standard Input in the following format:

<var>a</var> <var>b</var> <var>c</var>

Output

Print the minimum total price of two different bells.

Sample Input 1

700 600 780

Sample Output 1

1300

Buying a <var>700</var>-yen bell and a <var>600</var>-yen bell costs <var>1300</var> yen.

Buying a <var>700</var>-yen bell and a <var>780</var>-yen bell costs <var>1480</var> yen.

Buying a <var>600</var>-yen bell and a <var>780</var>-yen bell costs <var>1380</var> yen.

The minimum among these is <var>1300</var> yen.

Sample Input 2

10000 10000 10000

Sample Output 2

20000

Buying any two bells costs <var>20000</var> yen.


Score : <var>200</var> points

Problem Statement

We have a bingo card with a <var>3\times3</var> grid. The square at the <var>i</var>-th row from the top and the <var>j</var>-th column from the left contains the number <var>A_{i, j}</var>.

The MC will choose <var>N</var> numbers, <var>b_1, b_2, \cdots, b_N</var>. If our bingo sheet contains some of those numbers, we will mark them on our sheet.

Determine whether we will have a bingo when the <var>N</var> numbers are chosen, that is, the sheet will contain three marked numbers in a row, column, or diagonal.

Constraints

All values in input are integers.

<var>1 \leq A_{i, j} \leq 100</var>

<var>A_{i_1, j_1} \neq A_{i_2, j_2} ((i_1, j_1) \neq (i_2, j_2))</var>

<var>1 \leq N \leq 10</var>

<var>1 \leq b_i \leq 100</var>

<var>b_i \neq b_j (i \neq j)</var>

Input

Input is given from Standard Input in the following format:

<var>A_{1, 1}</var> <var>A_{1, 2}</var> <var>A_{1, 3}</var>
<var>A_{2, 1}</var> <var>A_{2, 2}</var> <var>A_{2, 3}</var>
<var>A_{3, 1}</var> <var>A_{3, 2}</var> <var>A_{3, 3}</var>
<var>N</var>
<var>b_1</var>
<var>\vdots</var>
<var>b_N</var>

Output

If we will have a bingo, print Yes; otherwise, print No.

Sample Input 1

84 97 66
79 89 11
61 59 7
7
89
7
87
79
24
84
30

Sample Output 1

Yes

We will mark <var>A_{1, 1}, A_{2, 1}, A_{2, 2}, A_{3, 3}</var>, and complete the diagonal from the top-left to the bottom-right.

Sample Input 2

41 7 46
26 89 2
78 92 8
5
6
45
16
57
17

Sample Output 2

No

We will mark nothing.

Sample Input 3

60 88 34
92 41 43
65 73 48
10
60
43
88
11
48
73
65
41
92
34

Sample Output 3

Yes

We will mark all the squares.


Score : <var>300</var> points

Problem Statement

Given is a permutation <var>P_1, \ldots, P_N</var> of <var>1, \ldots, N</var>.
Find the number of integers <var>i</var> <var>(1 \leq i \leq N)</var> that satisfy the following condition:

For any integer <var>j</var> <var>(1 \leq j \leq i)</var>, <var>P_i \leq P_j</var>.

Constraints

<var>1 \leq N \leq 2 \times 10^5</var>

<var>P_1, \ldots, P_N</var> is a permutation of <var>1, \ldots, N</var>.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>P_1</var> <var>...</var> <var>P_N</var>

Output

Print the number of integers <var>i</var> that satisfy the condition.

Sample Input 1

5
4 2 5 1 3

Sample Output 1

3

<var>i=1</var>, <var>2</var>, and <var>4</var> satisfy the condition, but <var>i=3</var> does not - for example, <var>P_i > P_j</var> holds for <var>j = 1</var>.

Similarly, <var>i=5</var> does not satisfy the condition, either. Thus, there are three integers that satisfy the condition.

Sample Input 2

4
4 3 2 1

Sample Output 2

4

All integers <var>i</var> <var>(1 \leq i \leq N)</var> satisfy the condition.

Sample Input 3

6
1 2 3 4 5 6

Sample Output 3

1

Only <var>i=1</var> satisfies the condition.

Sample Input 4

8
5 7 4 2 6 8 1 3

Sample Output 4

4

Sample Input 5

1
1

Sample Output 5

1


Score : <var>300</var> points

Problem Statement

If there is an integer not less than <var>0</var> satisfying the following conditions, print the smallest such integer; otherwise, print -1.

The integer has exactly <var>N</var> digits in base ten. (We assume <var>0</var> to be a <var>1</var>-digit integer. For other integers, leading zeros are not allowed.)

The <var>s_i</var>-th digit from the left is <var>c_i</var>. <var>\left(i = 1, 2, \cdots, M\right)</var>

Constraints

All values in input are integers.

<var>1 \leq N \leq 3</var>

<var>0 \leq M \leq 5</var>

<var>1 \leq s_i \leq N</var>

<var>0 \leq c_i \leq 9</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>s_1</var> <var>c_1</var>
<var>\vdots</var>
<var>s_M</var> <var>c_M</var>

Output

Print the answer.

Sample Input 1

3 3
1 7
3 2
1 7

Sample Output 1

702

<var>702</var> satisfies the conditions - its <var>1</var>-st and <var>3</var>-rd digits are 7 and 2, respectively - while no non-negative integer less than <var>702</var> satisfies them.

Sample Input 2

3 2
2 1
2 3

Sample Output 2

-1

Sample Input 3

3 1
1 0

Sample Output 3

-1


Score : <var>200</var> points

Problem Statement

There are <var>N</var> gems. The value of the <var>i</var>-th gem is <var>V_i</var>.

You will choose some of these gems, possibly all or none, and get them.

However, you need to pay a cost of <var>C_i</var> to get the <var>i</var>-th gem.

Let <var>X</var> be the sum of the values of the gems obtained, and <var>Y</var> be the sum of the costs paid.

Find the maximum possible value of <var>X-Y</var>.

Constraints

All values in input are integers.

<var>1 \leq N \leq 20</var>

<var>1 \leq C_i, V_i \leq 50</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>V_1</var> <var>V_2</var> <var>...</var> <var>V_N</var>
<var>C_1</var> <var>C_2</var> <var>...</var> <var>C_N</var>

Output

Print the maximum possible value of <var>X-Y</var>.

Sample Input 1

3
10 2 5
6 3 4

Sample Output 1

5

If we choose the first and third gems, <var>X = 10 + 5 = 15</var> and <var>Y = 6 + 4 = 10</var>.
We have <var>X-Y = 5</var> here, which is the maximum possible value.

Sample Input 2

4
13 21 6 19
11 30 6 15

Sample Output 2

6

Sample Input 3

1
1
50

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

AtCoder Inc. holds a contest every Saturday.

There are two types of contests called ABC and ARC, and just one of them is held at a time.

The company holds these two types of contests alternately: an ARC follows an ABC and vice versa.

Given a string <var>S</var> representing the type of the contest held last week, print the string representing the type of the contest held this week.

Constraints

<var>S</var> is ABC or ARC.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the string representing the type of the contest held this week.

Sample Input 1

ABC

Sample Output 1

ARC

They held an ABC last week, so they will hold an ARC this week.


Score : <var>200</var> points

Problem Statement

You are given a string <var>S</var>. Each character of <var>S</var> is uppercase or lowercase English letter.
Determine if <var>S</var> satisfies all of the following conditions:

The initial character of <var>S</var> is an uppercase A.

There is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).

All letters except the A and C mentioned above are lowercase.

Constraints

<var>4 ≤ |S| ≤ 10</var> (<var>|S|</var> is the length of the string <var>S</var>.)

Each character of <var>S</var> is uppercase or lowercase English letter.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

If <var>S</var> satisfies all of the conditions in the problem statement, print AC; otherwise, print WA.

Sample Input 1

AtCoder

Sample Output 1

AC

The first letter is A, the third letter is C and the remaining letters are all lowercase, so all the conditions are satisfied.

Sample Input 2

ACoder

Sample Output 2

WA

The second letter should not be C.

Sample Input 3

AcycliC

Sample Output 3

WA

The last letter should not be C, either.

Sample Input 4

AtCoCo

Sample Output 4

WA

There should not be two or more occurrences of C.

Sample Input 5

Atcoder

Sample Output 5

WA

The number of C should not be zero, either.


Score : <var>300</var> points

Problem Statement

You are given a sequence of length <var>N</var>: <var>A_1, A_2, ..., A_N</var>.
For each integer <var>i</var> between <var>1</var> and <var>N</var> (inclusive), answer the following question:

Find the maximum value among the <var>N-1</var> elements other than <var>A_i</var> in the sequence.

Constraints

<var>2 \leq N \leq 200000</var>

<var>1 \leq A_i \leq 200000</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var>
<var>:</var>
<var>A_N</var>

Output

Print <var>N</var> lines. The <var>i</var>-th line (<var>1 \leq i \leq N</var>) should contain the maximum value among the <var>N-1</var> elements other than <var>A_i</var> in the sequence.

Sample Input 1

3
1
4
3

Sample Output 1

4
3
4

The maximum value among the two elements other than <var>A_1</var>, that is, <var>A_2 = 4</var> and <var>A_3 = 3</var>, is <var>4</var>.

The maximum value among the two elements other than <var>A_2</var>, that is, <var>A_1 = 1</var> and <var>A_3 = 3</var>, is <var>3</var>.

The maximum value among the two elements other than <var>A_3</var>, that is, <var>A_1 = 1</var> and <var>A_2 = 4</var>, is <var>4</var>.

Sample Input 2

2
5
5

Sample Output 2

5
5


Score : <var>100</var> points

Problem Statement

We have five variables <var>x_1, x_2, x_3, x_4,</var> and <var>x_5</var>.

The variable <var>x_i</var> was initially assigned a value of <var>i</var>.

Snuke chose one of these variables and assigned it <var>0</var>.

You are given the values of the five variables after this assignment.

Find out which variable Snuke assigned <var>0</var>.

Constraints

The values of <var>x_1, x_2, x_3, x_4,</var> and <var>x_5</var> given as input are a possible outcome of the assignment by Snuke.

Input

Input is given from Standard Input in the following format:

<var>x_1</var> <var>x_2</var> <var>x_3</var> <var>x_4</var> <var>x_5</var>

Output

If the variable Snuke assigned <var>0</var> was <var>x_i</var>, print the integer <var>i</var>.

Sample Input 1

0 2 3 4 5

Sample Output 1

1

In this case, Snuke assigned <var>0</var> to <var>x_1</var>, so we should print <var>1</var>.

Sample Input 2

1 2 0 4 5

Sample Output 2

3


Score : <var>400</var> points

Problem Statement

Given is a string <var>S</var> consisting of L and R.

Let <var>N</var> be the length of <var>S</var>. There are <var>N</var> squares arranged from left to right, and the <var>i</var>-th character of <var>S</var> from the left is written on the <var>i</var>-th square from the left.

The character written on the leftmost square is always R, and the character written on the rightmost square is always L.

Initially, one child is standing on each square.

Each child will perform the move below <var>10^{100}</var> times:

Move one square in the direction specified by the character written in the square on which the child is standing. L denotes left, and R denotes right.

Find the number of children standing on each square after the children performed the moves.

Constraints

<var>S</var> is a string of length between <var>2</var> and <var>10^5</var> (inclusive).

Each character of <var>S</var> is L or R.

The first and last characters of <var>S</var> are R and L, respectively.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the number of children standing on each square after the children performed the moves, in order from left to right.

Sample Input 1

RRLRL

Sample Output 1

0 1 2 1 1

After each child performed one move, the number of children standing on each square is <var>0, 2, 1, 1, 1</var> from left to right.

After each child performed two moves, the number of children standing on each square is <var>0, 1, 2, 1, 1</var> from left to right.

After each child performed <var>10^{100}</var> moves, the number of children standing on each square is <var>0, 1, 2, 1, 1</var> from left to right.

Sample Input 2

RRLLLLRLRRLL

Sample Output 2

0 3 3 0 0 0 1 1 0 2 2 0

Sample Input 3

RRRLLRLLRRRLLLLL

Sample Output 3

0 0 3 2 0 2 1 0 0 0 4 4 0 0 0 0


Score : <var>200</var> points

Problem Statement

You are given an <var>H × W</var> grid.

The squares in the grid are described by <var>H</var> strings, <var>S_1,...,S_H</var>.

The <var>j</var>-th character in the string <var>S_i</var> corresponds to the square at the <var>i</var>-th row from the top and <var>j</var>-th column from the left <var>(1 \leq i \leq H,1 \leq j \leq W)</var>.

. stands for an empty square, and # stands for a square containing a bomb.

Dolphin is interested in how many bomb squares are horizontally, vertically or diagonally adjacent to each empty square.

(Below, we will simply say "adjacent" for this meaning. For each square, there are at most eight adjacent squares.)

He decides to replace each . in our <var>H</var> strings with a digit that represents the number of bomb squares adjacent to the corresponding empty square.

Print the strings after the process.

Constraints

<var>1 \leq H,W \leq 50</var>

<var>S_i</var> is a string of length <var>W</var> consisting of # and ..

Input

Input is given from Standard Input in the following format:

<var>H</var> <var>W</var>
<var>S_1</var>
<var>:</var>
<var>S_H</var>

Output

Print the <var>H</var> strings after the process.

The <var>i</var>-th line should contain a string <var>T_i</var> of length <var>W</var>, where the <var>j</var>-th character in <var>T_i</var> corresponds to the square at the <var>i</var>-th row from the top and <var>j</var>-th row from the left in the grid <var>(1 \leq i \leq H, 1 \leq j \leq W)</var>.

Sample Input 1

3 5
.....
.#.#.
.....

Sample Output 1

11211
1#2#1
11211

For example, let us observe the empty square at the first row from the top and first column from the left.

There is one bomb square adjacent to this empty square: the square at the second row and second column.

Thus, the . corresponding to this empty square is replaced with 1.

Sample Input 2

3 5
#####
#####
#####

Sample Output 2

#####
#####
#####

It is possible that there is no empty square.

Sample Input 3

6 6
#####.
#.#.##
####.#
.#..#.
#.##..
#.#...

Sample Output 3

#####3
#8#7##
####5#
4#65#2
#5##21
#4#310


Score : <var>500</var> points

Problem Statement

We have a two-dimensional grid with <var>H \times W</var> squares. There are <var>M</var> targets to destroy in this grid - the position of the <var>i</var>-th target is <var>\left(h_i, w_i \right)</var>.

Takahashi will choose one square in this grid, place a bomb there, and ignite it. The bomb will destroy all targets that are in the row or the column where the bomb is placed. It is possible to place the bomb at a square with a target.

Takahashi is trying to maximize the number of targets to destroy. Find the maximum number of targets that can be destroyed.

Constraints

All values in input are integers.

<var>1 \leq H, W \leq 3 \times 10^5</var>

<var>1 \leq M \leq \min\left(H\times W, 3 \times 10^5\right)</var>

<var>1 \leq h_i \leq H</var>

<var>1 \leq w_i \leq W</var>

<var>\left(h_i, w_i\right) \neq \left(h_j, w_j\right) \left(i \neq j\right)</var>

Input

Input is given from Standard Input in the following format:

<var>H</var> <var>W</var> <var>M</var>
<var>h_1</var> <var>w_1</var>
<var>\vdots</var>
<var>h_M</var> <var>w_M</var>

Output

Print the answer.

Sample Input 1

2 3 3
2 2
1 1
1 3

Sample Output 1

3

We can destroy all the targets by placing the bomb at <var>\left(1, 2\right)</var>.

Sample Input 2

3 3 4
3 3
3 1
1 1
1 2

Sample Output 2

3

Sample Input 3

5 5 10
2 5
4 3
2 3
5 5
2 2
5 4
5 3
5 1
3 5
1 4

Sample Output 3

6


Score : <var>200</var> points

Problem Statement

<var>N</var> Snukes called Snuke <var>1</var>, Snuke <var>2</var>, ..., Snuke <var>N</var> live in a town.

There are <var>K</var> kinds of snacks sold in this town, called Snack <var>1</var>, Snack <var>2</var>, ..., Snack <var>K</var>. The following <var>d_i</var> Snukes have Snack <var>i</var>: Snuke <var>A_{i, 1}, A_{i, 2}, \cdots, A_{i, {d_i}}</var>.

Takahashi will walk around this town and make mischief on the Snukes who have no snacks. How many Snukes will fall victim to Takahashi's mischief?

Constraints

All values in input are integers.

<var>1 \leq N \leq 100</var>

<var>1 \leq K \leq 100</var>

<var>1 \leq d_i \leq N</var>

<var>1 \leq A_{i, 1} < \cdots < A_{i, d_i} \leq N</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>d_1</var>
<var>A_{1, 1} \cdots A_{1, d_1}</var>
<var>\vdots</var>
<var>d_K</var>
<var>A_{K, 1} \cdots A_{K, d_K}</var>

Output

Print the answer.

Sample Input 1

3 2
2
1 3
1
3

Sample Output 1

1

Snuke <var>1</var> has Snack <var>1</var>.

Snuke <var>2</var> has no snacks.

Snuke <var>3</var> has Snack <var>1</var> and <var>2</var>.

Thus, there will be one victim: Snuke <var>2</var>.

Sample Input 2

3 3
1
3
1
3
1
3

Sample Output 2

2


Score : <var>400</var> points

Problem Statement

There are <var>N</var> integers, <var>A_1, A_2, ..., A_N</var>, arranged in a row in this order.

You can perform the following operation on this integer sequence any number of times:

Operation: Choose an integer <var>i</var> satisfying <var>1 \leq i \leq N-1</var>. Multiply both <var>A_i</var> and <var>A_{i+1}</var> by <var>-1</var>.

Let <var>B_1, B_2, ..., B_N</var> be the integer sequence after your operations.

Find the maximum possible value of <var>B_1 + B_2 + ... + B_N</var>.

Constraints

All values in input are integers.

<var>2 \leq N \leq 10^5</var>

<var>-10^9 \leq A_i \leq 10^9</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>A_1</var> <var>A_2</var> <var>...</var> <var>A_N</var>

Output

Print the maximum possible value of <var>B_1 + B_2 + ... + B_N</var>.

Sample Input 1

3
-10 5 -4

Sample Output 1

19

If we perform the operation as follows:

Choose <var>1</var> as <var>i</var>, which changes the sequence to <var>10, -5, -4</var>.

Choose <var>2</var> as <var>i</var>, which changes the sequence to <var>10, 5, 4</var>.

we have <var>B_1 = 10, B_2 = 5, B_3 = 4</var>. The sum here, <var>B_1 + B_2 + B_3 = 10 + 5 + 4 = 19</var>, is the maximum possible result.

Sample Input 2

5
10 -4 -8 -11 3

Sample Output 2

30

Sample Input 3

11
-1000000000 1000000000 -1000000000 1000000000 -1000000000 0 1000000000 -1000000000 1000000000 -1000000000 1000000000

Sample Output 3

10000000000

The output may not fit into a <var>32</var>-bit integer type.


Score : <var>200</var> points

Problem Statement

Given are strings <var>S</var> and <var>T</var>. Consider changing <var>S</var> to <var>T</var> by repeating the operation below. Find the minimum number of operations required to do so.

Operation: Choose one character of <var>S</var> and replace it with a different character.

Constraints

<var>S</var> and <var>T</var> have lengths between <var>1</var> and <var>2\times 10^5</var> (inclusive).

<var>S</var> and <var>T</var> consists of lowercase English letters.

<var>S</var> and <var>T</var> have equal lengths.

Input

Input is given from Standard Input in the following format:

<var>S</var>
<var>T</var>

Output

Print the answer.

Sample Input 1

cupofcoffee
cupofhottea

Sample Output 1

4

We can achieve the objective in four operations, such as the following:

First, replace the sixth character c with h.

Second, replace the eighth character f with t.

Third, replace the ninth character f with t.

Fourth, replace the eleventh character e with a.

Sample Input 2

abcde
bcdea

Sample Output 2

5

Sample Input 3

apple
apple

Sample Output 3

0

No operations may be needed to achieve the objective.


Score : <var>200</var> points

Problem Statement

Having learned the multiplication table, Takahashi can multiply two integers between <var>1</var> and <var>9</var> (inclusive) together.

Given an integer <var>N</var>, determine whether <var>N</var> can be represented as the product of two integers between <var>1</var> and <var>9</var>. If it can, print Yes; if it cannot, print No.

Constraints

<var>1 \leq N \leq 100</var>

<var>N</var> is an integer.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

If <var>N</var> can be represented as the product of two integers between <var>1</var> and <var>9</var> (inclusive), print Yes; if it cannot, print No.

Sample Input 1

10

Sample Output 1

Yes

<var>10</var> can be represented as, for example, <var>2 \times 5</var>.

Sample Input 2

50

Sample Output 2

No

<var>50</var> cannot be represented as the product of two integers between <var>1</var> and <var>9</var>.

Sample Input 3

81

Sample Output 3

Yes


Score : <var>400</var> points

Problem Statement

A positive integer <var>X</var> is said to be a lunlun number if and only if the following condition is satisfied:

In the base ten representation of <var>X</var> (without leading zeros), for every pair of two adjacent digits, the absolute difference of those digits is at most <var>1</var>.

For example, <var>1234</var>, <var>1</var>, and <var>334</var> are lunlun numbers, while none of <var>31415</var>, <var>119</var>, or <var>13579</var> is.

You are given a positive integer <var>K</var>. Find the <var>K</var>-th smallest lunlun number.

Constraints

<var>1 \leq K \leq 10^5</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>K</var>

Output

Print the answer.

Sample Input 1

15

Sample Output 1

23

We will list the <var>15</var> smallest lunlun numbers in ascending order:

<var>1</var>,
<var>2</var>,
<var>3</var>,
<var>4</var>,
<var>5</var>,
<var>6</var>,
<var>7</var>,
<var>8</var>,
<var>9</var>,
<var>10</var>,
<var>11</var>,
<var>12</var>,
<var>21</var>,
<var>22</var>,
<var>23</var>.

Thus, the answer is <var>23</var>.

Sample Input 2

1

Sample Output 2

1

Sample Input 3

13

Sample Output 3

21

Sample Input 4

100000

Sample Output 4

3234566667

Note that the answer may not fit into the <var>32</var>-bit signed integer type.


Score : <var>200</var> points

Problem Statement

A string <var>S</var> of an odd length is said to be a strong palindrome if and only if all of the following conditions are satisfied:

<var>S</var> is a palindrome.

Let <var>N</var> be the length of <var>S</var>. The string formed by the <var>1</var>-st through <var>((N-1)/2)</var>-th characters of <var>S</var> is a palindrome.

The string consisting of the <var>(N+3)/2</var>-st through <var>N</var>-th characters of <var>S</var> is a palindrome.

Determine whether <var>S</var> is a strong palindrome.

Constraints

<var>S</var> consists of lowercase English letters.

The length of <var>S</var> is an odd number between <var>3</var> and <var>99</var> (inclusive).

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

If <var>S</var> is a strong palindrome, print Yes;
otherwise, print No.

Sample Input 1

akasaka

Sample Output 1

Yes

<var>S</var> is akasaka.

The string formed by the <var>1</var>-st through the <var>3</var>-rd characters is aka.

The string formed by the <var>5</var>-th through the <var>7</var>-th characters is aka.
All of these are palindromes, so <var>S</var> is a strong palindrome.

Sample Input 2

level

Sample Output 2

No

Sample Input 3

atcoder

Sample Output 3

No


Score: <var>100</var> points

Problem Statement

In AtCoder city, there are five antennas standing in a straight line. They are called Antenna <var>A, B, C, D</var> and <var>E</var> from west to east, and their coordinates are <var>a, b, c, d</var> and <var>e</var>, respectively.

Two antennas can communicate directly if the distance between them is <var>k</var> or less, and they cannot if the distance is greater than <var>k</var>.

Determine if there exists a pair of antennas that cannot communicate directly.

Here, assume that the distance between two antennas at coordinates <var>p</var> and <var>q</var> (<var>p < q</var>) is <var>q - p</var>.

Constraints

<var>a, b, c, d, e</var> and <var>k</var> are integers between <var>0</var> and <var>123</var> (inclusive).

<var>a < b < c < d < e</var>

Input

Input is given from Standard Input in the following format:

<var>a</var>
<var>b</var>
<var>c</var>
<var>d</var>
<var>e</var>
<var>k</var>

Output

Print :( if there exists a pair of antennas that cannot communicate directly, and print Yay! if there is no such pair.

Sample Input 1

1
2
4
8
9
15

Sample Output 1

Yay!

In this case, there is no pair of antennas that cannot communicate directly, because:

the distance between <var>A</var> and <var>B</var> is <var>2 - 1</var> = <var>1</var>

the distance between <var>A</var> and <var>C</var> is <var>4 - 1</var> = <var>3</var>

the distance between <var>A</var> and <var>D</var> is <var>8 - 1</var> = <var>7</var>

the distance between <var>A</var> and <var>E</var> is <var>9 - 1</var> = <var>8</var>

the distance between <var>B</var> and <var>C</var> is <var>4 - 2</var> = <var>2</var>

the distance between <var>B</var> and <var>D</var> is <var>8 - 2</var> = <var>6</var>

the distance between <var>B</var> and <var>E</var> is <var>9 - 2</var> = <var>7</var>

the distance between <var>C</var> and <var>D</var> is <var>8 - 4</var> = <var>4</var>

the distance between <var>C</var> and <var>E</var> is <var>9 - 4</var> = <var>5</var>

the distance between <var>D</var> and <var>E</var> is <var>9 - 8</var> = <var>1</var>

and none of them is greater than <var>15</var>. Thus, the correct output is Yay!.

Sample Input 2

15
18
26
35
36
18

Sample Output 2

:(

In this case, the distance between antennas <var>A</var> and <var>D</var> is <var>35 - 15</var> = <var>20</var> and exceeds <var>18</var>, so they cannot communicate directly.
Thus, the correct output is :(.


Score : <var>100</var> points

Problem Statement

We have two integers: <var>A</var> and <var>B</var>.

Print the largest number among <var>A + B</var>, <var>A - B</var>, and <var>A \times B</var>.

Constraints

All values in input are integers.

<var>-100 \leq A,\ B \leq 100</var>

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var>

Output

Print the largest number among <var>A + B</var>, <var>A - B</var>, and <var>A \times B</var>.

Sample Input 1

-13 3

Sample Output 1

-10

The largest number among <var>A + B = -10</var>, <var>A - B = -16</var>, and <var>A \times B = -39</var> is <var>-10</var>.

Sample Input 2

1 -33

Sample Output 2

34

The largest number among <var>A + B = -32</var>, <var>A - B = 34</var>, and <var>A \times B = -33</var> is <var>34</var>.

Sample Input 3

13 3

Sample Output 3

39

The largest number among <var>A + B = 16</var>, <var>A - B = 10</var>, and <var>A \times B = 39</var> is <var>39</var>.


Score : <var>400</var> points

Problem Statement

Given is an integer <var>S</var>.
Find how many sequences there are whose terms are all integers greater than or equal to <var>3</var>, and whose sum is equal to <var>S</var>.
The answer can be very large, so output it modulo <var>10^9 + 7</var>.

Constraints

<var>1 \leq S \leq 2000</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the answer.

Sample Input 1

7

Sample Output 1

3

<var>3</var> sequences satisfy the condition: <var>\{3,4\}</var>, <var>\{4,3\}</var> and <var>\{7\}</var>.

Sample Input 2

2

Sample Output 2

0

There are no sequences that satisfy the condition.

Sample Input 3

1729

Sample Output 3

294867501


Score : <var>200</var> points

Problem Statement

Alice, Bob and Charlie are playing Card Game for Three, as below:

At first, each of the three players has a deck consisting of some number of cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks cannot be rearranged.

The players take turns. Alice goes first.

If the current player's deck contains at least one card, discard the top card in the deck. Then, the player whose name begins with the letter on the discarded card, takes the next turn. (For example, if the card says a, Alice takes the next turn.)

If the current player's deck is empty, the game ends and the current player wins the game.

You are given the initial decks of the players.
More specifically, you are given three strings <var>S_A</var>, <var>S_B</var> and <var>S_C</var>. The <var>i</var>-th <var>(1≦i≦|S_A|)</var> letter in <var>S_A</var> is the letter on the <var>i</var>-th card in Alice's initial deck. <var>S_B</var> and <var>S_C</var> describes Bob's and Charlie's initial decks in the same way.

Determine the winner of the game.

Constraints

<var>1≦|S_A|≦100</var>

<var>1≦|S_B|≦100</var>

<var>1≦|S_C|≦100</var>

Each letter in <var>S_A</var>, <var>S_B</var>, <var>S_C</var> is a, b or c.

Input

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

<var>S_A</var>
<var>S_B</var>
<var>S_C</var>

Output

If Alice will win, print A. If Bob will win, print B. If Charlie will win, print C.

Sample Input 1

aca
accc
ca

Sample Output 1

A

The game will progress as below:

Alice discards the top card in her deck, a. Alice takes the next turn.

Alice discards the top card in her deck, c. Charlie takes the next turn.

Charlie discards the top card in his deck, c. Charlie takes the next turn.

Charlie discards the top card in his deck, a. Alice takes the next turn.

Alice discards the top card in her deck, a. Alice takes the next turn.

Alice's deck is empty. The game ends and Alice wins the game.

Sample Input 2

abcb
aacb
bccc

Sample Output 2

C


Score : <var>200</var> points

Problem Statement

La Confiserie d'ABC sells cakes at <var>4</var> dollars each and doughnuts at <var>7</var> dollars each.
Determine if there is a way to buy some of them for exactly <var>N</var> dollars. You can buy two or more doughnuts and two or more cakes, and you can also choose to buy zero doughnuts or zero cakes.

Constraints

<var>N</var> is an integer between <var>1</var> and <var>100</var>, inclusive.

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

If there is a way to buy some cakes and some doughnuts for exactly <var>N</var> dollars, print Yes; otherwise, print No.

Sample Input 1

11

Sample Output 1

Yes

If you buy one cake and one doughnut, the total will be <var>4 + 7 = 11</var> dollars.

Sample Input 2

40

Sample Output 2

Yes

If you buy ten cakes, the total will be <var>4 \times 10 = 40</var> dollars.

Sample Input 3

3

Sample Output 3

No

The prices of cakes (<var>4</var> dollars) and doughnuts (<var>7</var> dollars) are both higher than <var>3</var> dollars, so there is no such way.


Score : <var>100</var> points

Problem Statement

Takahashi is a member of a programming competition site, ButCoder.

Each member of ButCoder is assigned two values: Inner Rating and Displayed Rating.

The Displayed Rating of a member is equal to their Inner Rating if the member has participated in <var>10</var> or more contests. Otherwise, the Displayed Rating will be their Inner Rating minus <var>100 \times (10 - K)</var> when the member has participated in <var>K</var> contests.

Takahashi has participated in <var>N</var> contests, and his Displayed Rating is <var>R</var>. Find his Inner Rating.

Constraints

All values in input are integers.

<var>1 \leq N \leq 100</var>

<var>0 \leq R \leq 4111</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>R</var>

Output

Print his Inner Rating.

Sample Input 1

2 2919

Sample Output 1

3719

Takahashi has participated in <var>2</var> contests, which is less than <var>10</var>, so his Displayed Rating is his Inner Rating minus <var>100 \times (10 - 2) = 800</var>.

Thus, Takahashi's Inner Rating is <var>2919 + 800 = 3719</var>.

Sample Input 2

22 3051

Sample Output 2

3051


Score : <var>100</var> points

Problem Statement

Given is a string <var>S</var> representing the day of the week today.

<var>S</var> is SUN, MON, TUE, WED, THU, FRI, or SAT, for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday, respectively.

After how many days is the next Sunday (tomorrow or later)?

Constraints

<var>S</var> is SUN, MON, TUE, WED, THU, FRI, or SAT.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the number of days before the next Sunday.

Sample Input 1

SAT

Sample Output 1

1

It is Saturday today, and tomorrow will be Sunday.

Sample Input 2

SUN

Sample Output 2

7

It is Sunday today, and seven days later, it will be Sunday again.


Score : <var>100</var> points

Problem Statement

Snuke is giving cookies to his three goats.

He has two cookie tins. One contains <var>A</var> cookies, and the other contains <var>B</var> cookies. He can thus give <var>A</var> cookies, <var>B</var> cookies or <var>A+B</var> 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

<var>1 \leq A,B \leq 100</var>

Both <var>A</var> and <var>B</var> are integers.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var>

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 1

4 5

Sample Output 1

Possible

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

Sample Input 2

1 1

Sample Output 2

Impossible

Since there are only two cookies, the three goats cannot have the same number of cookies no matter what Snuke gives to them.


Score : <var>100</var> points

Problem Statement

As a New Year's gift, Dolphin received a string <var>s</var> of length <var>19</var>.

The string <var>s</var> has the following format: [five lowercase English letters],[seven lowercase English letters],[five lowercase English letters].

Dolphin wants to convert the comma-separated string <var>s</var> into a space-separated string.

Write a program to perform the conversion for him.

Constraints

The length of <var>s</var> is <var>19</var>.

The sixth and fourteenth characters in <var>s</var> are ,.

The other characters in <var>s</var> are lowercase English letters.

Input

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

<var>s</var>

Output

Print the string after the conversion.

Sample Input 1

happy,newyear,enjoy

Sample Output 1

happy newyear enjoy

Replace all the commas in happy,newyear,enjoy with spaces to obtain happy newyear enjoy.

Sample Input 2

haiku,atcoder,tasks

Sample Output 2

haiku atcoder tasks

Sample Input 3

abcde,fghihgf,edcba

Sample Output 3

abcde fghihgf edcba


Score : <var>100</var> points

Problem Statement

Two students of AtCoder Kindergarten are fighting over candy packs.

There are three candy packs, each of which contains <var>a</var>, <var>b</var>, and <var>c</var> candies, respectively.

Teacher Evi is trying to distribute the packs between the two students so that each student gets the same number of candies. Determine whether it is possible.

Note that Evi cannot take candies out of the packs, and the whole contents of each pack must be given to one of the students.

Constraints

<var>1 ≦ a, b, c ≦ 100</var>

Input

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

<var>a</var> <var>b</var> <var>c</var>

Output

If it is possible to distribute the packs so that each student gets the same number of candies, print Yes. Otherwise, print No.

Sample Input 1

10 30 20

Sample Output 1

Yes

Give the pack with <var>30</var> candies to one student, and give the two packs with <var>10</var> and <var>20</var> candies to the other. Then, each gets <var>30</var> candies.

Sample Input 2

30 30 100

Sample Output 2

No

In this case, the student who gets the pack with <var>100</var> candies always has more candies than the other.

Note that every pack must be given to one of them.

Sample Input 3

56 25 31

Sample Output 3

Yes


Score : <var>200</var> points

Problem Statement

Iroha has a sequence of <var>N</var> strings <var>S_1, S_2, ..., S_N</var>. The length of each string is <var>L</var>.

She will concatenate all of the strings in some order, to produce a long string.

Among all strings that she can produce in this way, find the lexicographically smallest one.

Here, a string <var>s=s_1s_2s_3</var>...<var>s_n</var> is lexicographically smaller than another string <var>t=t_1t_2t_3</var>...<var>t_m</var> if and only if one of the following holds:

There exists an index <var>i(1≦i≦min(n,m))</var>, such that <var>s_j = t_j</var> for all indices <var>j(1≦j<i)</var>, and <var>s_i<t_i</var>.

<var>s_i = t_i</var> for all integers <var>i(1≦i≦min(n,m))</var>, and <var>n<m</var>.

Constraints

<var>1 ≦ N, L ≦ 100</var>

For each <var>i</var>, the length of <var>S_i</var> equals <var>L</var>.

For each <var>i</var>, <var>S_i</var> consists of lowercase letters.

Input

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

<var>N</var> <var>L</var>
<var>S_1</var>
<var>S_2</var>
:
<var>S_N</var>

Output

Print the lexicographically smallest string that Iroha can produce.

Sample Input 1

3 3
dxx
axx
cxx

Sample Output 1

axxcxxdxx

The following order should be used: axx, cxx, dxx.


Score : <var>500</var> points

Problem Statement

We have <var>N</var> logs of lengths <var>A_1,A_2,\cdots A_N</var>.

We can cut these logs at most <var>K</var> times in total. When a log of length <var>L</var> is cut at a point whose distance from an end of the log is <var>t</var> <var>(0<t<L)</var>, it becomes two logs of lengths <var>t</var> and <var>L-t</var>.

Find the shortest possible length of the longest log after at most <var>K</var> cuts, and print it after rounding up to an integer.

Constraints

<var>1 \leq N \leq 2 \times 10^5</var>

<var>0 \leq K \leq 10^9</var>

<var>1 \leq A_i \leq 10^9</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>K</var>
<var>A_1</var> <var>A_2</var> <var>\cdots</var> <var>A_N</var>

Output

Print an integer representing the answer.

Sample Input 1

2 3
7 9

Sample Output 1

4

First, we will cut the log of length <var>7</var> at a point whose distance from an end of the log is <var>3.5</var>, resulting in two logs of length <var>3.5</var> each.

Next, we will cut the log of length <var>9</var> at a point whose distance from an end of the log is <var>3</var>, resulting in two logs of length <var>3</var> and <var>6</var>.

Lastly, we will cut the log of length <var>6</var> at a point whose distance from an end of the log is <var>3.3</var>, resulting in two logs of length <var>3.3</var> and <var>2.7</var>.

In this case, the longest length of a log will be <var>3.5</var>, which is the shortest possible result. After rounding up to an integer, the output should be <var>4</var>.

Sample Input 2

3 0
3 4 5

Sample Output 2

5

Sample Input 3

10 10
158260522 877914575 602436426 24979445 861648772 623690081 433933447 476190629 262703497 211047202

Sample Output 3

292638192


Score : <var>300</var> points

Problem Statement

Given are an integer <var>X</var> and an integer sequence of length <var>N</var>: <var>p_1, \ldots, p_N</var>.

Among the integers not contained in the sequence <var>p_1, \ldots, p_N</var> (not necessarily positive), find the integer nearest to <var>X</var>, that is, find the integer whose absolute difference with <var>X</var> is the minimum. If there are multiple such integers, report the smallest such integer.

Constraints

<var>1 \leq X \leq 100</var>

<var>0 \leq N \leq 100</var>

<var>1 \leq p_i \leq 100</var>

<var>p_1, \ldots, p_N</var> are all distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>X</var> <var>N</var>
<var>p_1</var> <var>...</var> <var>p_N</var>

Output

Print the answer.

Sample Input 1

6 5
4 7 10 6 5

Sample Output 1

8

Among the integers not contained in the sequence <var>4, 7, 10, 6, 5</var>, the one nearest to <var>6</var> is <var>8</var>.

Sample Input 2

10 5
4 7 10 6 5

Sample Output 2

9

Among the integers not contained in the sequence <var>4, 7, 10, 6, 5</var>, the ones nearest to <var>10</var> are <var>9</var> and <var>11</var>. We should print the smaller one, <var>9</var>.

Sample Input 3

100 0

Sample Output 3

100

When <var>N = 0</var>, the second line in the input will be empty. Also, as seen here, <var>X</var> itself can be the answer.


Score : <var>100</var> points

Problem Statement

You are given three strings <var>A</var>, <var>B</var> and <var>C</var>. Check whether they form a word chain.

More formally, determine whether both of the following are true:

The last character in <var>A</var> and the initial character in <var>B</var> are the same.

The last character in <var>B</var> and the initial character in <var>C</var> are the same.

If both are true, print YES. Otherwise, print NO.

Constraints

<var>A</var>, <var>B</var> and <var>C</var> are all composed of lowercase English letters (a - z).

<var>1 ≤ |A|, |B|, |C| ≤ 10</var>, where <var>|A|</var>, <var>|B|</var> and <var>|C|</var> are the lengths of <var>A</var>, <var>B</var> and <var>C</var>, respectively.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>C</var>

Output

Print YES or NO.

Sample Input 1

rng gorilla apple

Sample Output 1

YES

They form a word chain.

Sample Input 2

yakiniku unagi sushi

Sample Output 2

NO

<var>A</var> and <var>B</var> form a word chain, but <var>B</var> and <var>C</var> do not.

Sample Input 3

a a a

Sample Output 3

YES

Sample Input 4

aaaaaaaaab aaaaaaaaaa aaaaaaaaab

Sample Output 4

NO


Score : <var>300</var> points

Problem Statement

We have <var>N</var> ID cards, and there are <var>M</var> gates.

We can pass the <var>i</var>-th gate if we have one of the following ID cards: the <var>L_i</var>-th, <var>(L_i+1)</var>-th, ..., and <var>R_i</var>-th ID cards.

How many of the ID cards allow us to pass all the gates alone?

Constraints

All values in input are integers.

<var>1 \leq N \leq 10^5</var>

<var>1 \leq M \leq 10^5</var>

<var>1 \leq L_i \leq R_i \leq N</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>L_1</var> <var>R_1</var>
<var>L_2</var> <var>R_2</var>
<var>\vdots</var>
<var>L_M</var> <var>R_M</var>

Output

Print the number of ID cards that allow us to pass all the gates alone.

Sample Input 1

4 2
1 3
2 4

Sample Output 1

2

Two ID cards allow us to pass all the gates alone, as follows:

The first ID card does not allow us to pass the second gate.

The second ID card allows us to pass all the gates.

The third ID card allows us to pass all the gates.

The fourth ID card does not allow us to pass the first gate.

Sample Input 2

10 3
3 6
5 7
6 9

Sample Output 2

1

Sample Input 3

100000 1
1 100000

Sample Output 3

100000


Score : <var>100</var> points

Problem Statement

Given are two strings <var>S</var> and <var>T</var> consisting of lowercase English letters. Concatenate <var>T</var> and <var>S</var> in this order, without space in between, and print the resulting string.

Constraints

<var>S</var> and <var>T</var> are strings consisting of lowercase English letters.

The lengths of <var>S</var> and <var>T</var> are between <var>1</var> and <var>100</var> (inclusive).

Input

Input is given from Standard Input in the following format:

<var>S</var> <var>T</var>

Output

Print the resulting string.

Sample Input 1

oder atc

Sample Output 1

atcoder

When <var>S = </var> oder and <var>T = </var> atc, concatenating <var>T</var> and <var>S</var> in this order results in atcoder.

Sample Input 2

humu humu

Sample Output 2

humuhumu


Score: <var>200</var> points

Problem Statement

We have <var>N</var> cards. A number <var>a_i</var> is written on the <var>i</var>-th card.

Alice and Bob will play a game using these cards. In this game, Alice and Bob alternately take one card. Alice goes first.

The game ends when all the cards are taken by the two players, and the score of each player is the sum of the numbers written on the cards he/she has taken. When both players take the optimal strategy to maximize their scores, find Alice's score minus Bob's score.

Constraints

<var>N</var> is an integer between <var>1</var> and <var>100</var> (inclusive).

<var>a_i \ (1 \leq i \leq N)</var> is an integer between <var>1</var> and <var>100</var> (inclusive).

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>a_1</var> <var>a_2</var> <var>a_3</var> <var>...</var> <var>a_N</var>

Output

Print Alice's score minus Bob's score when both players take the optimal strategy to maximize their scores.

Sample Input 1

2
3 1

Sample Output 1

2

First, Alice will take the card with <var>3</var>. Then, Bob will take the card with <var>1</var>.
The difference of their scores will be <var>3</var> - <var>1</var> = <var>2</var>.

Sample Input 2

3
2 7 4

Sample Output 2

5

First, Alice will take the card with <var>7</var>. Then, Bob will take the card with <var>4</var>. Lastly, Alice will take the card with <var>2</var>. The difference of their scores will be <var>7</var> - <var>4</var> + <var>2</var> = <var>5</var>. The difference of their scores will be <var>3</var> - <var>1</var> = <var>2</var>.

Sample Input 3

4
20 18 2 18

Sample Output 3

18


Score : <var>200</var> points

Problem Statement

Takahashi wants to gain muscle, and decides to work out at AtCoder Gym.

The exercise machine at the gym has <var>N</var> buttons, and exactly one of the buttons is lighten up.
These buttons are numbered <var>1</var> through <var>N</var>.
When Button <var>i</var> is lighten up and you press it, the light is turned off, and then Button <var>a_i</var> will be lighten up. It is possible that <var>i=a_i</var>.
When Button <var>i</var> is not lighten up, nothing will happen by pressing it.

Initially, Button <var>1</var> is lighten up. Takahashi wants to quit pressing buttons when Button <var>2</var> is lighten up.

Determine whether this is possible. If the answer is positive, find the minimum number of times he needs to press buttons.

Constraints

<var>2 ≤ N ≤ 10^5</var>

<var>1 ≤ a_i ≤ N</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>a_1</var>
<var>a_2</var>
:
<var>a_N</var>

Output

Print <var>-1</var> if it is impossible to lighten up Button <var>2</var>.
Otherwise, print the minimum number of times we need to press buttons in order to lighten up Button <var>2</var>.

Sample Input 1

3
3
1
2

Sample Output 1

2

Press Button <var>1</var>, then Button <var>3</var>.

Sample Input 2

4
3
4
1
2

Sample Output 2

-1

Pressing Button <var>1</var> lightens up Button <var>3</var>, and vice versa, so Button <var>2</var> will never be lighten up.

Sample Input 3

5
3
3
4
2
4

Sample Output 3

3


Score : <var>200</var> points

Problem Statement

We have a grid with <var>N</var> rows and <var>M</var> columns of squares. Initially, all the squares are white.

There is a button attached to each row and each column.
When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.
When a button attached to a column is pressed, the colors of all the squares in that column are inverted.

Takahashi can freely press the buttons any number of times. Determine whether he can have exactly <var>K</var> black squares in the grid.

Constraints

<var>1 \leq N,M \leq 1000</var>

<var>0 \leq K \leq NM</var>

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var> <var>K</var>

Output

If Takahashi can have exactly <var>K</var> black squares in the grid, print Yes; otherwise, print No.

Sample Input 1

2 2 2

Sample Output 1

Yes

Press the buttons in the order of the first row, the first column.

Sample Input 2

2 2 1

Sample Output 2

No

Sample Input 3

3 5 8

Sample Output 3

Yes

Press the buttons in the order of the first column, third column, second row, fifth column.

Sample Input 4

7 9 20

Sample Output 4

No


Score : <var>200</var> points

Problem Statement

An <var>X</var>-layered kagami mochi <var>(X ≥ 1)</var> is a pile of <var>X</var> round mochi (rice cake) stacked vertically where each mochi (except the bottom one) has a smaller diameter than that of the mochi directly below it. For example, if you stack three mochi with diameters of <var>10</var>, <var>8</var> and <var>6</var> centimeters from bottom to top in this order, you have a <var>3</var>-layered kagami mochi; if you put just one mochi, you have a <var>1</var>-layered kagami mochi.

Lunlun the dachshund has <var>N</var> round mochi, and the diameter of the <var>i</var>-th mochi is <var>d_i</var> centimeters. When we make a kagami mochi using some or all of them, at most how many layers can our kagami mochi have?

Constraints

<var>1 ≤ N ≤ 100</var>

<var>1 ≤ d_i ≤ 100</var>

All input values are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>d_1</var>
<var>:</var>
<var>d_N</var>

Output

Print the maximum number of layers in a kagami mochi that can be made.

Sample Input 1

4
10
8
8
6

Sample Output 1

3

If we stack the mochi with diameters of <var>10</var>, <var>8</var> and <var>6</var> centimeters from bottom to top in this order, we have a <var>3</var>-layered kagami mochi, which is the maximum number of layers.

Sample Input 2

3
15
15
15

Sample Output 2

1

When all the mochi have the same diameter, we can only have a <var>1</var>-layered kagami mochi.

Sample Input 3

7
50
30
50
100
50
80
30

Sample Output 3

4


Score: <var>200</var> points

Problem Statement

M-kun has the following three cards:

A red card with the integer <var>A</var>.

A green card with the integer <var>B</var>.

A blue card with the integer <var>C</var>.

He is a genius magician who can do the following operation at most <var>K</var> times:

Choose one of the three cards and multiply the written integer by <var>2</var>.

His magic is successful if both of the following conditions are satisfied after the operations:

The integer on the green card is strictly greater than the integer on the red card.

The integer on the blue card is strictly greater than the integer on the green card.

Determine whether the magic can be successful.

Constraints

<var>1 \leq A, B, C \leq 7</var>

<var>1 \leq K \leq 7</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>A</var> <var>B</var> <var>C</var>
<var>K</var>

Output

If the magic can be successful, print Yes; otherwise, print No.

Sample Input 1

7 2 5
3

Sample Output 1

Yes

The magic will be successful if, for example, he does the following operations:

First, choose the blue card. The integers on the red, green, and blue cards are now <var>7</var>, <var>2</var>, and <var>10</var>, respectively.

Second, choose the green card. The integers on the red, green, and blue cards are now <var>7</var>, <var>4</var>, and <var>10</var>, respectively.

Third, choose the green card. The integers on the red, green, and blue cards are now <var>7</var>, <var>8</var>, and <var>10</var>, respectively.

Sample Input 2

7 4 2
3

Sample Output 2

No

He has no way to succeed in the magic with at most three operations.


Score : <var>200</var> points

Problem Statement

There are <var>N</var> points in a <var>D</var>-dimensional space.

The coordinates of the <var>i</var>-th point are <var>(X_{i1}, X_{i2}, ..., X_{iD})</var>.

The distance between two points with coordinates <var>(y_1, y_2, ..., y_D)</var> and <var>(z_1, z_2, ..., z_D)</var> is <var>\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}</var>.

How many pairs <var>(i, j)</var> <var>(i < j)</var> are there such that the distance between the <var>i</var>-th point and the <var>j</var>-th point is an integer?

Constraints

All values in input are integers.

<var>2 \leq N \leq 10</var>

<var>1 \leq D \leq 10</var>

<var>-20 \leq X_{ij} \leq 20</var>

No two given points have the same coordinates. That is, if <var>i \neq j</var>, there exists <var>k</var> such that <var>X_{ik} \neq X_{jk}</var>.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>D</var>
<var>X_{11}</var> <var>X_{12}</var> <var>...</var> <var>X_{1D}</var>
<var>X_{21}</var> <var>X_{22}</var> <var>...</var> <var>X_{2D}</var>
<var>\vdots</var>
<var>X_{N1}</var> <var>X_{N2}</var> <var>...</var> <var>X_{ND}</var>

Output

Print the number of pairs <var>(i, j)</var> <var>(i < j)</var> such that the distance between the <var>i</var>-th point and the <var>j</var>-th point is an integer.

Sample Input 1

3 2
1 2
5 5
-2 8

Sample Output 1

1

The number of pairs with an integer distance is one, as follows:

The distance between the first point and the second point is <var>\sqrt{|1-5|^2 + |2-5|^2} = 5</var>, which is an integer.

The distance between the second point and the third point is <var>\sqrt{|5-(-2)|^2 + |5-8|^2} = \sqrt{58}</var>, which is not an integer.

The distance between the third point and the first point is <var>\sqrt{|-2-1|^2+|8-2|^2} = 3\sqrt{5}</var>, which is not an integer.

Sample Input 2

3 4
-3 7 8 2
-12 1 10 2
-2 8 9 3

Sample Output 2

2

Sample Input 3

5 1
1
2
3
4
5

Sample Output 3

10


Score : <var>100</var> points

Problem Statement

We have a sandglass that runs for <var>X</var> seconds. The sand drops from the upper bulb at a rate of <var>1</var> gram per second. That is, the upper bulb initially contains <var>X</var> grams of sand.

How many grams of sand will the upper bulb contains after <var>t</var> seconds?

Constraints

<var>1≤X≤10^9</var>

<var>1≤t≤10^9</var>

<var>X</var> and <var>t</var> are integers.

Input

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

<var>X</var> <var>t</var>

Output

Print the number of sand in the upper bulb after <var>t</var> second.

Sample Input 1

100 17

Sample Output 1

83

<var>17</var> out of the initial <var>100</var> grams of sand will be consumed, resulting in <var>83</var> grams.

Sample Input 2

48 58

Sample Output 2

0

All <var>48</var> grams of sand will be gone, resulting in <var>0</var> grams.

Sample Input 3

1000000000 1000000000

Sample Output 3

0


Score : <var>100</var> points

Problem Statement

We conducted a survey on newspaper subscriptions.
More specifically, we asked each of the <var>N</var> respondents the following two questions:

Question <var>1</var>: Are you subscribing to Newspaper X?

Question <var>2</var>: Are you subscribing to Newspaper Y?

As the result, <var>A</var> respondents answered "yes" to Question <var>1</var>, and <var>B</var> respondents answered "yes" to Question <var>2</var>.

What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y?

Write a program to answer this question.

Constraints

<var>1 \leq N \leq 100</var>

<var>0 \leq A \leq N</var>

<var>0 \leq B \leq N</var>

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>A</var> <var>B</var>

Output

Print the maximum possible number and the minimum possible number of respondents subscribing to both newspapers, in this order, with a space in between.

Sample Input 1

10 3 5

Sample Output 1

3 0

In this sample, out of the <var>10</var> respondents, <var>3</var> answered they are subscribing to Newspaper X, and <var>5</var> answered they are subscribing to Newspaper Y.

Here, the number of respondents subscribing to both newspapers is at most <var>3</var> and at least <var>0</var>.

Sample Input 2

10 7 5

Sample Output 2

5 2

In this sample, out of the <var>10</var> respondents, <var>7</var> answered they are subscribing to Newspaper X, and <var>5</var> answered they are subscribing to Newspaper Y.

Here, the number of respondents subscribing to both newspapers is at most <var>5</var> and at least <var>2</var>.

Sample Input 3

100 100 100

Sample Output 3

100 100


Score : <var>300</var> points

Problem Statement

There are <var>N</var> people. The name of the <var>i</var>-th person is <var>S_i</var>.

We would like to choose three people so that the following conditions are met:

The name of every chosen person begins with M, A, R, C or H.

There are no multiple people whose names begin with the same letter.

How many such ways are there to choose three people, disregarding order?

Note that the answer may not fit into a <var>32</var>-bit integer type.

Constraints

<var>1 \leq N \leq 10^5</var>

<var>S_i</var> consists of uppercase English letters.

<var>1 \leq |S_i| \leq 10</var>

<var>S_i \neq S_j (i \neq j)</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>S_1</var>
<var>:</var>
<var>S_N</var>

Output

If there are <var>x</var> ways to choose three people so that the given conditions are met, print <var>x</var>.

Sample Input 1

5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI

Sample Output 1

2

We can choose three people with the following names:

MASHIKE, RUMOI, HABORO

MASHIKE, RUMOI, HOROKANAI

Thus, we have two ways.

Sample Input 2

4
ZZ
ZZZ
Z
ZZZZZZZZZZ

Sample Output 2

0

Note that there may be no ways to choose three people so that the given conditions are met.

Sample Input 3

5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO

Sample Output 3

7