CF BUDDY
← Problems·

1811D · Umka and a Long Flight

1600 · constructive algorithms, implementation, math

Problem: The girl Umka loves to travel and participate in math olympiads. One day she was flying by plane to the next olympiad and out of boredom explored a huge checkered sheet of paper.

Denote the nn-th Fibonacci number as Fn={1,n=0;1,n=1;Fn2+Fn1,n2.F_n = \begin{cases} 1, & n = 0; \\ 1, & n = 1; \\ F_{n-2} + F_{n-1}, & n \ge 2. \end{cases}

A checkered rectangle with a height of FnF_n and a width of Fn+1F_{n+1} is called a Fibonacci rectangle of order nn.

Umka has a Fibonacci rectangle of order nn. Someone colored a cell in it at the intersection of the row xx and the column yy.

It is necessary to cut this rectangle exactly into n+1n+1 squares in such way that

  • the painted cell was in a square with a side of 11;
  • there was at most one pair of squares with equal sides;
  • the side of each square was equal to a Fibonacci number.

Will Umka be able to cut this rectangle in that way?

Input Format: The first line contains an integer tt (1t21051 \le t \le 2 \cdot 10^5) — number of test cases.

For each test case the integers nn, xx, yy are given (1n441 \le n \le 44, 1xFn1 \le x \le F_n, 1yFn+11 \le y \le F_{n+1}) — the order of the Fibonacci rectangle and the coordinates of the colored cell.

Output Format: For each test case, print "YES" if the answer is positive, and "NO" otherwise.

You can print "YES" and "NO" in any case (for example, the strings "yEs", "yes" and "Yes" will be recognized as a positive answer).

Note: The first, third and fourth test cases.

Sample Cases

Case 1

Input

12
1 1 1
2 1 2
3 1 4
3 3 2
4 4 6
4 3 3
5 6 5
5 4 12
5 2 12
4 2 1
1 1 2
44 758465880 1277583853

Output

YES
NO
YES
YES
YES
NO
YES
NO
NO
YES
YES
NO

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback