B - Taro Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 200

問題文

AtCoder 王国では、長男に必ず「太郎」という名前を付けます。長男以外には「太郎」という名前は付けません。 長男とは、各家で生まれた男の子のうち最も早く生まれた者を指します。

AtCoder 王国には N 戸の家があり、M 人の赤子が生まれました。また、M 人の赤子が生まれる前には、N 戸のどの家も赤子が生まれたことはありませんでした。

赤子の情報が生まれの時系列順に与えられます。

i 番目に生まれた赤子は、A_i 番目の家で生まれ、B_iM のとき男の子、F のとき女の子です。

M 人の赤子それぞれについて、付けられた名前が「太郎」か判定してください。

制約

  • 1\leq N,M\leq 100
  • 1\leq A_i\leq N
  • B_iM または F
  • 入力される数値は全て整数

入力

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

N M
A_1 B_1
\vdots
A_M B_M

出力

M 行出力せよ。

i\ (1\leq i \leq M) 行目には、i 番目に生まれた赤子の名前が「太郎」ならば Yes を、そうでない場合 No を出力せよ。


入力例 1

2 4
1 M
1 M
2 F
2 M

出力例 1

Yes
No
No
Yes

1 番目に生まれた赤子は、家 1 で生まれた男の子のうち最も早く生まれた者なので「太郎」です。

一方、2 番目に生まれた赤子は、家 1 で生まれた男の子のうち最も早く生まれた者ではないので「太郎」ではありません。

3 番目に生まれた赤子は、女の子なので「太郎」ではありません。

4 番目に生まれた赤子は、家 2 で生まれた男の子のうち最も早く生まれた者なので「太郎」です。3 番目に生まれた赤子も家 2 で生まれていますが、男の子のうち最も早く生まれた者を「太郎」と名付けることに注意してください。


入力例 2

4 7
2 M
3 M
1 F
4 F
4 F
1 F
2 M

出力例 2

Yes
Yes
No
No
No
No
No

Score : 200 points

Problem Statement

In the Kingdom of AtCoder, the eldest son is always given the name Taro. No one else is given the name Taro. The eldest son is the earliest born male child in each family.

There are N families in the Kingdom, and M babies were born. Before the M babies were born, none of the N families had had any babies.

Information about the babies is given in chronological order of their birth.

The i-th baby born was born in family A_i, and the baby is male if B_i is M, and female if it is F.

Determine for each of the M babies whether the name given is Taro.

Constraints

  • 1\leq N,M\leq 100
  • 1\leq A_i\leq N
  • B_i is M or F.
  • All numbers in the input are integers.

Input

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

N M
A_1 B_1
\vdots
A_M B_M

Output

Print M lines.

The i-th line (1\leq i \leq M) should contain Yes if the name given to the i-th baby is Taro, and No otherwise.


Sample Input 1

2 4
1 M
1 M
2 F
2 M

Sample Output 1

Yes
No
No
Yes

The first baby is the earliest born boy in family 1, so he is named Taro.

The second baby is not the earliest born boy in family 1, so he is not named Taro.

The third baby is a girl, so she is not named Taro.

The fourth baby is the earliest born boy in family 2, so he is named Taro. Note that the third baby is also born in family 2, but it is the earliest born boy who is named Taro.


Sample Input 2

4 7
2 M
3 M
1 F
4 F
4 F
1 F
2 M

Sample Output 2

Yes
Yes
No
No
No
No
No