Restricted Arrays

아직 제출이 없습니다시간 제한4초메모리 제한256 MB

문제

Let nn be a positive integer. Find the number of integers 1Mn1 \le M \le n for which there exists an array of integers a\[1..n]a\[1..n] that satisfies the following conditions: a\[x_i]+1a\[y_i](modM),1iq.a\[x\_i] + 1 \equiv a\[y\_i] \pmod{M} , \quad 1 \le i \le q *.*

입력

The first line contains two integers, nn and qq: the array size and the number of conditions (1n,q1061\le n, q \le 10^6).

Each of the next qq lines contains two integers, x_ix\_i and y_iy\_i: the indices describing the corresponding condition (1x_i,y_in1 \le x\_i, y\_i \le n).

출력

On the first line, print an integer tt: the number of possible values of MM. On the second line, print the tt possible values of MM in increasing order.