QOJ.ac

QOJ

Limite de temps : 1.0 s Limite de mémoire : 256 MB Points totaux : 100 Hackable ✓

#12562. AND-OR Game

Statistiques

gsh loves bitwise operations! Today, he is playing a game against an AI.

The rules of the game are as follows:

  • gsh and the AI take turns, with gsh going first.
  • They operate on two non-negative integers $a$ and $b$. gsh's goal is to transform them into the target non-negative integers $x$ and $y$, while the AI tries to prevent gsh from achieving this goal.
  • On his turn, gsh can perform one of the following two operations:
    1. $a := a \& v$ (bitwise AND with some non-negative integer $v$).
    2. $b := b \mid v$ (bitwise OR with some non-negative integer $v$).
  • On its turn, the AI can perform one of the following two operations:
    1. $a := a \mid v$ (bitwise OR with some non-negative integer $v$).
    2. $b := b \& v$ (bitwise AND with some non-negative integer $v$).
  • The chosen $v$ must satisfy $0 \le v < 2^{60}$.
  • Both sides are sufficiently intelligent and will adopt optimal strategies to win the game.
  • If, within $10^{100}$ turns, there exists a moment where $a = x$ and $b = y$, then gsh wins; otherwise, the AI wins.

Determine whether gsh has a winning strategy. If he does, output Yes; otherwise, output No.

Input

The first line contains an integer $T$ ($1 \le T \le 10^5$), representing the number of test cases.

Each test case consists of a single line containing four non-negative integers $a, b, x, y$ ($0 \le a, b, x, y < 2^{60}$).

Output

For each test case, output a single line containing the string Yes or No.

Examples

Input 1

4
3 6 3 6
7 4 5 4
5 4 3 4
2 4 3 5

Output 1

Yes
Yes
No
No

Note

For the first test case, the initial state already satisfies $a = x$ and $b = y$, so gsh wins.

For the second test case, gsh performs the operation $a := a \& 5$, reaching the target, so gsh wins.

For the third and fourth test cases, it is not difficult to prove that the target can never be reached, so gsh loses.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.