Sinchon Regional Middle and High School Student Programming Contest Club Joint Competition
Time limit1sMemory limit1024 MB
Fill the empty seats with ages 8 to 19 so every AND or OR constraint between two seats holds, or report that no arrangement exists.
- Level
Medium7 of 10
- Topics
- Bit manipulation, Graph, Implementation
- Solved
- No attempts yet
Problem
Following the success of SUAPC, Yeondu is planning the "Sinchon Regional Middle and High School Student Programming Contest Club Joint Competition". Any student aged to who attends an elementary, middle, or high school in Sinchon can take part.
Yeondu firmly believes in his own feng shui and Four Pillars theories, which are based on computer science. He thinks the seating arrangement by age is critical to a successful contest. The data he built from his Yin-Yang Bitron theory states, for the seats at positions and , the value the bitwise AND or bitwise OR of the two participants' ages must produce.
Kakao, which joined SUAPC 2021 Winter and is also a sponsor of this contest, asked for a favor. They want specific ages seated at a few chosen seats. Yeondu does not want to refuse the sponsor. He wants to know whether the remaining empty seats can be filled with suitable ages so that all of his data is satisfied. He already has many students aged to . Arrange the seats for him while he is busy preparing the contest.
Input
The input is given in the following format.
Output
If you can fill the empty seats with participants aged to so that all of Yeondu's data is satisfied, print on the first line. On the next line, print the ages of the participants seated at seat , seat , , seat , separated by spaces. If several arrangements are valid, print any one of them.
If no such arrangement exists, print on the first line.
Constraints
-
is the number of seats. ()
-
or
- If , seat is empty.
- If , the participant seated at seat is years old.
-
is the number of data items. ()
-
is
&or|.- If is
&, the bitwise AND of the ages of the participants at seats and must be . - If is
|, the bitwise OR of the ages of the participants at seats and must be .
- If is
-
,
-
-
All numbers in the input are integers.