#SGM0000041. Mảng thú vị (Interesting Array)
Mảng thú vị (Interesting Array)
Interesting Array
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Construct a non-negative integer array whose bitwise AND on every constrained range equals the required value, or report impossibility.
Input
The first line contains . Each of the next lines contains , requiring $a_{l_i}\mathbin{\&}a_{l_i+1}\mathbin{\&}\cdots\mathbin{\&}a_{r_i}=q_i$.
Output
Print NO if no array exists. Otherwise print YES and then values satisfying every constraint. Multiple answers are allowed and are checked by a special checker.
Subtasks
- 20 points: .
- 30 points: .
- 50 points: , , .
Examples
Input
3 1
1 3 3
Output
YES
3 3 3
Explanation
The only constraint requires the AND of all three positions to be 3. Array 3 3 3 is valid because . Other valid arrays may also exist.