&+ +&

Over all N^2 pairs, compute the sum modulo 1999 of pairwise ANDs, and the bitwise AND of all pairwise sums.

Medium5Bit manipulationMathImplementationNo attempts yetTime limit1.5sMemory limit512 MB

Problem

Two positive integer sequences of length NN are given: A1,A2,,ANA_1, A_2, \dots, A_N and B1,B2,,BNB_1, B_2, \dots, B_N. For every ordered pair (i,j)(i, j) with 1iN1 \le i \le N and 1jN1 \le j \le N, compute the following two values.

  • The remainder of the sum of all (Ai&Bj)(A_i \mathbin{\&} B_j) divided by 19991999
  • The bitwise AND of all (Ai+Bj)(A_i + B_j) values

&\mathbin{\&} is bitwise AND. Its definition is in the Hint section.

Input

The first line gives the sequence length NN (1N1061 \le N \le 10^6). The second line gives NN integers of sequence AA, separated by spaces, and the third line gives NN integers of sequence BB, separated by spaces. Every element of AA and BB is a positive integer with 1Ai,Bi2281 \le A_i, B_i \le 2^{28}.

Output

Print the two values described above on the first line, separated by a space, in order.

Hint

Bitwise AND applies to each binary digit. Write both operands in binary first, then set a digit to 11 only when both operands have 11 there, and to 00 otherwise.

As an illustration, 13&7=513 \mathbin{\&} 7 = 5. Here 1313 is 110121101_2 in binary and 77 is 1112111_2. After aligning digits to 110121101_2 and 011120111_2, the digitwise AND is 010120101_2, which equals 55 in decimal.