logo AlgoBeat OnlineJudge
登录 注册

#215810. [JAG 2024 Summer Camp #3] Equal or Not Equal

内存限制:1024 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

There are integer variables . All the initial values are unspecified. You have to process events in order, each of which is an observation event, a change event or an inquiry event.

One kind of an observation event has the format,

which represents that it is observed that and are equal. In other words, after this event it is guaranteed that these two variables have the same value unless there is a change event for either variable.

The other kind of an observation event has the format,

which represents that it is observed that and are not equal.

A change event has the format,

which represents that the value of changes to a different integer.

Finally, an inquiry event has the format,

which asks whether and are equal. If it can be proven from all the past events that and are equal, you have to print Yes. Similarly, if it can be proven that and are not equal, you have to print No. If neither can be proven, you have to print Unknown.

输入格式

The input consists of a single test case of the following format, where all values in the input are integers.

The integer is the number of variables (). The integer is the number of events (). events are given in chronological order. The format of each event is explained above. In an observation event or an inquiry event, it is guaranteed that . In a change event it is guaranteed that .

At any point, it is guaranteed that there is at least one assignment to all variables that contradicts none of the given information.

输出格式

For each inquiry event, print Yes, No or Unknown followed by a newline.

样例

样例输入 1

4 11
1 1 2
4 1 2
2 3 4
4 3 4
4 1 3
1 1 3
4 1 3
4 1 4
3 1
4 1 3
4 1 4

样例输出 1

Yes
No
Unknown
Yes
No
No
Unknown