#abc371b. B - Taro

B - Taro

Score : 200200 points

问题陈述

在AtCoder王国中,长子总是被命名为太郎。没有人被命名为太郎。长子是每个家庭中最早出生的男性孩子。

AtCoder王国有NN个家庭,并且有MM个婴儿出生。在MM个婴儿出生之前,NN个家庭都没有孩子。

关于婴儿的信息是按照他们出生的顺序给出的。

ii个出生的婴儿出生在家庭AiA_i,如果BiB_iM,那么这个婴儿是男性,如果是F,那么是女性。

确定MM个婴儿中每一个是否被命名为太郎。

以上为大语言模型 kimi 翻译,仅供参考。

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 NN families in the Kingdom, and MM babies were born. Before the MM babies were born, none of the NN families had had any babies.

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

The ii-th baby born was born in family AiA_i, and the baby is male if BiB_i is M, and female if it is F.

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

Constraints

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

Input

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

NN MM

A1A_1 B1B_1

\vdots

AMA_M BMB_M

Output

Print MM lines.

The ii-th line (1iM)(1\leq i \leq M) should contain Yes if the name given to the ii-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 11, so he is named Taro.

The second baby is not the earliest born boy in family 11, 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 22, so he is named Taro. Note that the third baby is also born in family 22, 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