## Larry and Nerdiness

View as PDF

Points: 15 (partial)
Time limit: 4.0s
Memory limit: 256M

Problem types

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.

No further constraints.

#### Sample Input

5
5 3 5 3 5
10 1 20 1 20

#### Sample Output

2
1 2