409004: GYM103414 H Octopus Game

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

H. Octopus Gametime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output

The tournament of "Octopus Game" is held in some country.

This round the participants will deal with math puzzle. Each player has two cards, initially there are integers $$$a_0$$$ and $$$b_0$$$ at the cards, respectively.

Players make actions with their cards. Let the integers on player's cards be $$$a$$$ and $$$b$$$. The player first chooses an integer $$$k$$$, and then performs one of the following operations:

  1. replace the integer on the first card with $$$a + kb$$$;
  2. replace the integer on the second card with $$$b + ka$$$.

While playing, the absolute value of an integer written on a card must not exceed $$$10^{18}$$$, otherwise something bad might happen. Those players are winning the round, who get $$$0$$$ written on one of the cards, after performing at most $$$50$$$ actions.

You are going to play the game, and of course you would like to win!

Input

The only line of input contains two integers $$$a_0$$$ and $$$b_0$$$ — the initial integers written on the cards ($$$-10^{18} \le a_0, b_0 \le 10^{18}$$$).

Output

The first line must contain $$$n$$$ — the number of actions that the player is willing to perform to get 0 on one of the cards ($$$0 \le n \le 50$$$). Note that you need not minimize the number of actions, but it must not exceed $$$50$$$.

The following $$$n$$$ lines must contain two space separated integers each: $$$t_i$$$ and $$$k_i$$$ — the type of the respective action and the chosen integer $$$k$$$.

If there are multiple valid solutions, it is allowed to output any of them, but note that during the game the integers on the cards must not exceed $$$10^{18}$$$ by their absolute values.

ExamplesInput
-3 9
Output
1
2 3
Input
-27 57
Output
2
2 2
1 9
Input
56 15
Output
6
1 -2
1 -1
2 -2
1 1
2 2
1 -4
Note

The first test requires just one action: add three times integer on the first card to the integer on the second card.

The second test: after the first action there are integers $$$-27$$$ and $$$3$$$ on the cards, respectively, after the second action the integers are $$$0$$$ and $$$3$$$.

The third test: the integers on the cards are in turn: $$$56$$$ and $$$15$$$, $$$26$$$ and $$$15$$$, $$$11$$$ and $$$15$$$, $$$11$$$ and $$$-7$$$, $$$4$$$ and $$$-7$$$, $$$4$$$ and $$$1$$$, $$$0$$$ and $$$1$$$.

加入题单

算法标签: