ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

## 2079. Memory leaks

Time limit: 0.5 second
Memory limit: 256 MB
Ural programmers are scattered around the whole world. Programmer Alexey, for example, lives in the Valley and develops C++ program debugging tools at Google.
One of his concerns is predicting possible memory leaks.
Alexey has scrutinized the occurring issues for long and has reached an understanding that memory leak happens when and only when the system comes into the following state: zero and first memory register contain values 0 and 1 correspondingly, and values at other registers are related according to the equation xn = (xn−1 + xn−2mod p, where nn−1, n−2 are memory register numbers.
If Alexey’s program finds a value xi at a register i, it considers current situation hazardous and reads the value of the next register i+1 just to be safe. If it matches xi+1, the situation is considered Extremely Hazardous.
Once upon a time Alexey’s program failed, the input was x — the value of some register, but the number of the register was not identified. Find out whether a hazardous situation is possible. if yes, find all possible values of register number k which will cause a hazardous situation, and for each k find the value yk of the next register leading the program to consider the situation Extremely Hazardous.
Notice, that there are powerful servers at Google, with 10100 memory registers.

### Input

The first line contains two integer numbers p (2 ≤ p < 109) and x (0 ≤ x < p). It is guaranteed that p is a prime number.

### Output

If the situation may be hazardous, in the first line output the number of different values of yk. In the second line list these values in an ascending order separated by space.
If the situation cannot be hazardous, in the only line output number 0.

inputoutput
```7 0
```
```2
1 6
```
```7 3
```
```1
5
```
```11 4
```
```0
```