Score : <var>200</var> points

Problem Statement

We have <var>A</var> cards, each of which has an integer <var>1</var> written on it. Similarly, we also have <var>B</var> cards with <var>0</var>s and <var>C</var> cards with <var>-1</var>s.

We will pick up <var>K</var> among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Constraints

All values in input are integers.

<var>0 \leq A, B, C</var>

<var>1 \leq K \leq A + B + C \leq 2 \times 10^9</var>

Input

Input is given from Standard Input in the following format:

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

Output

Print the maximum possible sum of the numbers written on the cards chosen.

Sample Input 1

2 1 1 3

Sample Output 1

2

Consider picking up two cards with <var>1</var>s and one card with a <var>0</var>.
In this case, the sum of the numbers written on the cards is <var>2</var>, which is the maximum possible value.

Sample Input 2

1 2 3 4

Sample Output 2

0

Sample Input 3

2000000000 0 0 2000000000

Sample Output 3

2000000000


Score: <var>300</var> points

Problem Statement

We have <var>N</var> voting papers. The <var>i</var>-th vote <var>(1 \leq i \leq N)</var> has the string <var>S_i</var> written on it.

Print all strings that are written on the most number of votes, in lexicographical order.

Constraints

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

<var>S_i</var> <var>(1 \leq i \leq N)</var> are strings consisting of lowercase English letters.

The length of <var>S_i</var> <var>(1 \leq i \leq N)</var> is 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 all strings in question in lexicographical order.

Sample Input 1

7
beat
vet
beet
bed
vet
bet
beet

Sample Output 1

beet
vet

beet and vet are written on two sheets each, while beat, bed, and bet are written on one vote each. Thus, we should print the strings beet and vet.

Sample Input 2

8
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo
buffalo

Sample Output 2

buffalo

Sample Input 3

7
bass
bass
kick
kick
bass
kick
kick

Sample Output 3

kick

Sample Input 4

4
ushi
tapu
nichia
kun

Sample Output 4

kun
nichia
tapu
ushi


Score : <var>400</var> points

Problem Statement

A maze is composed of a grid of <var>H \times W</var> squares - <var>H</var> vertical, <var>W</var> horizontal.

The square at the <var>i</var>-th row from the top and the <var>j</var>-th column from the left - <var>(i,j)</var> - is a wall if <var>S_{ij}</var> is # and a road if <var>S_{ij}</var> is ..

There is a magician in <var>(C_h,C_w)</var>. He can do the following two kinds of moves:

Move A: Walk to a road square that is vertically or horizontally adjacent to the square he is currently in.

Move B: Use magic to warp himself to a road square in the <var>5\times 5</var> area centered at the square he is currently in.

In either case, he cannot go out of the maze.

At least how many times does he need to use the magic to reach <var>(D_h, D_w)</var>?

Constraints

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

<var>1 \leq C_h,D_h \leq H</var>

<var>1 \leq C_w,D_w \leq W</var>

<var>S_{ij}</var> is # or ..

<var>S_{C_h C_w}</var> and <var>S_{D_h D_w}</var> are ..

<var>(C_h,C_w) \neq (D_h,D_w)</var>

Input

Input is given from Standard Input in the following format:

<var>H</var> <var>W</var>
<var>C_h</var> <var>C_w</var>
<var>D_h</var> <var>D_w</var>
<var>S_{11}\ldots S_{1W}</var>
<var>\vdots</var>
<var>S_{H1}\ldots S_{HW}</var>

Output

Print the minimum number of times the magician needs to use the magic. If he cannot reach <var>(D_h,D_w)</var>, print -1 instead.

Sample Input 1

4 4
1 1
4 4
..#.
..#.
.#..
.#..

Sample Output 1

1

For example, by walking to <var>(2,2)</var> and then using the magic to travel to <var>(4,4)</var>, just one use of magic is enough.

Note that he cannot walk diagonally.

Sample Input 2

4 4
1 4
4 1
.##.
####
####
.##.

Sample Output 2

-1

He cannot move from there.

Sample Input 3

4 4
2 2
3 3
....
....
....
....

Sample Output 3

0

No use of magic is needed.

Sample Input 4

4 5
1 2
2 5
#.###
####.
#..##
#..##

Sample Output 4

2


Score : <var>100</var> points

Problem Statement

There is always an integer in Takahashi's mind.

Initially, the integer in Takahashi's mind is <var>0</var>. Takahashi is now going to eat four symbols, each of which is + or -. When he eats +, the integer in his mind increases by <var>1</var>; when he eats -, the integer in his mind decreases by <var>1</var>.

The symbols Takahashi is going to eat are given to you as a string <var>S</var>. The <var>i</var>-th character in <var>S</var> is the <var>i</var>-th symbol for him to eat.

Find the integer in Takahashi's mind after he eats all the symbols.

Constraints

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

Each character in <var>S</var> is + or -.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print the integer in Takahashi's mind after he eats all the symbols.

Sample Input 1

+-++

Sample Output 1

2

Initially, the integer in Takahashi's mind is <var>0</var>.

The first integer for him to eat is +. After eating it, the integer in his mind becomes <var>1</var>.

The second integer to eat is -. After eating it, the integer in his mind becomes <var>0</var>.

The third integer to eat is +. After eating it, the integer in his mind becomes <var>1</var>.

The fourth integer to eat is +. After eating it, the integer in his mind becomes <var>2</var>.

Thus, the integer in Takahashi's mind after he eats all the symbols is <var>2</var>.

Sample Input 2

-+--

Sample Output 2

-2

Sample Input 3

----

Sample Output 3

-4


Score : <var>200</var> points

Problem Statement

You are given strings <var>s</var> and <var>t</var>, consisting of lowercase English letters.
You will create a string <var>s'</var> by freely rearranging the characters in <var>s</var>.
You will also create a string <var>t'</var> by freely rearranging the characters in <var>t</var>.
Determine whether it is possible to satisfy <var>s' < t'</var> for the lexicographic order.

Notes

For a string <var>a = a_1 a_2 ... a_N</var> of length <var>N</var> and a string <var>b = b_1 b_2 ... b_M</var> of length <var>M</var>, we say <var>a < b</var> for the lexicographic order if either one of the following two conditions holds true:

<var>N < M</var> and <var>a_1 = b_1</var>, <var>a_2 = b_2</var>, ..., <var>a_N = b_N</var>.

There exists <var>i</var> (<var>1 \leq i \leq N, M</var>) such that <var>a_1 = b_1</var>, <var>a_2 = b_2</var>, ..., <var>a_{i - 1} = b_{i - 1}</var> and <var>a_i < b_i</var>. Here, letters are compared using alphabetical order.

For example, xy <var><</var> xya and atcoder <var><</var> atlas.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>s</var>
<var>t</var>

Output

If it is possible to satisfy <var>s' < t'</var>, print Yes; if it is not, print No.

Sample Input 1

yx
axy

Sample Output 1

Yes

We can, for example, rearrange yx into xy and axy into yxa. Then, xy <var><</var> yxa.

Sample Input 2

ratcode
atlas

Sample Output 2

Yes

We can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort <var><</var> tslaa.

Sample Input 3

cd
abc

Sample Output 3

No

No matter how we rearrange cd and abc, we cannot achieve our objective.

Sample Input 4

w
ww

Sample Output 4

Yes

Sample Input 5

zzz
zzz

Sample Output 5

No


Score : <var>400</var> points

Problem Statement

Snuke has <var>N</var> strings. The <var>i</var>-th string is <var>s_i</var>.

Let us concatenate these strings into one string after arranging them in some order.
Find the maximum possible number of occurrences of AB in the resulting string.

Constraints

<var>1 \leq N \leq 10^{4}</var>

<var>2 \leq |s_i| \leq 10</var>

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

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>s_1</var>
<var>\vdots</var>
<var>s_N</var>

Output

Print the answer.

Sample Input 1

3
ABCA
XBAZ
BAD

Sample Output 1

2

For example, if we concatenate ABCA, BAD and XBAZ in this order, the resulting string ABCABADXBAZ has two occurrences of AB.

Sample Input 2

9
BEWPVCRWH
ZZNQYIJX
BAVREA
PA
HJMYITEOX
BCJHMRMNK
BP
QVFABZ
PRGKSPUNA

Sample Output 2

4

Sample Input 3

7
RABYBBE
JOZ
BMHQUVA
BPA
ISU
MCMABAOBHZ
SZMEHMA

Sample Output 3

4


Score : <var>200</var> points

Problem Statement

A sequence <var>a=\{a_1,a_2,a_3,......\}</var> is determined as follows:

The first term <var>s</var> is given as input.

Let <var>f(n)</var> be the following function: <var>f(n) = n/2</var> if <var>n</var> is even, and <var>f(n) = 3n+1</var> if <var>n</var> is odd.

<var>a_i = s</var> when <var>i = 1</var>, and <var>a_i = f(a_{i-1})</var> when <var>i > 1</var>.

Find the minimum integer <var>m</var> that satisfies the following condition:

There exists an integer <var>n</var> such that <var>a_m = a_n (m > n)</var>.

Constraints

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

All values in input are integers.

It is guaranteed that all elements in <var>a</var> and the minimum <var>m</var> that satisfies the condition are at most <var>1000000</var>.

Input

Input is given from Standard Input in the following format:

<var>s</var>

Output

Print the minimum integer <var>m</var> that satisfies the condition.

Sample Input 1

8

Sample Output 1

5

<var>a=\{8,4,2,1,4,2,1,4,2,1,......\}</var>. As <var>a_5=a_2</var>, the answer is <var>5</var>.

Sample Input 2

7

Sample Output 2

18

<var>a=\{7,22,11,34,17,52,26,13,40,20,10,5,16,8,4,2,1,4,2,1,......\}</var>.

Sample Input 3

54

Sample Output 3

114


Score: <var>100</var> points

Problem Statement

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

Print the integer <var>K</var> such that <var>|A - K| = |B - K|</var>.

If such an integer does not exist, print IMPOSSIBLE instead.

Constraints

All values in input are integers.

<var>0 \leq A,\ B \leq 10^9</var>

<var>A</var> and <var>B</var> are distinct.

Input

Input is given from Standard Input in the following format:

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

Output

Print the integer <var>K</var> satisfying the condition.

If such an integer does not exist, print IMPOSSIBLE instead.

Sample Input 1

2 16

Sample Output 1

9

<var>|2 - 9| = 7</var> and <var>|16 - 9| = 7</var>, so <var>9</var> satisfies the condition.

Sample Input 2

0 3

Sample Output 2

IMPOSSIBLE

No integer satisfies the condition.

Sample Input 3

998244353 99824435

Sample Output 3

549034394


Score : <var>500</var> points

Problem Statement

We have <var>N</var> integers. The <var>i</var>-th number is <var>A_i</var>.

<var>\{A_i\}</var> is said to be pairwise coprime when <var>GCD(A_i,A_j)=1</var> holds for every pair <var>(i, j)</var> such that <var>1\leq i < j \leq N</var>.

<var>\{A_i\}</var> is said to be setwise coprime when <var>\{A_i\}</var> is not pairwise coprime but <var>GCD(A_1,\ldots,A_N)=1</var>.

Determine if <var>\{A_i\}</var> is pairwise coprime, setwise coprime, or neither.

Here, <var>GCD(\ldots)</var> denotes greatest common divisor.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

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

Output

If <var>\{A_i\}</var> is pairwise coprime, print pairwise coprime; if <var>\{A_i\}</var> is setwise coprime, print setwise coprime; if neither, print not coprime.

Sample Input 1

3
3 4 5

Sample Output 1

pairwise coprime

<var>GCD(3,4)=GCD(3,5)=GCD(4,5)=1</var>, so they are pairwise coprime.

Sample Input 2

3
6 10 15

Sample Output 2

setwise coprime

Since <var>GCD(6,10)=2</var>, they are not pairwise coprime. However, since <var>GCD(6,10,15)=1</var>, they are setwise coprime.

Sample Input 3

3
6 10 16

Sample Output 3

not coprime

<var>GCD(6,10,16)=2</var>, so they are neither pairwise coprime nor setwise coprime.


Score : <var>100</var> points

Problem Statement

An uppercase or lowercase English letter <var>\alpha</var> will be given as input.
If <var>\alpha</var> is uppercase, print A; if it is lowercase, print a.

Constraints

<var>\alpha</var> is an uppercase (A - Z) or lowercase (a - z) English letter.

Input

Input is given from Standard Input in the following format:

<var>α</var>

Output

If <var>\alpha</var> is uppercase, print A; if it is lowercase, print a.

Sample Input 1

B

Sample Output 1

A

B is uppercase, so we should print A.

Sample Input 2

a

Sample Output 2

a

a is lowercase, so we should print a.


Score : <var>200</var> points

Problem Statement

Given are a positive integer <var>N</var> and a string <var>S</var> of length <var>N</var> consisting of lowercase English letters.

Determine whether the string is a concatenation of two copies of some string.
That is, determine whether there is a string <var>T</var> such that <var>S = T + T</var>.

Constraints

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

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

<var>|S| = N</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>S</var>

Output

If <var>S</var> is a concatenation of two copies of some string, print Yes; otherwise, print No.

Sample Input 1

6
abcabc

Sample Output 1

Yes

Let <var>T = </var> abc, and <var>S = T + T</var>.

Sample Input 2

6
abcadc

Sample Output 2

No

Sample Input 3

1
z

Sample Output 3

No


Score : <var>100</var> points

Problem Statement

There is a hotel with the following accommodation fee:

<var>X</var> yen (the currency of Japan) per night, for the first <var>K</var> nights

<var>Y</var> yen per night, for the <var>(K+1)</var>-th and subsequent nights

Tak is staying at this hotel for <var>N</var> consecutive nights.
Find his total accommodation fee.

Constraints

<var>1 \leq N, K \leq 10000</var>

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

<var>N,\,K,\,X,\,Y</var> are integers.

Input

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

<var>N</var>
<var>K</var>
<var>X</var>
<var>Y</var>

Output

Print Tak's total accommodation fee.

Sample Input 1

5
3
10000
9000

Sample Output 1

48000

The accommodation fee is as follows:

<var>10000</var> yen for the <var>1</var>-st night

<var>10000</var> yen for the <var>2</var>-nd night

<var>10000</var> yen for the <var>3</var>-rd night

<var>9000</var> yen for the <var>4</var>-th night

<var>9000</var> yen for the <var>5</var>-th night

Thus, the total is <var>48000</var> yen.

Sample Input 2

2
3
10000
9000

Sample Output 2

20000


Score: <var>200</var> points

Problem Statement

There are three positive integers <var>A</var>, <var>B</var> and <var>C</var> written on a blackboard. E869120 performs the following operation <var>K</var> times:

Choose one integer written on the blackboard and let the chosen integer be <var>n</var>. Replace the chosen integer with <var>2n</var>.

What is the largest possible sum of the integers written on the blackboard after <var>K</var> operations?

Constraints

<var>A, B</var> and <var>C</var> are integers between <var>1</var> and <var>50</var> (inclusive).

<var>K</var> is an integer between <var>1</var> and <var>10</var> (inclusive).

Input

Input is given from Standard Input in the following format:

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

Output

Print the largest possible sum of the integers written on the blackboard after <var>K</var> operations by E869220.

Sample Input 1

5 3 11
1

Sample Output 1

30

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

There are three choices:

Double <var>5</var>: The integers written on the board after the operation are <var>10, 3, 11</var>.

Double <var>3</var>: The integers written on the board after the operation are <var>5, 6, 11</var>.

Double <var>11</var>: The integers written on the board after the operation are <var>5, 3, 22</var>.

If he chooses 3., the sum of the integers written on the board afterwards is <var>5 + 3 + 22 = 30</var>, which is the largest among 1. through 3.

Sample Input 2

3 3 4
2

Sample Output 2

22

E869120 can perform the operation twice. The sum of the integers eventually written on the blackboard is maximized as follows:

First, double <var>4</var>. The integers written on the board are now <var>3, 3, 8</var>.

Next, double <var>8</var>. The integers written on the board are now <var>3, 3, 16</var>.

Then, the sum of the integers eventually written on the blackboard is <var>3 + 3 + 16 = 22</var>.


Score: <var>200</var> points

Problem Statement

The number <var>105</var> is quite special - it is odd but still it has eight divisors.
Now, your task is this: how many odd numbers with exactly eight positive divisors are there between <var>1</var> and <var>N</var> (inclusive)?

Constraints

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

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

Print the count.

Sample Input 1

105

Sample Output 1

1

Among the numbers between <var>1</var> and <var>105</var>, the only number that is odd and has exactly eight divisors is <var>105</var>.

Sample Input 2

7

Sample Output 2

0

<var>1</var> has one divisor. <var>3</var>, <var>5</var> and <var>7</var> are all prime and have two divisors. Thus, there is no number that satisfies the condition.


Score : <var>200</var> points

Problem Statement

You are given two integers <var>K</var> and <var>S</var>.

Three variable <var>X, Y</var> and <var>Z</var> takes integer values satisfying <var>0≤X,Y,Z≤K</var>.

How many different assignments of values to <var>X, Y</var> and <var>Z</var> are there such that <var>X + Y + Z = S</var>?

Constraints

<var>2≤K≤2500</var>

<var>0≤S≤3K</var>

<var>K</var> and <var>S</var> are integers.

Input

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

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

Output

Print the number of the triples of <var>X, Y</var> and <var>Z</var> that satisfy the condition.

Sample Input 1

2 2

Sample Output 1

6

There are six triples of <var>X, Y</var> and <var>Z</var> that satisfy the condition:

<var>X = 0, Y = 0, Z = 2</var>

<var>X = 0, Y = 2, Z = 0</var>

<var>X = 2, Y = 0, Z = 0</var>

<var>X = 0, Y = 1, Z = 1</var>

<var>X = 1, Y = 0, Z = 1</var>

<var>X = 1, Y = 1, Z = 0</var>

Sample Input 2

5 15

Sample Output 2

1

The maximum value of <var>X + Y + Z</var> is <var>15</var>, achieved by one triple of <var>X, Y</var> and <var>Z</var>.


Score : <var>300</var> points

Problem Statement

We have <var>N</var> switches with "on" and "off" state, and <var>M</var> bulbs. The switches are numbered <var>1</var> to <var>N</var>, and the bulbs are numbered <var>1</var> to <var>M</var>.

Bulb <var>i</var> is connected to <var>k_i</var> switches: Switch <var>s_{i1}</var>, <var>s_{i2}</var>, <var>...</var>, and <var>s_{ik_i}</var>. It is lighted when the number of switches that are "on" among these switches is congruent to <var>p_i</var> modulo <var>2</var>.

How many combinations of "on" and "off" states of the switches light all the bulbs?

Constraints

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

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

<var>1 \leq s_{ij} \leq N</var>

<var>s_{ia} \neq s_{ib} (a \neq b)</var>

<var>p_i</var> is <var>0</var> or <var>1</var>.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>k_1</var> <var>s_{11}</var> <var>s_{12}</var> <var>...</var> <var>s_{1k_1}</var>
<var>:</var>
<var>k_M</var> <var>s_{M1}</var> <var>s_{M2}</var> <var>...</var> <var>s_{Mk_M}</var>
<var>p_1</var> <var>p_2</var> <var>...</var> <var>p_M</var>

Output

Print the number of combinations of "on" and "off" states of the switches that light all the bulbs.

Sample Input 1

2 2
2 1 2
1 2
0 1

Sample Output 1

1

Bulb <var>1</var> is lighted when there is an even number of switches that are "on" among the following: Switch <var>1</var> and <var>2</var>.

Bulb <var>2</var> is lighted when there is an odd number of switches that are "on" among the following: Switch <var>2</var>.

There are four possible combinations of states of (Switch <var>1</var>, Switch <var>2</var>): (on, on), (on, off), (off, on) and (off, off). Among them, only (on, on) lights all the bulbs, so we should print <var>1</var>.

Sample Input 2

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

Sample Output 2

0

Bulb <var>1</var> is lighted when there is an even number of switches that are "on" among the following: Switch <var>1</var> and <var>2</var>.

Bulb <var>2</var> is lighted when there is an even number of switches that are "on" among the following: Switch <var>1</var>.

Bulb <var>3</var> is lighted when there is an odd number of switches that are "on" among the following: Switch <var>2</var>.

Switch <var>1</var> has to be "off" to light Bulb <var>2</var> and Switch <var>2</var> has to be "on" to light Bulb <var>3</var>, but then Bulb <var>1</var> will not be lighted. Thus, there are no combinations of states of the switches that light all the bulbs, so we should print <var>0</var>.

Sample Input 3

5 2
3 1 2 5
2 2 3
1 0

Sample Output 3

8


Score : <var>100</var> points

Problem Statement

In programming, hexadecimal notation is often used.

In hexadecimal notation, besides the ten digits <var>0, 1, ..., 9</var>, the six letters A, B, C, D, E and F are used to represent the values <var>10, 11, 12, 13, 14</var> and <var>15</var>, respectively.

In this problem, you are given two letters <var>X</var> and <var>Y</var>. Each <var>X</var> and <var>Y</var> is A, B, C, D, E or F.

When <var>X</var> and <var>Y</var> are seen as hexadecimal numbers, which is larger?

Constraints

Each <var>X</var> and <var>Y</var> is A, B, C, D, E or F.

Input

Input is given from Standard Input in the following format:

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

Output

If <var>X</var> is smaller, print <; if <var>Y</var> is smaller, print >; if they are equal, print =.

Sample Input 1

A B

Sample Output 1

<

<var>10 < 11</var>.

Sample Input 2

E C

Sample Output 2

>

<var>14 > 12</var>.

Sample Input 3

F F

Sample Output 3

=

<var>15 = 15</var>.


Score : <var>100</var> points

Problem Statement

Snuke has a grid consisting of three squares numbered <var>1</var>, <var>2</var> and <var>3</var>.
In each square, either 0 or 1 is written. The number written in Square <var>i</var> is <var>s_i</var>.

Snuke will place a marble on each square that says 1.
Find the number of squares on which Snuke will place a marble.

Constraints

Each of <var>s_1</var>, <var>s_2</var> and <var>s_3</var> is either 1 or 0.

Input

Input is given from Standard Input in the following format:

<var>s_{1}s_{2}s_{3}</var>

Output

Print the answer.

Sample Input 1

101

Sample Output 1

2

A marble will be placed on Square <var>1</var> and <var>3</var>.

Sample Input 2

000

Sample Output 2

0

No marble will be placed on any square.


Score : <var>200</var> points

Problem Statement

AtCoDeer the deer has found two positive integers, <var>a</var> and <var>b</var>.
Determine whether the concatenation of <var>a</var> and <var>b</var> in this order is a square number.

Constraints

<var>1</var> <var>≤</var> <var>a,b</var> <var>≤</var> <var>100</var>

<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 the concatenation of <var>a</var> and <var>b</var> in this order is a square number, print Yes; otherwise, print No.

Sample Input 1

1 21

Sample Output 1

Yes

As <var>121</var> <var>=</var> <var>11</var> × <var>11</var>, it is a square number.

Sample Input 2

100 100

Sample Output 2

No

<var>100100</var> is not a square number.

Sample Input 3

12 10

Sample Output 3

No


Score : <var>100</var> points

Problem Statement

It is September <var>9</var> in Japan now.

You are given a two-digit integer <var>N</var>. Answer the question: Is <var>9</var> contained in the decimal notation of <var>N</var>?

Constraints

<var>10≤N≤99</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>

Output

If <var>9</var> is contained in the decimal notation of <var>N</var>, print Yes; if not, print No.

Sample Input 1

29

Sample Output 1

Yes

The one's digit of <var>29</var> is <var>9</var>.

Sample Input 2

72

Sample Output 2

No

<var>72</var> does not contain <var>9</var>.

Sample Input 3

91

Sample Output 3

Yes


Score : <var>200</var> points

Problem Statement

Print all the integers that satisfies the following in ascending order:

Among the integers between <var>A</var> and <var>B</var> (inclusive), it is either within the <var>K</var> smallest integers or within the <var>K</var> largest integers.

Constraints

<var>1 \leq A \leq B \leq 10^9</var>

<var>1 \leq K \leq 100</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 all the integers that satisfies the condition above in ascending order.

Sample Input 1

3 8 2

Sample Output 1

3
4
7
8

<var>3</var> is the first smallest integer among the integers between <var>3</var> and <var>8</var>.

<var>4</var> is the second smallest integer among the integers between <var>3</var> and <var>8</var>.

<var>7</var> is the second largest integer among the integers between <var>3</var> and <var>8</var>.

<var>8</var> is the first largest integer among the integers between <var>3</var> and <var>8</var>.

Sample Input 2

4 8 3

Sample Output 2

4
5
6
7
8

Sample Input 3

2 9 100

Sample Output 3

2
3
4
5
6
7
8
9


Score : <var>100</var> points

Problem Statement

The door of Snuke's laboratory is locked with a security code.

The security code is a <var>4</var>-digit number. We say the security code is hard to enter when it contains two consecutive digits that are the same.

You are given the current security code <var>S</var>. If <var>S</var> is hard to enter, print Bad; otherwise, print Good.

Constraints

<var>S</var> is a <var>4</var>-character string consisting of digits.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

If <var>S</var> is hard to enter, print Bad; otherwise, print Good.

Sample Input 1

3776

Sample Output 1

Bad

The second and third digits are the same, so <var>3776</var> is hard to enter.

Sample Input 2

8080

Sample Output 2

Good

There are no two consecutive digits that are the same, so <var>8080</var> is not hard to enter.

Sample Input 3

1333

Sample Output 3

Bad

Sample Input 4

0024

Sample Output 4

Bad


Score : <var>400</var> points

Problem Statement

An altar enshrines <var>N</var> stones arranged in a row from left to right. The color of the <var>i</var>-th stone from the left <var>(1 \leq i \leq N)</var> is given to you as a character <var>c_i</var>; R stands for red and W stands for white.

You can do the following two kinds of operations any number of times in any order:

Choose two stones (not necessarily adjacent) and swap them.

Choose one stone and change its color (from red to white and vice versa).

According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Constraints

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

<var>c_i</var> is R or W.

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>c_{1}c_{2}...c_{N}</var>

Output

Print an integer representing the minimum number of operations needed.

Sample Input 1

4
WWRR

Sample Output 1

2

For example, the two operations below will achieve the objective.

Swap the <var>1</var>-st and <var>3</var>-rd stones from the left, resulting in RWWR.

Change the color of the <var>4</var>-th stone from the left, resulting in RWWW.

Sample Input 2

2
RR

Sample Output 2

0

It can be the case that no operation is needed.

Sample Input 3

8
WRWWRWRR

Sample Output 3

3


Score: <var>400</var> points

Problem Statement

The Kingdom of Takahashi has <var>N</var> towns, numbered <var>1</var> through <var>N</var>.

There is one teleporter in each town. The teleporter in Town <var>i</var> <var>(1 \leq i \leq N)</var> sends you to Town <var>A_i</var>.

Takahashi, the king, loves the positive integer <var>K</var>. The selfish king wonders what town he will be in if he starts at Town <var>1</var> and uses a teleporter exactly <var>K</var> times from there.

Help the king by writing a program that answers this question.

Constraints

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

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

<var>1 \leq K \leq 10^{18}</var>

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>\dots</var> <var>A_N</var>

Output

Print the integer representing the town the king will be in if he starts at Town <var>1</var> and uses a teleporter exactly <var>K</var> times from there.

Sample Input 1

4 5
3 2 4 1

Sample Output 1

4

If we start at Town <var>1</var> and use the teleporter <var>5</var> times, our travel will be as follows: <var>1 \to 3 \to 4 \to 1 \to 3 \to 4</var>.

Sample Input 2

6 727202214173249351
6 5 2 5 3 2

Sample Output 2

2


Score : <var>300</var> points

Problem Statement

Snuke has <var>N</var> dogs and <var>M</var> monkeys. He wants them to line up in a row.

As a Japanese saying goes, these dogs and monkeys are on bad terms. ("ken'en no naka", literally "the relationship of dogs and monkeys", means a relationship of mutual hatred.) Snuke is trying to reconsile them, by arranging the animals so that there are neither two adjacent dogs nor two adjacent monkeys.

How many such arrangements there are? Find the count modulo <var>10^9+7</var> (since animals cannot understand numbers larger than that).
Here, dogs and monkeys are both distinguishable. Also, two arrangements that result from reversing each other are distinguished.

Constraints

<var>1 ≤ N,M ≤ 10^5</var>

Input

Input is given from Standard Input in the following format:

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

Output

Print the number of possible arrangements, modulo <var>10^9+7</var>.

Sample Input 1

2 2

Sample Output 1

8

We will denote the dogs by A and B, and the monkeys by C and D. There are eight possible arrangements: ACBD, ADBC, BCAD, BDAC, CADB, CBDA, DACB and DBCA.

Sample Input 2

3 2

Sample Output 2

12

Sample Input 3

1 8

Sample Output 3

0

Sample Input 4

100000 100000

Sample Output 4

530123477


Score: <var>100</var> points

Problem Statement

The weather in Takahashi's town changes day by day, in the following cycle: Sunny, Cloudy, Rainy, Sunny, Cloudy, Rainy, ...

Given is a string <var>S</var> representing the weather in the town today. Predict the weather tomorrow.

Constraints

<var>S</var> is Sunny, Cloudy, or Rainy.

Input

Input is given from Standard Input in the following format:

<var>S</var>

Output

Print a string representing the expected weather tomorrow, in the same format in which input is given.

Sample Input 1

Sunny

Sample Output 1

Cloudy

In Takahashi's town, a sunny day is followed by a cloudy day.

Sample Input 2

Rainy

Sample Output 2

Sunny


Score: <var>100</var> points

Problem Statement

A triple of numbers is said to be poor when two of those numbers are equal but the other number is different from those two numbers.

You will be given three integers <var>A</var>, <var>B</var>, and <var>C</var>. If this triple is poor, print Yes; otherwise, print No.

Constraints

<var>A</var>, <var>B</var>, and <var>C</var> are all integers between <var>1</var> and <var>9</var> (inclusive).

Input

Input is given from Standard Input in the following format:

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

Output

If the given triple is poor, print Yes; otherwise, print No.

Sample Input 1

5 7 5

Sample Output 1

Yes

<var>A</var> and <var>C</var> are equal, but <var>B</var> is different from those two numbers, so this triple is poor.

Sample Input 2

4 4 4

Sample Output 2

No

<var>A</var>, <var>B</var>, and <var>C</var> are all equal, so this triple is not poor.

Sample Input 3

4 9 6

Sample Output 3

No

Sample Input 4

3 3 4

Sample Output 4

Yes


Score: <var>300</var> points

Problem Statement

AtCoder Mart sells <var>1000000</var> of each of the six items below:

Riceballs, priced at <var>100</var> yen (the currency of Japan) each

Sandwiches, priced at <var>101</var> yen each

Cookies, priced at <var>102</var> yen each

Cakes, priced at <var>103</var> yen each

Candies, priced at <var>104</var> yen each

Computers, priced at <var>105</var> yen each

Takahashi wants to buy some of them that cost exactly <var>X</var> yen in total.
Determine whether this is possible.

(Ignore consumption tax.)

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>X</var>

Output

If it is possible to buy some set of items that cost exactly <var>X</var> yen in total, print 1; otherwise, print 0.

Sample Input 1

615

Sample Output 1

1

For example, we can buy one of each kind of item, which will cost <var>100+101+102+103+104+105=615</var> yen in total.

Sample Input 2

217

Sample Output 2

0

No set of items costs <var>217</var> yen in total.


Score : <var>100</var> points

Problem Statement

Find the number of ways to choose a pair of an even number and an odd number from the positive integers between <var>1</var> and <var>K</var> (inclusive). The order does not matter.

Constraints

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

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

Input

Input is given from Standard Input in the following format:

<var>K</var>

Output

Print the number of ways to choose a pair of an even number and an odd number from the positive integers between <var>1</var> and <var>K</var> (inclusive).

Sample Input 1

3

Sample Output 1

2

Two pairs can be chosen: <var>(2,1)</var> and <var>(2,3)</var>.

Sample Input 2

6

Sample Output 2

9

Sample Input 3

11

Sample Output 3

30

Sample Input 4

50

Sample Output 4

625


Score: <var>100</var> points

Problem Statement

E869120 has <var>A</var> <var>1</var>-yen coins and infinitely many <var>500</var>-yen coins.

Determine if he can pay exactly <var>N</var> yen using only these coins.

Constraints

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

<var>A</var> is an integer between <var>0</var> and <var>1000</var> (inclusive).

Input

Input is given from Standard Input in the following format:

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

Output

If E869120 can pay exactly <var>N</var> yen using only his <var>1</var>-yen and <var>500</var>-yen coins, print Yes; otherwise, print No.

Sample Input 1

2018
218

Sample Output 1

Yes

We can pay <var>2018</var> yen with four <var>500</var>-yen coins and <var>18</var> <var>1</var>-yen coins, so the answer is Yes.

Sample Input 2

2763
0

Sample Output 2

No

When we have no <var>1</var>-yen coins, we can only pay a multiple of <var>500</var> yen using only <var>500</var>-yen coins. Since <var>2763</var> is not a multiple of <var>500</var>, we cannot pay this amount.

Sample Input 3

37
514

Sample Output 3

Yes


Score : <var>400</var> points

Problem Statement

There are <var>N</var> empty boxes arranged in a row from left to right.
The integer <var>i</var> is written on the <var>i</var>-th box from the left <var>(1 \leq i \leq N)</var>.

For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.

We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:

For every integer <var>i</var> between <var>1</var> and <var>N</var> (inclusive), the total number of balls contained in the boxes with multiples of <var>i</var> written on them is congruent to <var>a_i</var> modulo <var>2</var>.

Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Constraints

All values in input are integers.

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

<var>a_i</var> is <var>0</var> or <var>1</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

If a good set of choices does not exist, print -1.

If a good set of choices exists, print one such set of choices in the following format:

<var>M</var>
<var>b_1</var> <var>b_2</var> <var>...</var> <var>b_M</var>

where <var>M</var> denotes the number of boxes that will contain a ball, and <var>b_1,\ b_2,\ ...,\ b_M</var> are the integers written on these boxes, in any order.

Sample Input 1

3
1 0 0

Sample Output 1

1
1

Consider putting a ball only in the box with <var>1</var> written on it.

There are three boxes with multiples of <var>1</var> written on them: the boxes with <var>1</var>, <var>2</var>, and <var>3</var>. The total number of balls contained in these boxes is <var>1</var>.

There is only one box with a multiple of <var>2</var> written on it: the box with <var>2</var>. The total number of balls contained in these boxes is <var>0</var>.

There is only one box with a multiple of <var>3</var> written on it: the box with <var>3</var>. The total number of balls contained in these boxes is <var>0</var>.

Thus, the condition is satisfied, so this set of choices is good.

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

Putting nothing in the boxes can be a good set of choices.


Score : <var>100</var> points

Problem Statement

Three poles stand evenly spaced along a line. Their heights are <var>a</var>, <var>b</var> and <var>c</var> meters, from left to right.
We will call the arrangement of the poles beautiful if the tops of the poles lie on the same line, that is, <var>b-a = c-b</var>.

Determine whether the arrangement of the poles is beautiful.

Constraints

<var>1 \leq a,b,c \leq 100</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 YES if the arrangement of the poles is beautiful; print NO otherwise.

Sample Input 1

2 4 6

Sample Output 1

YES

Since <var>4-2 = 6-4</var>, this arrangement of poles is beautiful.

Sample Input 2

2 5 6

Sample Output 2

NO

Since <var>5-2 \neq 6-5</var>, this arrangement of poles is not beautiful.

Sample Input 3

3 2 1

Sample Output 3

YES

Since <var>1-2 = 2-3</var>, this arrangement of poles is beautiful.


Score : <var>100</var> points

Problem Statement

You are given three integers <var>A, B</var> and <var>C</var>.

Determine if there exists an equilateral triangle whose sides have lengths <var>A, B</var> and <var>C</var>.

Constraints

All values in input are integers.

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

Input

Input is given from Standard Input in the following format:

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

Output

If there exists an equilateral triangle whose sides have lengths <var>A, B</var> and <var>C</var>, print Yes; otherwise, print No.

Sample Input 1

2 2 2

Sample Output 1

Yes

There exists an equilateral triangle whose sides have lengths <var>2, 2</var> and <var>2</var>.

Sample Input 2

3 4 5

Sample Output 2

No

There is no equilateral triangle whose sides have lengths <var>3, 4</var> and <var>5</var>.


Score : <var>300</var> points

Problem Statement

Takahashi participated in a contest on AtCoder.

The contest had <var>N</var> problems.

Takahashi made <var>M</var> submissions during the contest.

The <var>i</var>-th submission was made for the <var>p_i</var>-th problem and received the verdict <var>S_i</var> (AC or WA).

The number of Takahashi's correct answers is the number of problems on which he received an AC once or more.

The number of Takahashi's penalties is the sum of the following count for the problems on which he received an AC once or more: the number of WAs received before receiving an AC for the first time on that problem.

Find the numbers of Takahashi's correct answers and penalties.

Constraints

<var>N</var>, <var>M</var>, and <var>p_i</var> are integers.

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

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

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

<var>S_i</var> is AC or WA.

Input

Input is given from Standard Input in the following format:

<var>N</var> <var>M</var>
<var>p_1</var> <var>S_1</var>
<var>:</var>
<var>p_M</var> <var>S_M</var>

Output

Print the number of Takahashi's correct answers and the number of Takahashi's penalties.

Sample Input 1

2 5
1 WA
1 AC
2 WA
2 AC
2 WA

Sample Output 1

2 2

In his second submission, he received an AC on the first problem for the first time. Before this, he received one WA on this problem.

In his fourth submission, he received an AC on the second problem for the first time. Before this, he received one WA on this problem.

Thus, he has two correct answers and two penalties.

Sample Input 2

100000 3
7777 AC
7777 AC
7777 AC

Sample Output 2

1 0

Note that it is pointless to get an AC more than once on the same problem.

Sample Input 3

6 0

Sample Output 3

0 0


Score : <var>100</var> points

Problem Statement

You are given positive integers <var>A</var> and <var>B</var>.

If <var>A</var> is a divisor of <var>B</var>, print <var>A + B</var>; otherwise, print <var>B - A</var>.

Constraints

All values in input are integers.

<var>1 \leq A \leq B \leq 20</var>

Input

Input is given from Standard Input in the following format:

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

Output

If <var>A</var> is a divisor of <var>B</var>, print <var>A + B</var>; otherwise, print <var>B - A</var>.

Sample Input 1

4 12

Sample Output 1

16

As <var>4</var> is a divisor of <var>12</var>, <var>4 + 12 = 16</var> should be printed.

Sample Input 2

8 20

Sample Output 2

12

Sample Input 3

1 1

Sample Output 3

2

<var>1</var> is a divisor of <var>1</var>.


Score : <var>400</var> points

Problem Statement

There are <var>N</var> mountains in a circle, called Mountain <var>1</var>, Mountain <var>2</var>, <var>...</var>, Mountain <var>N</var> in clockwise order. <var>N</var> is an odd number.

Between these mountains, there are <var>N</var> dams, called Dam <var>1</var>, Dam <var>2</var>, <var>...</var>, Dam <var>N</var>. Dam <var>i</var> (<var>1 \leq i \leq N</var>) is located between Mountain <var>i</var> and <var>i+1</var> (Mountain <var>N+1</var> is Mountain <var>1</var>).

When Mountain <var>i</var> (<var>1 \leq i \leq N</var>) receives <var>2x</var> liters of rain, Dam <var>i-1</var> and Dam <var>i</var> each accumulates <var>x</var> liters of water (Dam <var>0</var> is Dam <var>N</var>).

One day, each of the mountains received a non-negative even number of liters of rain.

As a result, Dam <var>i</var> (<var>1 \leq i \leq N</var>) accumulated a total of <var>A_i</var> liters of water.

Find the amount of rain each of the mountains received. We can prove that the solution is unique under the constraints of this problem.

Constraints

All values in input are integers.

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

<var>N</var> is an odd number.

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

The situation represented by input can occur when each of the mountains receives a non-negative even number of liters of rain.

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 <var>N</var> integers representing the number of liters of rain Mountain <var>1</var>, Mountain <var>2</var>, <var>...</var>, Mountain <var>N</var> received, in this order.

Sample Input 1

3
2 2 4

Sample Output 1

4 0 4

If we assume Mountain <var>1</var>, <var>2</var>, and <var>3</var> received <var>4</var>, <var>0</var>, and <var>4</var> liters of rain, respectively, it is consistent with this input, as follows:

Dam <var>1</var> should have accumulated <var>\frac{4}{2} + \frac{0}{2} = 2</var> liters of water.

Dam <var>2</var> should have accumulated <var>\frac{0}{2} + \frac{4}{2} = 2</var> liters of water.

Dam <var>3</var> should have accumulated <var>\frac{4}{2} + \frac{4}{2} = 4</var> liters of water.

Sample Input 2

5
3 8 7 5 5

Sample Output 2

2 4 12 2 8

Sample Input 3

3
1000000000 1000000000 0

Sample Output 3

0 2000000000 0


Score : <var>200</var> points

Problem Statement

You are given a string <var>S</var> of length <var>N</var>.
Among its subsequences, count the ones such that all characters are different, modulo <var>10^9+7</var>. Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.

Here, a subsequence of a string is a concatenation of one or more characters from the string without changing the order.

Constraints

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

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

<var>|S|=N</var>

Input

Input is given from Standard Input in the following format:

<var>N</var>
<var>S</var>

Output

Print the number of the subsequences such that all characters are different, modulo <var>10^9+7</var>.

Sample Input 1

4
abcd

Sample Output 1

15

Since all characters in <var>S</var> itself are different, all its subsequences satisfy the condition.

Sample Input 2

3
baa

Sample Output 2

5

The answer is five: b, two occurrences of a, two occurrences of ba. Note that we do not count baa, since it contains two as.

Sample Input 3

5
abcab

Sample Output 3

17


Score : <var>100</var> points

Problem Statement

Three people, A, B and C, are trying to communicate using transceivers.
They are standing along a number line, and the coordinates of A, B and C are <var>a</var>, <var>b</var> and <var>c</var> (in meters), respectively.
Two people can directly communicate when the distance between them is at most <var>d</var> meters.
Determine if A and C can communicate, either directly or indirectly.
Here, A and C can indirectly communicate when A and B can directly communicate and also B and C can directly communicate.

Constraints

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

<var>1</var> <var>≤</var> <var>d</var> <var>≤</var> <var>100</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>d</var>

Output

If A and C can communicate, print Yes; if they cannot, print No.

Sample Input 1

4 7 9 3

Sample Output 1

Yes

A and B can directly communicate, and also B and C can directly communicate, so we should print Yes.

Sample Input 2

100 10 1 2

Sample Output 2

No

They cannot communicate in this case.

Sample Input 3

10 10 10 1

Sample Output 3

Yes

There can be multiple people at the same position.

Sample Input 4

1 100 2 10

Sample Output 4

Yes


Score : <var>300</var> points

Problem Statement

Snuke has a fair <var>N</var>-sided die that shows the integers from <var>1</var> to <var>N</var> with equal probability and a fair coin. He will play the following game with them:

Throw the die. The current score is the result of the die.

As long as the score is between <var>1</var> and <var>K-1</var> (inclusive), keep flipping the coin. The score is doubled each time the coin lands heads up, and the score becomes <var>0</var> if the coin lands tails up.

The game ends when the score becomes <var>0</var> or becomes <var>K</var> or above. Snuke wins if the score is <var>K</var> or above, and loses if the score is <var>0</var>.

You are given <var>N</var> and <var>K</var>. Find the probability that Snuke wins the game.

Constraints

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

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

Print the probability that Snuke wins the game. The output is considered correct when the absolute or relative error is at most <var>10^{-9}</var>.

Sample Input 1

3 10

Sample Output 1

0.145833333333

If the die shows <var>1</var>, Snuke needs to get four consecutive heads from four coin flips to obtain a score of <var>10</var> or above. The probability of this happening is <var>\frac{1}{3} \times (\frac{1}{2})^4 = \frac{1}{48}</var>.

If the die shows <var>2</var>, Snuke needs to get three consecutive heads from three coin flips to obtain a score of <var>10</var> or above. The probability of this happening is <var>\frac{1}{3} \times (\frac{1}{2})^3 = \frac{1}{24}</var>.

If the die shows <var>3</var>, Snuke needs to get two consecutive heads from two coin flips to obtain a score of <var>10</var> or above. The probability of this happening is <var>\frac{1}{3} \times (\frac{1}{2})^2 = \frac{1}{12}</var>.

Thus, the probability that Snuke wins is <var>\frac{1}{48} + \frac{1}{24} + \frac{1}{12} = \frac{7}{48} \simeq 0.1458333333</var>.

Sample Input 2

100000 5

Sample Output 2

0.999973749998