## Task Description

You are given two integer sequences $X(t)$ and $Y(t)$ for $t$ = 0, 1, 2, .... Sequence $X(t)$ is generated by the formula $X(t+1) = (aX(t) + b) \pmod c$. And sequence $Y(t)$ is generated by the formula $Y(t+1) = (dY(t) + e) \pmod f$. $a$, $b$, $c$, $d$, $e$, and $f$ are positive integers.

Write a program to play $\textit{paper}$, $\textit{scissors}$, $\textit{stone}$ with the two integer sequences. For any integer $X$, we can determine whether $X$ is $\textit{paper}$, $\textit{scissors}$, or $\textit{stone}$ with the value of $X \bmod 3$. $X$ is $paper$ when the value of $X \bmod 3$ is 0. $X$ is $\textit{scissors}$ when the value of $X \bmod 3$ is 1. And $X$ is $stone$ when the value of $X \bmod 3$ is 2. $\textit{Scissors}$ beat $\textit{paper}$, $\textit{stone}$ beats $\textit{scissors}$, and $\textit{paper}$ beats $\textit{stone}$.

We will have many rounds of games by two players. In a round of game, we pick a new integer pair $(X(t)$, $Y(t))$ from each sequence and check which player wins. We keep picking new integer pairs until one player wins this round.

For example, $X(0)$ is 4 , and $X(t+1) = (5X(t) + 6) \bmod 7$. Also $Y(0)$ is 6, and $Y(t+1) = (5Y(t) + 4) \bmod 3$. We play three rounds. In the first round, we pick $(X(0)$, $Y(0)) = (4$, $6)$. $X(0)$ is $\textit{scissors}$, $Y(0)$ is $\textit{paper}$, so $X$ wins this round. In the second round, we have $(X(1)$, $Y(1)) = (5$, $1)$. $X(1)$ is $\textit{stone}$. $Y(1)$ is $\textit{scissors}$, so $X$ wins this round. In the third round, we have $(X(2), Y(2)) = (3, 0)$. Both $X(2)$ and $Y(2)$ are $\textit{papers}$, so this pick ends in a draw. We keep picking a new pair $(X(3), Y(3)) = (0, 1)$. $X(3)$ is $\textit{paper}$, $Y(3)$ is $\textit{scissors}$, so $Y$ wins this round.

## Input Format

The input contains only one test case. There are four positive integers $X(0)$, $a$, $b$, and $c$ in the first line. There are four positive integers $Y(0)$, $d$, $e$, and $f$ in the second line. And there is one positive integer $N$ in the third line. $N$ is number of round we will play.

## Output Format

The output contains $N$ lines. There are two integers $w$ and $k$ in each line. The first integer $w$ determines which player wins this round. When $X$ wins, $w$ is 0, and $w$ is 1 when $Y$ wins. The second integer $k$ determines how many pairs we picked in this round.

## Subtask

- 10 points: $N$ is 1. We play only one round, and the are
**no**draws in the game. - 10 points: $N$ is larger than 1, and there are
**no**draws - 80 points: $N$ is larger than 1, and there are draws in the games.

## Sample Input 1

`4 5 6 7`

`6 5 4 3`

`1`

## Sample Output 1

`0 1`

## Sample Input 2

`4 5 6 7`

`6 5 4 3`

`2`

## Sample Output 2

`0 1`

`0 1`

## Sample Input 3

`4 5 6 7`

`6 5 4 3`

`3`

## Sample Output 3

`0 1`

`0 1`

`1 2`