A - Happy Birthday! 4

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

正整数 X,Y,Z が与えられます。

高橋君と青木君は現在それぞれ X 歳、Y 歳です。

高橋君と青木君は毎年 11 日を迎えると同時に 1 歳ずつ歳を取ります。

(今年も含めて)これから高橋君の年齢が青木君の年齢のちょうど Z 倍となるタイミングが存在するか判定してください。

制約

  • 1\le X,Y \le 100
  • 2\le Z\le 10
  • 入力される値は全て整数

入力

入力は以下の形式で標準入力から与えられる。

X Y Z

出力

高橋君の年齢が青木君の年齢のちょうど Z 倍となるタイミングが存在するならば Yes を、存在しないならば No を出力せよ。


入力例 1

44 20 2

出力例 1

Yes

今から 4 年後に高橋君は 48 歳、青木君は 24 歳になり、高橋君の年齢は青木君の年齢のちょうど 2 倍になります。したがって、 Yes を出力してください。


入力例 2

28 10 3

出力例 2

No

これから高橋君の年齢が青木君の年齢のちょうど 3 倍となるタイミングは存在しません。したがって、No を出力してください。


入力例 3

50 5 10

出力例 3

Yes

現在の高橋君の年齢は青木君の年齢のちょうど 10 倍です。

今年も含めてこれから高橋君の年齢が青木君の年齢のちょうど Z 倍となるタイミングが存在するか判定することに注意してください。


入力例 4

1 100 2

出力例 4

No

Score : 100 points

Problem Statement

You are given positive integers X,Y,Z.

Takahashi and Aoki are currently X years old and Y years old, respectively.

Takahashi and Aoki age by 1 year simultaneously on every January 1st.

Determine whether there is a moment in the future (including this year) when Takahashi's age becomes exactly Z times Aoki's age.

Constraints

  • 1\le X,Y \le 100
  • 2\le Z\le 10
  • All input values are integers.

Input

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

X Y Z

Output

Output Yes if there is a moment in the future when Takahashi's age becomes exactly Z times Aoki's age, and No otherwise.


Sample Input 1

44 20 2

Sample Output 1

Yes

Four years from now, Takahashi will be 48 years old and Aoki will be 24 years old, so Takahashi's age will be exactly twice Aoki's age. Thus, output Yes.


Sample Input 2

28 10 3

Sample Output 2

No

There will never be a moment when Takahashi's age becomes exactly three times Aoki's age. Thus, output No.


Sample Input 3

50 5 10

Sample Output 3

Yes

Currently, Takahashi's age is exactly 10 times Aoki's age.

Note that you need to determine whether there will be such a moment in the future including this year.


Sample Input 4

1 100 2

Sample Output 4

No
B - Nearest Taller

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

N 人の人が左右一列に並んでいます。左から i 番目 (1\le i\le N) の人を人 i と呼びます。人 i (1\le i\le N) の身長は A_i です。

i=1,2,\ldots,N に対し、人 i より左にいる人であって人 i より身長の高い人が存在するか判定し、存在する場合はその中で番号が人 i に最も近い人を求めてください。

制約

  • 1\le N\le 100
  • 1\le A_i\le 100
  • 入力される値は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N
A_1 A_2 \ldots A_N

出力

N 行出力せよ。

i 行目 (1\le i\le N) には、人 i より左にいる人であって人 i より身長の高い人が存在しない場合は -1 を、存在する場合はその中で番号が人 i に最も近い人の番号を出力せよ。


入力例 1

4
4 3 2 5

出力例 1

-1
1
2
-1
  • 1 より左側に人はいません。したがって、 1 行目には -1 を出力してください。
  • 2 より左側にいる人で人 2 より身長が高いのは人 1 のみです。したがって、 2 行目には 1 を出力してください。
  • 3 より左側にいる人で人 3 より身長が高いのは人 1,2 で、このうち番号が人 3 に最も近いのは人 2 です。したがって、 3 行目には 2 を出力してください。
  • 4 より左側に人 4 より身長が高い人はいません。したがって、 4 行目には -1 を出力してください。

入力例 2

3
7 7 7

出力例 2

-1
-1
-1

同じ身長の人が複数人いる場合もあります。


入力例 3

6
31 9 17 10 2 9

出力例 3

-1
1
1
3
4
4

Score : 200 points

Problem Statement

There are N people standing in a row from left to right. The i-th person from the left (1\le i\le N) is called person i. The height of person i (1\le i\le N) is A_i.

For each i=1,2,\ldots,N, determine whether there exists a person to the left of person i who is taller than person i, and if so, find the person standing closest to person i among them.

Constraints

  • 1\le N\le 100
  • 1\le A_i\le 100
  • All input values are integers.

Input

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

N
A_1 A_2 \ldots A_N

Output

Output N lines.

The i-th line (1\le i\le N) should contain -1 if there is no person to the left of person i who is taller than person i, and otherwise, the number representing the person standing closest to person i among such people.


Sample Input 1

4
4 3 2 5

Sample Output 1

-1
1
2
-1
  • There is no person to the left of person 1. Thus, output -1 on the first line.
  • Among the people to the left of person 2, only person 1 is taller than person 2. Thus, output 1 on the second line.
  • Among the people to the left of person 3, persons 1,2 are taller than person 3, and the person standing closest to person 3 is person 2. Thus, output 2 on the third line.
  • There is no person to the left of person 4 who is taller than person 4. Thus, output -1 on the fourth line.

Sample Input 2

3
7 7 7

Sample Output 2

-1
-1
-1

There may be multiple people with the same height.


Sample Input 3

6
31 9 17 10 2 9

Sample Output 3

-1
1
1
3
4
4
C - 1122 Substring 2

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300

問題文

数字からなる文字列 S が与えられます。

以下の条件を全て満たす文字列 T1122文字列 と呼びます。(定義は F 問題と同じです。)

  • T は数字からなる空でない文字列
  • |T| は偶数。ここで、 |T| は文字列 T の長さを表す
  • T1 文字目から \frac{|T|}2 文字目までは全て同じ数字である
  • T\frac{|T|}2+1 文字目から |T| 文字目までは全て同じ数字である
  • T1 文字目の数字に 1 を足すと |T| 文字目の数字になる

例えば 112201444555 などは 1122文字列 ですが、 122290 は 1122文字列 ではありません。

S部分文字列 であって 1122文字列 であるものの個数を求めてください。

ただし、ある二つの部分文字列が文字列として同じでも、取り出された位置が異なるならばそれらは別々に数えるものとします。

制約

  • S は長さ 1 以上 10^6 以下の数字からなる文字列

入力

入力は以下の形式で標準入力から与えられる。

S

出力

S の空でない部分文字列であって 1122文字列 であるものの個数を出力せよ。


入力例 1

1122

出力例 1

2

以下の 2 つの部分文字列が条件を満たします。

  • S2 文字目から 3 文字目を取り出した 12
  • S1 文字目から 4 文字目を取り出した 1122

したがって、 2 を出力してください。


入力例 2

7788788

出力例 2

3

文字列として同じでも、取り出された位置が異なるならばそれらは別々に数えることに注意してください。


入力例 3

2025

出力例 3

0

1122文字列 となる部分文字列が存在しない場合もあります。


入力例 4

1112222334445556555

出力例 4

11

Score : 300 points

Problem Statement

You are given a string S consisting of digits.

A string T is called a 1122-string if it satisfies all of the following conditions. (The definition is the same as in Problem F.)

  • T is a non-empty string consisting of digits.
  • |T| is even, where |T| denotes the length of string T.
  • All characters from the 1-st through the \frac{|T|}2-th character of T are the same digit.
  • All characters from the (\frac{|T|}2+1)-th through the |T|-th character of T are the same digit.
  • Adding 1 to the digit of the 1-st character of T gives the digit of the |T|-th character.

For example, 1122, 01, and 444555 are 1122-strings, but 1222 and 90 are not 1122-strings.

Find the number of substrings of S that are 1122-strings.

Two substrings are counted separately if they are extracted from different positions, even if they are identical as strings.

Constraints

  • S is a string consisting of digits with length between 1 and 10^6, inclusive.

Input

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

S

Output

Output the number of non-empty substrings of S that are 1122-strings.


Sample Input 1

1122

Sample Output 1

2

The following two substrings satisfy the condition.

  • 12 extracted from the 2-nd through 3-rd characters of S
  • 1122 extracted from the 1-st through 4-th characters of S

Thus, output 2.


Sample Input 2

7788788

Sample Output 2

3

Note that two substrings are counted separately if they are extracted from different positions, even if they are identical as strings.


Sample Input 3

2025

Sample Output 3

0

There may be no substring that is a 1122-string.


Sample Input 4

1112222334445556555

Sample Output 4

11
D - 183183

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 400

問題文

正整数 x,y に対して f(x,y) を以下のように定義します。

  • 先頭に余分な 0 を付けない十進表記の x,y をそれぞれ文字列として解釈しこの順に連結して得られる文字列を S としたときの、 S を十進表記の整数として解釈した値。

例えば f(12,3) = 123f(100,40)=10040 です。

正整数 N,M と長さ N の正整数列 A=(A_1,A_2,\ldots,A_N) が与えられます。

以下の条件を全て満たす整数の組 (i,j) の個数を求めてください。

  • 1\le i,j\le N
  • f(A_i,A_j)M の倍数

制約

  • 1\le N\le 2\times 10^5
  • 1\le M\le 10^9
  • 1\le A_i\le 10^9
  • 入力される値は全て整数

入力

入力は以下の形式で標準入力から与えられる。

N M
A_1 A_2 \ldots A_N

出力

条件を全て満たす整数の組 (i,j) の個数を出力せよ。


入力例 1

2 11
2 42

出力例 1

2
  • (i,j)=(1,1) のとき: f(A_1,A_1)=2211 の倍数です。
  • (i,j)=(1,2) のとき: f(A_1,A_2)=24211 の倍数です。
  • (i,j)=(2,1) のとき: f(A_2,A_1)=42211 の倍数ではありません。
  • (i,j)=(2,2) のとき: f(A_2,A_2)=424211 の倍数ではありません。

以上より、条件を全て満たす整数の組は (i,j)=(1,1),(1,2)2 つです。したがって、 2 を出力してください。


入力例 2

4 7
2 8 16 183

出力例 2

4

入力例 3

5 5
1000000000 1000000000 1000000000 1000000000 1000000000

出力例 3

25

入力例 4

12 13
80 68 862370 82217 8 56 5 168 672624 6 286057 11864

出力例 4

10

Score : 400 points

Problem Statement

For positive integers x,y, define f(x,y) as follows:

  • The value obtained by interpreting x,y in decimal notation without leading zeros as strings, concatenating them in this order to obtain a string S, and then interpreting S as an integer in decimal notation.

For example, f(12,3) = 123 and f(100,40)=10040.

You are given positive integers N,M and a sequence of N positive integers A=(A_1,A_2,\ldots,A_N).

Find the number of pairs of integers (i,j) that satisfy all of the following conditions.

  • 1\le i,j\le N
  • f(A_i,A_j) is a multiple of M.

Constraints

  • 1\le N\le 2\times 10^5
  • 1\le M\le 10^9
  • 1\le A_i\le 10^9
  • All input values are integers.

Input

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

N M
A_1 A_2 \ldots A_N

Output

Output the number of pairs of integers (i,j) that satisfy all the conditions.


Sample Input 1

2 11
2 42

Sample Output 1

2
  • When (i,j)=(1,1): f(A_1,A_1)=22 is a multiple of 11.
  • When (i,j)=(1,2): f(A_1,A_2)=242 is a multiple of 11.
  • When (i,j)=(2,1): f(A_2,A_1)=422 is not a multiple of 11.
  • When (i,j)=(2,2): f(A_2,A_2)=4242 is not a multiple of 11.

From the above, the pairs of integers that satisfy all the conditions are (i,j)=(1,1),(1,2), which is two pairs. Thus, output 2.


Sample Input 2

4 7
2 8 16 183

Sample Output 2

4

Sample Input 3

5 5
1000000000 1000000000 1000000000 1000000000 1000000000

Sample Output 3

25

Sample Input 4

12 13
80 68 862370 82217 8 56 5 168 672624 6 286057 11864

Sample Output 4

10
E - Max Matrix 2

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 450

問題文

整数 N,M と長さ N の整数列 X=(X_1,X_2,\ldots,X_N) 、長さ M の整数列 Y=(Y_1,Y_2,\ldots,Y_M) が与えられます。

以下の条件を全て満たす NM 列の整数行列 A=(A_{i,j}) (1\le i\le N,\ 1\le j\le M) が存在するか判定し、存在する場合は一つ求めてください。

  • 1\le A_{i,j} \le N\times M
  • A_{i,j}N\times M 個の要素は相異なる
  • i=1,2,\ldots,N に対し \displaystyle \max_{1\le j\le M} A_{i,j} = X_i が成り立つ
  • j=1,2,\ldots,M に対し \displaystyle \max_{1\le i\le N} A_{i,j} = Y_j が成り立つ

T 個のテストケースが与えられるので、それぞれについて答えを求めてください。

制約

  • 1\le T\le 10^5
  • 1\le N,M
  • 全てのテストケースにおける N\times M の総和は 2\times 10^5 以下
  • 1\le X_i,Y_j\le N\times M
  • 入力される値は全て整数

入力

入力は以下の形式で標準入力から与えられる。

T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T

各テストケースは以下の形式で与えられる。

N M
X_1 X_2 \ldots X_N
Y_1 Y_2 \ldots Y_M

出力

各テストケースに対する答えを順に改行区切りで出力せよ。

各テストケースについて、条件を全て満たす A が存在しない場合は No を出力せよ。

そうでない場合、条件を全て満たす A を以下の形式で出力せよ。

Yes
A_{1,1} A_{1,2} \ldots A_{1,M}
A_{2,1} A_{2,2} \ldots A_{2,M}
\vdots
A_{N,1} A_{N,2} \ldots A_{N,M}

条件を満たす A が複数存在する場合、どれを出力しても正答となる。


入力例 1

3
2 3
5 6
5 3 6
3 3
5 4 6
6 2 4
5 4
18 20 19 14 17
18 20 14 15

出力例 1

Yes
5 1 4
2 3 6
No
Yes
18 12 4 9
13 20 1 10
16 19 6 8
2 5 14 3
11 17 7 15

1 つ目のテストケースについて考えます。

出力例の A の要素は全て 1 以上 6 以下で相異なり、さらに

  • \displaystyle \max_{1\le j\le 3} A_{1,j} =\max \lbrace 5,1,4\rbrace = 5 = X_1
  • \displaystyle\max_{1\le j\le 3} A_{2,j} =\max \lbrace 2,3,6\rbrace = 6 = X_2
  • \displaystyle\max_{1\le i\le 2} A_{i,1} =\max \lbrace 5,2\rbrace = 5 = Y_1
  • \displaystyle\max_{1\le i\le 2} A_{i,2} =\max \lbrace 1,3\rbrace = 3 = Y_2
  • \displaystyle\max_{1\le i\le 2} A_{i,3} =\max \lbrace 4,6\rbrace = 6 = Y_3

より全ての条件を満たしていることが分かります。

そのほかにも、例えば以下のような出力も正答となります。

Yes
5 3 1
4 2 6

Score : 450 points

Problem Statement

You are given integers N,M, a sequence of N integers X=(X_1,X_2,\ldots,X_N), and a sequence of M integers Y=(Y_1,Y_2,\ldots,Y_M).

Determine whether there exists an N row by M column integer matrix A=(A_{i,j}) (1\le i\le N,\ 1\le j\le M) that satisfies all of the following conditions, and if so, find one such matrix.

  • 1\le A_{i,j} \le N\times M
  • All N\times M elements of A_{i,j} are distinct.
  • \displaystyle \max_{1\le j\le M} A_{i,j} = X_i for i=1,2,\ldots,N.
  • \displaystyle \max_{1\le i\le N} A_{i,j} = Y_j for j=1,2,\ldots,M.

You are given T test cases; solve each of them.

Constraints

  • 1\le T\le 10^5
  • 1\le N,M
  • The sum of N\times M over all test cases is at most 2\times 10^5.
  • 1\le X_i,Y_j\le N\times M
  • All input values are integers.

Input

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

T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T

Each test case is given in the following format:

N M
X_1 X_2 \ldots X_N
Y_1 Y_2 \ldots Y_M

Output

Output the answers for the test cases in order, separated by newlines.

For each test case, if there is no A that satisfies all the conditions, output No.

Otherwise, output A that satisfies all the conditions in the following format:

Yes
A_{1,1} A_{1,2} \ldots A_{1,M}
A_{2,1} A_{2,2} \ldots A_{2,M}
\vdots
A_{N,1} A_{N,2} \ldots A_{N,M}

If there are multiple A that satisfy the conditions, any of them will be accepted.


Sample Input 1

3
2 3
5 6
5 3 6
3 3
5 4 6
6 2 4
5 4
18 20 19 14 17
18 20 14 15

Sample Output 1

Yes
5 1 4
2 3 6
No
Yes
18 12 4 9
13 20 1 10
16 19 6 8
2 5 14 3
11 17 7 15

Consider the first test case.

In the sample output, all elements of A are between 1 and 6 and are distinct, and furthermore,

  • \displaystyle \max_{1\le j\le 3} A_{1,j} =\max \lbrace 5,1,4\rbrace = 5 = X_1
  • \displaystyle\max_{1\le j\le 3} A_{2,j} =\max \lbrace 2,3,6\rbrace = 6 = X_2
  • \displaystyle\max_{1\le i\le 2} A_{i,1} =\max \lbrace 5,2\rbrace = 5 = Y_1
  • \displaystyle\max_{1\le i\le 2} A_{i,2} =\max \lbrace 1,3\rbrace = 3 = Y_2
  • \displaystyle\max_{1\le i\le 2} A_{i,3} =\max \lbrace 4,6\rbrace = 6 = Y_3

so all conditions are satisfied.

Other outputs, such as the following, are also accepted.

Yes
5 3 1
4 2 6
F - 1122 Subsequence 2

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 500

問題文

数字からなる文字列 S が与えられます。

以下の条件を全て満たす文字列 T1122文字列 と呼びます。(定義は C 問題と同じです。)

  • T は数字からなる空でない文字列
  • |T| は偶数。ここで、 |T| は文字列 T の長さを表す
  • T1 文字目から \frac{|T|}2 文字目までは全て同じ数字である
  • T\frac{|T|}2+1 文字目から |T| 文字目までは全て同じ数字である
  • T1 文字目の数字に 1 を足すと |T| 文字目の数字になる

例えば 112201444555 などは 1122文字列 ですが、 122290 は 1122文字列 ではありません。

S(連続でなくても良い)部分列 であって 1122文字列 であるものの個数を 998244353 で割ったあまりを求めてください。

ただし、ある二つの部分列が文字列として同じでも、取り出された位置が異なるならばそれらは別々に数えるものとします。

制約

  • S は長さ 1 以上 10^6 以下の数字からなる文字列

入力

入力は以下の形式で標準入力から与えられる。

S

出力

S の部分列であって 1122文字列 であるものの個数を 998244353 で割ったあまりを出力せよ。


入力例 1

1122

出力例 1

5

以下の 5 つの部分列が条件を満たします。

  • S1 文字目と 3 文字目を取り出した 12
  • S1 文字目と 4 文字目を取り出した 12
  • S2 文字目と 3 文字目を取り出した 12
  • S2 文字目と 4 文字目を取り出した 12
  • S1 文字目から 4 文字目を取り出した 1122

したがって、 5 を出力してください。

文字列として同じでも、取り出された位置が異なるならばそれらは別々に数えることに注意してください。


入力例 2

2025

出力例 2

0

1122文字列 となる部分列が存在しない場合もあります。


入力例 3

0777468889971

出力例 3

30

Score : 500 points

Problem Statement

You are given a string S consisting of digits.

A string T is called a 1122-string if it satisfies all of the following conditions. (The definition is the same as in Problem C.)

  • T is a non-empty string consisting of digits.
  • |T| is even, where |T| denotes the length of string T.
  • All characters from the 1-st through the \frac{|T|}2-th character of T are the same digit.
  • All characters from the (\frac{|T|}2+1)-th through the |T|-th character of T are the same digit.
  • Adding 1 to the digit of the 1-st character of T gives the digit of the |T|-th character.

For example, 1122, 01, and 444555 are 1122-strings, but 1222 and 90 are not 1122-strings.

Find the number, modulo 998244353, of (not necessarily contiguous) subsequences of S that are 1122-strings.

Two subsequences are counted separately if they are extracted from different positions, even if they are identical as strings.

Constraints

  • S is a string consisting of digits with length between 1 and 10^6, inclusive.

Input

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

S

Output

Output the number, modulo 998244353, of subsequences of S that are 1122-strings.


Sample Input 1

1122

Sample Output 1

5

The following five subsequences satisfy the condition.

  • 12 extracted from the 1-st and 3-rd characters of S
  • 12 extracted from the 1-st and 4-th characters of S
  • 12 extracted from the 2-nd and 3-rd characters of S
  • 12 extracted from the 2-nd and 4-th characters of S
  • 1122 extracted from the 1-st through 4-th characters of S

Thus, output 5.

Note that two subsequences are counted separately if they are extracted from different positions, even if they are identical as strings.


Sample Input 2

2025

Sample Output 2

0

There may be no subsequence that is a 1122-string.


Sample Input 3

0777468889971

Sample Output 3

30
G - Substring Game

Time Limit: 3 sec / Memory Limit: 1024 MiB

配点 : 600

問題文

英小文字からなる文字列 S が与えられます。

Alice と Bob がこの文字列を使って以下のようなゲームを行います。

  • 空文字列 T を用意する。
  • Alice から始めて両者は交互に手番をプレイする。
  • 各手番では、プレイヤーは英小文字を一つ選び、 T の末尾に選んだ英小文字を連結させる。ただし、連結させた後の TS の部分文字列とならないような行動を取ることはできない。

先に手番をプレイできなくなったプレイヤーの負けです。

両者が最善を尽くしたとき、どちらのプレイヤーが勝つかを求めてください。

T 個のテストケースが与えられるので、それぞれについて答えを求めてください。

制約

  • 1\le T\le 10^5
  • T は整数
  • S は英小文字からなる長さ 1 以上 2\times 10^5 以下の文字列
  • 全てのテストケースにおける S の長さの総和は 4\times 10^5 以下

入力

入力は以下の形式で標準入力から与えられる。

T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T

各テストケースは以下の形式で与えられる。

S

出力

各テストケースに対する答えを順に改行区切りで出力せよ。

各テストケースについて、両者が最善を尽くしたとき Alice が勝つならば Alice を、Bob が勝つならば Bob を出力せよ。


入力例 1

4
ooxo
abrakadabra
atcoderbeginnercontest
baabca

出力例 1

Bob
Alice
Alice
Bob

1 番目のテストケースについて考えます。

例えば、ゲームは以下のように進行します。

  • Alice が x を選ぶ。 T= x となる。
  • Bob が o を選ぶ。 T= xo となる。
  • Alice がどの英小文字を選んで T の末尾に連結しても TS の部分文字列となることはないため、Alice は手番をプレイすることができない。この時点で Bob の勝ちとなる。

このテストケースは Alice がどのように手番をプレイしても Bob が勝つことができます。したがって、 Bob を出力してください。

Score : 600 points

Problem Statement

You are given a string S consisting of lowercase English letters.

Alice and Bob play the following game using this string.

  • Prepare an empty string T.
  • Starting with Alice, they take turns playing.
  • On each turn, the player chooses one lowercase English letter and concatenates the chosen letter to the end of T. Here, the player cannot take an action such that T after concatenation is not a substring of S.

The player who cannot make a move first loses.

Determine which player will win when both players play optimally.

You are given T test cases; solve each of them.

Constraints

  • 1\le T\le 10^5
  • T is an integer.
  • S is a string consisting of lowercase English letters with length between 1 and 2\times 10^5, inclusive.
  • The sum of the lengths of S over all test cases is at most 4\times 10^5.

Input

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

T
\text{case}_1
\text{case}_2
\vdots
\text{case}_T

Each test case is given in the following format.

S

Output

Output the answers for the test cases in order, separated by newlines.

For each test case, output Alice if Alice wins when both players play optimally, and Bob if Bob wins.


Sample Input 1

4
ooxo
abrakadabra
atcoderbeginnercontest
baabca

Sample Output 1

Bob
Alice
Alice
Bob

Consider the first test case.

For example, the game proceeds as follows.

  • Alice chooses x. T= x.
  • Bob chooses o. T= xo.
  • No matter which lowercase English letter Alice chooses and concatenates to the end of T, T will not be a substring of S, so Alice cannot make a move. At this point, Bob wins.

In this test case, Bob can win no matter how Alice plays. Therefore, output Bob.