Under construction

Still being built. Things may change

One Number Hint

Time limit1sMemory limit256 MB

Summary
Implement two fixed rules over 6-element subsets of 1 to 12: output the smallest element in S(x) missing from S(y), and answer yes when h lies in S(q).
Level

Easy3 of 10

Topics
Combinatorics, Implementation
Solved
No attempts yet

Problem

A and B want to get into a locked research laboratory. The entrance runs a security system that asks one question. The question is written as an integer qq with 1≤q≤N1 \le q \le N, and it must be answered with either yes or no. A correct answer opens the door, and a wrong answer sets off the alarm.

Both of them know that qq is always either xx or yy, where x≠yx \ne y, the correct answer to xx is yes, and the correct answer to yy is no.

While they were planning, neither could recall the actual values of xx and yy. So B walks up to the entrance alone and A waits far away. The moment the question appears, A remembers xx and yy. From that distance A cannot explain anything to B. A can only shout one integer hh. Everything B needs has to fit into that single hh.

Write a program that plays both parts. In the first run it reads NN, xx, yy and prints the number hh that A shouts. In the second run it reads NN, qq, hh and prints the answer B should give.

The two runs are judged separately, so the rule that turns (x,y)(x, y) into hh and the rule that turns (q,h)(q, h) into an answer are both fixed here.

The subset table. Take every 6-element subset of {1,2,…,12}\{1, 2, \dots, 12\}, write each subset as its elements in increasing order, and sort those sequences lexicographically. There are 924 such subsets. Let S(v)S(v) be the vv-th subset in this order, counting from 1. The first four are S(1)={1,2,3,4,5,6}S(1) = \{1,2,3,4,5,6\}, S(2)={1,2,3,4,5,7}S(2) = \{1,2,3,4,5,7\}, S(3)={1,2,3,4,5,8}S(3) = \{1,2,3,4,5,8\} and S(4)={1,2,3,4,5,9}S(4) = \{1,2,3,4,5,9\}, and the last one is S(924)={7,8,9,10,11,12}S(924) = \{7,8,9,10,11,12\}.

The number A shouts. For a pair (x,y)(x, y), hh is the smallest number that belongs to S(x)S(x) and not to S(y)S(y). Two different subsets of the same size never contain one another, so such a number always exists.

The answer B gives. For a pair (q,h)(q, h), the answer is yes if h∈S(q)h \in S(q), and no otherwise.

Input

The first line contains a single integer, either 1 or 2.

If it is 1, the program plays A. The second line contains NN and TT. The ii-th of the next TT lines contains xx and yy (1≤x,y≤N1 \le x, y \le N, x≠yx \ne y).

If it is 2, the program plays B. The second line contains NN and TT. The ii-th of the next TT lines contains qq and hh (1≤q≤N1 \le q \le N, 1≤h≤121 \le h \le 12).

Output

If the program plays A, print TT lines. The ii-th line holds the number hh for test case ii, computed by the rule above.

If the program plays B, print TT lines. The ii-th line holds the answer for test case ii, computed by the rule above, written as yes or no.

Constraints

In every test case 1≤N≤9201 \le N \le 920 and 1≤T≤10 0001 \le T \le 10\,000.

Examples2

  1. Example 1

    Input
    1
    5 6
    1 2
    4 5
    1 2
    3 5
    4 5
    5 2
    
    Expected output
    6
    9
    6
    8
    9
    10
    
  2. Example 2

    Input
    2
    5 6
    1 12
    4 2
    2 12
    3 4
    5 2
    2 1
    
    Expected output
    no
    yes
    no
    yes
    yes
    yes