The evil professor has just given you the following task. Let us define a sequence as follows:
For each given value of , compute x_i.
The input consists of multiple lines, each containing one integer (0 \leq i \leq 10^6). The last line contains and should not be processed.
For each value of (except the last ), print the corresponding value of x_i modulo 10^6.
Example 1