Larry is a large nerd, and thus likes nerdy things. Larry has two arrays of length : and . Larry considers some sequence of integers nerdy if:
. The sequence is increasing.
Popcount for all , where & is bitwise and, and Popcount is the number of one bits in the binary representation of its argument.
Find the longest nerdy sequence.
Input Specification
The first line will contain one integer .
The second line will contain integers .
The last line will contain integers .
Output Specification
On the first line you are to output one integer, the length of the longest nerdy sequence.
On the next line you are to print any such longest sequence, separated by spaces.
Subtasks
Subtask 1 (7%)
Subtask 2 (16%)
Subtask 3 (17%)
Subtask 4 (60%)
No further constraints.
Sample Input
5
5 3 5 3 5
10 1 20 1 20
Sample Output
2
1 2
Comments