Under construction

Still being built. Things may change

Octopus Game

Time limit1sMemory limit512 MB

Summary
Given two starting card values, output at most 50 moves that add a multiple of one card to the other and put a zero on one card, keeping all values within 10^18.
Level

Medium7 of 10

Topics
Number theory, Math, Implementation
Solved
No attempts yet

Problem

In some country, a tournament called Octopus Game is held.

In this round, participants solve a math puzzle. Each player starts with two cards. Initially, the first card contains a0a_0 and the second card contains b0b_0.

Players act with their cards. Let the integers on a player's cards be aa and bb. The player first chooses an integer kk, then performs one of the following operations:

  1. Replace the integer on the first card with a+kba + kb.
  2. Replace the integer on the second card with b+kab + ka.

During play, the absolute value of an integer written on a card must not exceed 101810^{18}; otherwise something bad may happen. A player wins the round if, after at most 50 actions, one of the cards contains 0.

You are going to play the game, and of course you want to win.

Input

The only line of input contains the two integers a0a_0 and b0b_0 initially written on the cards (−1018≤a0,b0≤1018-10^{18} \le a_0, b_0 \le 10^{18}).

Output

The first line must contain nn, the number of actions the player wants to perform to put 0 on one of the cards (0≤n≤500 \le n \le 50). You do not need to minimize the number of actions, but it must not exceed 50.

The following nn lines must each contain two space-separated integers tit_i and kik_i: the type of the corresponding action and the chosen integer kik_i.

If there are multiple valid solutions, you may output any of them. However, during the game, the absolute value of the integers on the cards must not exceed 101810^{18}.

Hint

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

In the second test, after the first action the cards contain −27-27 and 33, respectively; after the second action they contain 00 and 33.

In the third test, the integers on the cards are, in order, 5656 and 1515, 2626 and 1515, 1111 and 1515, 1111 and −7-7, 44 and −7-7, 44 and 11, 00 and 11.

Examples3

  1. Example 1

    Input
    -3 9
    
    Expected output
    1
    2 3
    
  2. Example 2

    Input
    -27 57
    
    Expected output
    2
    2 2
    1 9
    
  3. Example 3

    Input
    56 15
    
    Expected output
    6
    1 -2
    1 -1
    2 -2
    1 1
    2 2
    1 -4