## GlobeX Cup '18 S3 - Playing With Bits

View as PDF

Points: 10 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem types

August is doing his binary math homework. While doing it, he came up with a problem, and thought it would be a good problem to put on the GlobeX Canada Cup.

August gives you 3 questions. Given the integers and , how many ways are there to make an integer array of length where such that:

?
?
?

Note that:

• denotes the bitwise xor operation (^ in most languages).
• denotes the bitwise or operation (| in most languages).
• denotes the bitwise and operation (& in most languages).

Since August has meganumerophobia, he wants the answer to each question modulo .

#### Input Specification

The first line and only line will contain space-separated integers .

#### Output Specification

On the first line, output the answer to question modulo .
On the second line, output the answer to question modulo .
On the last line, output the answer to question modulo .

No further constraints.

#### Sample Input 1

2 1000000007 3 5

#### Sample Output 1

8
9
3

#### Sample Input 2

8 1000000007 1 0

#### Sample Output

128
1
255