A - Exact Price

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

高橋君の財布の中には 100 円硬貨が 1 枚以上入っており、それ以外には何も入っていません。

高橋君の財布の中の合計金額が X 円である可能性はありますか?

制約

  • 0 \leq X \leq 1000
  • 入力は全て整数

入力

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

X

出力

高橋君の財布の中の合計金額が X 円である可能性がある場合は Yes、そうでない場合は No と出力せよ。


入力例 1

500

出力例 1

Yes

財布に 100 円硬貨が 5 枚入っているとき、合計金額は 500 円になります。故に財布の中の合計金額は X=500 円になりうるため、Yes を出力します。


入力例 2

40

出力例 2

No

入力例 3

0

出力例 3

No

財布の中には 100 円硬貨が 1 枚以上入っていることに注意してください。

Score : 100 points

Problem Statement

Takahashi's purse has one or more 100-yen coins in it and nothing else. (Yen is the Japanese currency.)

Is it possible that the total amount of money in the purse is X yen?

Constraints

  • 0 \leq X \leq 1000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

X

Output

If it is possible that the total amount of money in Takahashi's purse is X yen, print Yes; otherwise, print No.


Sample Input 1

500

Sample Output 1

Yes

If the purse has five 100-yen coins, the total amount of money is 500 yen. Thus, it is possible that the total amount is X=500 yen, so we should print Yes.


Sample Input 2

40

Sample Output 2

No

Sample Input 3

0

Sample Output 3

No

Note that the purse has at least one 100-yen coin.

B - String Shifting

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

空でない文字列に対し、先頭の文字を末尾に移動する操作を左シフト、末尾の文字を先頭に移動する操作を右シフトと呼びます。

例えば、abcde に対して左シフトを 1 回行うと bcdea となり、右シフトを 2 回行うと deabc となります。

英小文字からなる空でない文字列 S が与えられます。S に対し左シフトと右シフトをそれぞれ好きな回数(0 回でもよい)行って得られる文字列のうち、辞書順で最小のものと最大のものを求めてください。

辞書順とは?

辞書順とは簡単に説明すると「単語が辞書に載っている順番」を意味します。より厳密な説明として、英小文字からなる相異なる文字列 S, T の大小を判定するアルゴリズムを以下に説明します。

以下では「 Si 文字目の文字」を S_i のように表します。また、 ST より辞書順で小さい場合は S \lt T 、大きい場合は S \gt T と表します。

  1. S, T のうち長さが大きくない方の文字列の長さを L とします。i=1,2,\dots,L に対して S_iT_i が一致するか調べます。
  2. S_i \neq T_i である i が存在する場合、そのような i のうち最小のものを j とします。そして、S_jT_j を比較して、S_jT_j よりアルファベット順で小さい場合は S \lt T 、そうでない場合は S \gt T と決定して、アルゴリズムを終了します。
  3. S_i \neq T_i である i が存在しない場合、ST の長さを比較して、ST より短い場合は S \lt T 、長い場合は S \gt T と決定して、アルゴリズムを終了します。

制約

  • S は英小文字からなる。
  • S の長さは 1 以上 1000 以下である。

入力

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

S

出力

2 行にわたって出力せよ。S に対し左シフトと右シフトをそれぞれ好きな回数(0 回でもよい)行って得られる文字列のうち、辞書順で最小のものと最大のものをそれぞれ S_{\min}, S_{\max} とおいたとき、1 行目には S_{\min} を、2 行目には S_{\max} を出力せよ。


入力例 1

aaba

出力例 1

aaab
baaa

操作によって、aaab , aaba , abaa , baaa4 通りの文字列を得ることができます。 これらのうち辞書順で最小、最大のものはそれぞれ aaab , baaa です。


入力例 2

z

出力例 2

z
z

どのように操作を行っても、得られる文字列は z のみです。


入力例 3

abracadabra

出力例 3

aabracadabr
racadabraab

Score : 200 points

Problem Statement

On a non-empty string, a left shift moves the first character to the end of the string, and a right shift moves the last character to the beginning of the string.

For example, a left shift on abcde results in bcdea, and two right shifts on abcde result in deabc.

You are given a non-empty S consisting of lowercase English letters. Among the strings that can be obtained by performing zero or more left shifts and zero or more right shifts on S, find the lexicographically smallest string and the lexicographically largest string.

What is the lexicographical order?

Simply speaking, the lexicographical order is the order in which words are listed in a dictionary. As a more formal definition, here is the algorithm to determine the lexicographical order between different strings S and T.

Below, let S_i denote the i-th character of S. Also, if S is lexicographically smaller than T, we will denote that fact as S \lt T; if S is lexicographically larger than T, we will denote that fact as S \gt T.

  1. Let L be the smaller of the lengths of S and T. For each i=1,2,\dots,L, we check whether S_i and T_i are the same.
  2. If there is an i such that S_i \neq T_i, let j be the smallest such i. Then, we compare S_j and T_j. If S_j comes earlier than T_j in alphabetical order, we determine that S \lt T and quit; if S_j comes later than T_j, we determine that S \gt T and quit.
  3. If there is no i such that S_i \neq T_i, we compare the lengths of S and T. If S is shorter than T, we determine that S \lt T and quit; if S is longer than T, we determine that S \gt T and quit.

Constraints

  • S consists of lowercase English letters.
  • The length of S is between 1 and 1000 (inclusive).

Input

Input is given from Standard Input in the following format:

S

Output

Print two lines. The first line should contain S_{\min}, and the second line should contain S_{\max}. Here, S_{\min} and S_{\max} are respectively the lexicographically smallest and largest strings obtained by performing zero or more left shifts and zero or more right shifts on S.


Sample Input 1

aaba

Sample Output 1

aaab
baaa

By performing shifts, we can obtain four strings: aaab, aaba, abaa, baaa. The lexicographically smallest and largest among them are aaab and baaa, respectively.


Sample Input 2

z

Sample Output 2

z
z

Any sequence of operations results in z.


Sample Input 3

abracadabra

Sample Output 3

aabracadabr
racadabraab
C - Doukasen

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300

問題文

N 本の導火線を一直線に接着したものがあります。左から i 本目の導火線は長さが A_i cm で、 1 秒あたり B_i cm の一定の速さで燃えます。

この導火線の左端と右端から同時に火をつけるとき、 2 つの火がぶつかる場所が着火前の導火線の左端から何 cm の地点か求めてください。

制約

  • 1 \leq N \leq 10^5
  • 1 \leq A_i,B_i \leq 1000
  • 入力は全て整数

入力

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

N
A_1 B_1
A_2 B_2
\vdots
A_N B_N

出力

2 つの火がぶつかる場所が着火前の導火線の左端から何 cm の地点か(単位を除いて)出力せよ。

想定解答との絶対誤差または相対誤差が 10^{-5} 以下であれば正解として扱われる。


入力例 1

3
1 1
2 1
3 1

出力例 1

3.000000000000000

着火前の導火線の左端から 3 cm の地点で 2 つの火がぶつかります。


入力例 2

3
1 3
2 2
3 1

出力例 2

3.833333333333333

入力例 3

5
3 9
1 2
4 6
1 5
5 3

出力例 3

8.916666666666668

Score : 300 points

Problem Statement

We have N fuses connected in series. The i-th fuse from the left has a length of A_i centimeters and burns at a constant speed of B_i centimeters per second.

Consider igniting this object from left and right ends simultaneously. Find the distance between the position where the two flames will meet and the left end of the object.

Constraints

  • 1 \leq N \leq 10^5
  • 1 \leq A_i,B_i \leq 1000
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
A_1 B_1
A_2 B_2
\vdots
A_N B_N

Output

Print the distance between the position where the two flames will meet and the left end of the object, in centimeters (print just the number).

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


Sample Input 1

3
1 1
2 1
3 1

Sample Output 1

3.000000000000000

The two flames will meet at 3 centimeters from the left end of the object.


Sample Input 2

3
1 3
2 2
3 1

Sample Output 2

3.833333333333333

Sample Input 3

5
3 9
1 2
4 6
1 5
5 3

Sample Output 3

8.916666666666668
D - Restricted Permutation

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 400

問題文

(1, 2, \dots, N) を並び替えて得られる数列 P であって以下の条件を満たすもののうち、辞書順で最小のものを求めてください。

  • i = 1, \dots, M に対し、P において A_iB_i よりも先に現れる。

ただし、そのような P が存在しない場合は -1 と出力してください。

制約

  • 2 \leq N \leq 2 \times 10^5
  • 1 \leq M \leq 2 \times 10^5
  • 1 \leq A_i, B_i \leq N
  • A_i \neq B_i
  • 入力は全て整数である。

入力

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

N M
A_1 B_1
\vdots
A_M B_M

出力

答えを出力せよ。


入力例 1

4 3
2 1
3 4
2 4

出力例 1

2 1 3 4

条件を満たす P(2, 1, 3, 4), (2, 3, 1, 4), (2, 3, 4, 1), (3, 2, 1, 4), (3, 2, 4, 1)5 つです。これらのうち辞書順で最小のものは (2, 1, 3, 4) です。


入力例 2

2 3
1 2
1 2
2 1

出力例 2

-1

条件を満たす P は存在しません。

Score : 400 points

Problem Statement

Among the sequences P that are permutations of (1, 2, \dots, N) and satisfy the condition below, find the lexicographically smallest sequence.

  • For each i = 1, \dots, M, A_i appears earlier than B_i in P.

If there is no such P, print -1.

Constraints

  • 2 \leq N \leq 2 \times 10^5
  • 1 \leq M \leq 2 \times 10^5
  • 1 \leq A_i, B_i \leq N
  • A_i \neq B_i
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
A_1 B_1
\vdots
A_M B_M

Output

Print the answer.


Sample Input 1

4 3
2 1
3 4
2 4

Sample Output 1

2 1 3 4

The following five permutations P satisfy the condition: (2, 1, 3, 4), (2, 3, 1, 4), (2, 3, 4, 1), (3, 2, 1, 4), (3, 2, 4, 1). The lexicographically smallest among them is (2, 1, 3, 4).


Sample Input 2

2 3
1 2
1 2
2 1

Sample Output 2

-1

No permutations P satisfy the condition.

E - Placing Rectangles

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 500

問題文

正整数 X, Y に対し、2 次元平面上において以下の条件を満たす長方形を良い長方形と呼びます。

  • 全ての辺は x 軸または y 軸に並行である。
  • 全ての頂点に対し、その x 座標は 0 以上 X 以下の整数であり、その y 座標は 0 以上 Y 以下の整数である。

面積がそれぞれ A 以上、B 以上、C 以上であるような 3 つの良い長方形を重ならないように配置することができるか判定してください。

ただし、3 つの長方形が重ならないとは、どの 2 つの長方形についても、それらの共通部分の面積が 0 であることを指します。

制約

  • 1 \leq X, Y \leq 10^9
  • 1 \leq A, B, C \leq 10^{18}
  • 入力は全て整数である。

入力

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

X Y A B C

出力

問題文で与えられた条件を満たすように長方形を配置することができるならば Yes、できないならば No と出力せよ。


入力例 1

3 3 2 2 3

出力例 1

Yes

下の図のように配置すればよいです。長方形内の数値は面積を表します。

2 \geq A, 3 \geq B, 3 \geq C であるので、問題文で与えられた条件を満たします。

image


入力例 2

3 3 4 4 1

出力例 2

No

条件を満たすように配置することはできません。


入力例 3

1000000000 1000000000 1000000000000000000 1000000000000000000 1000000000000000000

出力例 3

No

Score : 500 points

Problem Statement

For positive integers X and Y, a rectangle in a two-dimensional plane that satisfies the conditions below is said to be good.

  • Every edge is parallel to the x- or y-axis.
  • For every vertex, its x-coordinate is an integer between 0 and X (inclusive), and y-coordinate is an integer between 0 and Y (inclusive).

Determine whether it is possible to place the following three good rectangles without overlapping: a good rectangle of an area at least A, another of an area at least B, and another of an area at least C.

Here, three rectangles are considered to be non-overlapping when the intersection of any two of them has an area of 0.

Constraints

  • 1 \leq X, Y \leq 10^9
  • 1 \leq A, B, C \leq 10^{18}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

X Y A B C

Output

If it is possible to place three rectangles under the conditions specified in the Problem Statement, print Yes; otherwise, print No.


Sample Input 1

3 3 2 2 3

Sample Output 1

Yes

The figure below shows a possible placement, where the number in a rectangle represents its area.

We can see that 2 \geq A, 3 \geq B, 3 \geq C, satisfying the conditions.

image


Sample Input 2

3 3 4 4 1

Sample Output 2

No

There is no possible placement under the conditions.


Sample Input 3

1000000000 1000000000 1000000000000000000 1000000000000000000 1000000000000000000

Sample Output 3

No
F - Parenthesis Checking

Time Limit: 3 sec / Memory Limit: 1024 MiB

配点 : 500

問題文

以下のいずれかの条件を満たす文字列を正しい括弧列と定義します。

  • 空文字列
  • ある正しい括弧列 A が存在して、(, A, ) をこの順に連結した文字列
  • ある空でない正しい括弧列 A, B が存在して、A, B をこの順に連結した文字列

() のみからなる長さ N の文字列 S があります。

Q 個のクエリ \text{Query}_1,\text{Query}_2,\ldots,\text{Query}_Q が与えられるので、順番に処理してください。クエリには 2 種類があり、入力形式とクエリの内容は以下の通りです。

  • 1 l r : Sl 文字目と r 文字目を入れ替える。
  • 2 l r : Sl 文字目から r 文字目までの連続部分文字列が正しい括弧列であるか判定する。

制約

  • 1 \leq N,Q \leq 2 \times 10^5
  • S() のみからなる長さ N の文字列
  • 1 \leq l < r \leq N
  • N,Q,l,r はいずれも整数
  • 各クエリは 1 l r2 l r のいずれかの形式で与えられる。
  • 2 l r の形式のクエリは 1 つ以上与えられる。

入力

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

N Q
S
\text{Query}_1
\text{Query}_2
\vdots
\text{Query}_Q

出力

2 l r の形式の各クエリに対して、連続部分文字列が正しい括弧列である場合 Yes、そうでない場合 No と出力し、改行せよ。


入力例 1

5 3
(())(
2 1 4
2 1 2
2 4 5

出力例 1

Yes
No
No

1 つ目のクエリにおいて、(())正しい括弧列です。

2 つ目のクエリにおいて、((正しい括弧列ではありません。

3 つ目のクエリにおいて、)(正しい括弧列ではありません。


入力例 2

5 3
(())(
2 1 4
1 1 4
2 1 4

出力例 2

Yes
No

1 つ目のクエリにおいて、(())正しい括弧列です。

2 つ目のクエリによって、S)()(( となります。

3 つ目のクエリにおいて、)()(正しい括弧列ではありません。


入力例 3

8 8
(()(()))
2 2 7
2 2 8
1 2 5
2 3 4
1 3 4
1 3 5
1 1 4
1 6 8

出力例 3

Yes
No
No

Score : 500 points

Problem Statement

Let us define a correct parenthesis sequence as a string that satisfies one of the following conditions.

  • It is an empty string.
  • It is a concatenation of (, A, ), in this order, for some correct parenthesis sequence A.
  • It is a concatenation of A, B, in this order, for some correct parenthesis sequences A and B.

We have a string S of length N consisting of ( and ).

Given Q queries \text{Query}_1,\text{Query}_2,\ldots,\text{Query}_Q, process them in order. There are two kinds of queries, with the following formats and content.

  • 1 l r: Swap the l-th and r-th characters of S.
  • 2 l r: Determine whether the contiguous substring from the l-th through the r-th character is a correct parenthesis sequence.

Constraints

  • 1 \leq N,Q \leq 2 \times 10^5
  • S is a string of length N consisting of ( and ).
  • 1 \leq l < r \leq N
  • N,Q,l,r are all integers.
  • Each query is in the format 1 l r or 2 l r.
  • There is at least one query in the format 2 l r.

Input

Input is given from Standard Input in the following format:

N Q
S
\text{Query}_1
\text{Query}_2
\vdots
\text{Query}_Q

Output

For each query in the format 2 l r, print Yes if the contiguous substring is a correct parenthesis sequence, and No otherwise, followed by a newline.


Sample Input 1

5 3
(())(
2 1 4
2 1 2
2 4 5

Sample Output 1

Yes
No
No

In the first query, (()) is a correct parenthesis sequence.

In the second query, (( is not a correct parenthesis sequence.

In the third query, )( is not a correct parenthesis sequence.


Sample Input 2

5 3
(())(
2 1 4
1 1 4
2 1 4

Sample Output 2

Yes
No

In the first query, (()) is a correct parenthesis sequence.

In the second query, S becomes )()((.

In the third query, )()( is not a correct parenthesis sequence.


Sample Input 3

8 8
(()(()))
2 2 7
2 2 8
1 2 5
2 3 4
1 3 4
1 3 5
1 1 4
1 6 8

Sample Output 3

Yes
No
No
G - Vertex Deletion

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 600

問題文

N 頂点の木が与えられます。頂点には 1,2,\ldots ,N の番号がついており、i\,(1 \leq i \leq N-1) 本目の辺は頂点 u_i と頂点 v_i を結んでいます。

以下の条件を満たす整数 i\,(1 \leq i \leq N) の個数を求めてください。

  • 元の木から頂点 i およびそれに接続する全ての辺を削除して得られるグラフの最大マッチングの大きさが、元の木の最大マッチングの大きさに等しい。

制約

  • 2 \leq N \leq 2 \times 10^5
  • 1 \leq u_i < v_i \leq N
  • 与えられるグラフは木
  • 入力は全て整数

入力

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

N
u_1 v_1
u_2 v_2
\vdots
u_{N-1} v_{N-1}

出力

答えを出力せよ。


入力例 1

3
1 2
2 3

出力例 1

2

元の木の最大マッチングの大きさは 1 です。

頂点 1 およびそれに接続する全ての辺を削除して得られるグラフの最大マッチングの大きさは 1

頂点 2 およびそれに接続する全ての辺を削除して得られるグラフの最大マッチングの大きさは 0

頂点 3 およびそれに接続する全ての辺を削除して得られるグラフの最大マッチングの大きさは 1

です。i=1,32 つが条件を満たすので、2 を出力します。


入力例 2

2
1 2

出力例 2

0

入力例 3

6
2 5
3 5
1 4
4 5
4 6

出力例 3

4

Score : 600 points

Problem Statement

Given is a tree with N vertices. The vertices are numbered 1,2,\ldots,N, and the i-th edge (1 \leq i \leq N-1) connects Vertex u_i and Vertex v_i.

Find the number of integers i (1 \leq i \leq N) that satisfy the following condition.

  • The size of the maximum matching of the graph obtained by deleting Vertex i and all incident edges from the tree is equal to the size of the maximum matching of the original tree.

Constraints

  • 2 \leq N \leq 2 \times 10^5
  • 1 \leq u_i < v_i \leq N
  • The given graph is a tree.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
u_1 v_1
u_2 v_2
\vdots
u_{N-1} v_{N-1}

Output

Print the answer.


Sample Input 1

3
1 2
2 3

Sample Output 1

2

The size of the maximum matching of the original tree is 1.

The size of the maximum matching of the graph obtained by deleting Vertex 1 and all incident edges from the tree is 1.

The size of the maximum matching of the graph obtained by deleting Vertex 2 and all incident edges from the tree is 0.

The size of the maximum matching of the graph obtained by deleting Vertex 3 and all incident edges from the tree is 1.

Thus, two integers i=1,3 satisfy the condition, so we should print 2.


Sample Input 2

2
1 2

Sample Output 2

0

Sample Input 3

6
2 5
3 5
1 4
4 5
4 6

Sample Output 3

4
H - Xor Query

Time Limit: 3 sec / Memory Limit: 1024 MiB

配点 : 600

問題文

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

Q 個のクエリを処理してください。i \, (1 \leq i \leq Q) 番目のクエリでは、A_{L_i}, A_{L_i + 1}, \dots, A_{R_i} から 1 つ以上の要素を選び、それらの排他的論理和を X_i にできるかどうか判定してください。

排他的論理和とは

整数 a, b のビットごとの排他的論理和 a\ \mathrm{xor}\ b は、以下のように定義されます。

  • a\ \mathrm{xor}\ b を二進表記した際の 2^k \, (k \geq 0) の位の数は、a, b を二進表記した際の 2^k の位の数のうち一方のみが 1 であれば 1、そうでなければ 0 である。
例えば、3\ \mathrm{xor}\ 5 = 6 となります(二進表記すると: 011\ \mathrm{xor}\ 101 = 110)。

制約

  • 1 \leq N \leq 4 \times 10^5
  • 1 \leq Q \leq 2 \times 10^5
  • 1 \leq A_i \lt 2^{60}
  • 1 \leq L_i \leq R_i \leq N
  • 1 \leq X_i \lt 2^{60}
  • 入力は全て整数である。

入力

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

N Q
A_1 \ldots A_N
L_1 R_1 X_1
\vdots
L_Q R_Q X_Q

出力

Q 行にわたって出力せよ。i \, (1 \leq i \leq Q) 行目には、A_{L_i}, A_{L_i + 1}, \dots, A_{R_i} から 1 つ以上の要素を選び、それらの排他的論理和を X_i にできるならば Yes と、できないならば No と出力せよ。


入力例 1

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

出力例 1

Yes
No

1 つ目のクエリでは、A_1, A_3 を選ぶことで排他的論理和を 7 にすることができます。

2 つ目のクエリでは、どのように要素を選んでも排他的論理和を 7 にすることはできません。


入力例 2

10 10
8 45 56 9 38 28 33 5 15 19
10 10 53
3 8 60
1 10 29
5 7 62
3 7 51
8 8 52
1 4 60
6 8 32
4 8 58
5 9 2

出力例 2

No
No
Yes
No
Yes
No
No
No
Yes
Yes

Score : 600 points

Problem Statement

Given is a sequence of N positive integers A = (A_1, \dots, A_N).

Process Q queries. In the i-th query (1 \leq i \leq Q), determine whether it is possible to choose one or more elements from A_{L_i}, A_{L_i + 1}, \dots, A_{R_i} so that their \mathrm{XOR} is X_i.

What is \mathrm{XOR}?

The bitwise \mathrm{XOR} of integers A and B, A\ \mathrm{XOR}\ B, is defined as follows:

  • When A\ \mathrm{XOR}\ B is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if exactly one of A and B is 1, and 0 otherwise.
For example, we have 3\ \mathrm{XOR}\ 5 = 6 (in base two: 011\ \mathrm{XOR}\ 101 = 110).

Constraints

  • 1 \leq N \leq 4 \times 10^5
  • 1 \leq Q \leq 2 \times 10^5
  • 1 \leq A_i \lt 2^{60}
  • 1 \leq L_i \leq R_i \leq N
  • 1 \leq X_i \lt 2^{60}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N Q
A_1 \ldots A_N
L_1 R_1 X_1
\vdots
L_Q R_Q X_Q

Output

Print Q lines. The i-th line (1 \leq i \leq Q) should contain Yes if it is possible to choose one or more elements from A_{L_i}, A_{L_i + 1}, \dots, A_{R_i} so that their \mathrm{XOR} is X_i, and No otherwise.


Sample Input 1

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

Sample Output 1

Yes
No

In the first query, you can choose A_1 and A_3, whose \mathrm{XOR} is 7.

In the second query, there is no way to choose elements so that their \mathrm{XOR} is 7.


Sample Input 2

10 10
8 45 56 9 38 28 33 5 15 19
10 10 53
3 8 60
1 10 29
5 7 62
3 7 51
8 8 52
1 4 60
6 8 32
4 8 58
5 9 2

Sample Output 2

No
No
Yes
No
Yes
No
No
No
Yes
Yes