Learn DSADSAContests
coding75 logo
LeetCode POTDPOTDSheets
coding75 Pro
coding75 logo
Dashboard
Learn DSA
Course RoadmapFlow
DSA Topic TreeNew πŸš€
Contest SolutionsPractice
Practice Sheets
MasterclassesLive πŸ‘¨πŸ»β€πŸ’»

coding75 ProPRO

Live Classes & Placement Guidance

coding75 logo

The premier developer platform for mastering Data Structures & Algorithms, exploring contest editorials, building ATS-ready resumes, and accelerating your tech career.

Connect & Community

DSA & Contests

  • Learn DSA
  • Contest Solutions
  • LeetCode POTDDaily
  • Practice Sheets
  • MasterclassesSoon

Interview Prep

  • Portfolio Projects
  • CS Fundamentals
  • System DesignSoon
  • Interview ExperiencesSoon
  • Mock InterviewsSoon

Career & Pro

  • Jobs & Internships
  • Resume BuilderATS
  • coding75 Pro
  • Submit Feedback
Β© 2026coding75β€’crackDSAβ„’β€’Maa Lalita Edtech Private Limited. All Rights Reserved.
Privacy PolicyTerms & ConditionsContact Support
Registered Office: Kanpur 208021β€’Regional Office: Indiranagar, Bangalore, 560008
Maa Lalita Edtech Private Limited
Contests/Codeforces/Codeforces Round 1057/B. Bitwise Reversion
PrevNext
CodeforcesCodeforces
Pupil
Codeforces Round 1057

B. Bitwise Reversion

GreedyBit ManipulationBitmaskMath
Loading...
Solve on Codeforces

Problem Statement

Official algorithmic problem description and constraints.

Open on Codeforces

You are given three non-negative integers π‘₯

, π‘¦

 and π‘§

. Determine whether there exist three non-negative integers π‘Ž

, π‘

 and π‘

 satisfying the following three conditions:

  • π‘Ž&𝑏=π‘₯
  • 𝑏&𝑐=𝑦
  • π‘Ž&𝑐=𝑧

where &

 denotes the bitwise AND operation.

Input


Each test contains multiple test cases. The first line contains the number of test cases π‘‘

 (1≀𝑑≀10

4

). The description of the test cases follows.

The first and only line of each test case contains three integers π‘₯

, π‘¦

 and π‘§

 (0≀π‘₯,𝑦,𝑧≀10

9

) β€” the target values of π‘Ž&𝑏

, π‘&𝑐

 and π‘Ž&𝑐

, respectively.

Output


For each test case, output "YES" if there exists three non-negative integers π‘Ž

, π‘

, and π‘

 satisfying the above conditions, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Example

Input

Copy

5
1 1 1
3 2 6
4 8 12
9 10 12
12730 3088 28130

Output

Copy

YES
YES
NO
YES
NO

Note


In the first test case, π‘Ž=3

, π‘=5

, and π‘=9

 satisfies the condition as 3&5=1

, 5&9=1

, and 3&9=1

.

In the second test case, π‘Ž=7

, π‘=3

, and π‘=22

 satisfies the condition as 7&3=3

, 3&22=2

, and 7&22=6

.

In the third test case, it can be proven that there are no three non-negative integers π‘Ž

, π‘

, and π‘

 such that π‘Ž&𝑏=4

, π‘&𝑐=8

, and π‘Ž&𝑐=12

.

Solutions & Walkthrough

Detailed video explanations, mathematical intuition, and clean C++ implementation code.

Connecting secure classroom stream...
Back to Codeforces Round 1057
Previous ProblemNext Problem