Under construction

Still being built. Things may change

Chemistry

Time limit1sMemory limit1024 MB

Summary
Given n tubes holding 1 nanoliter each, pour between equal-volume tubes to leave exactly k nanoliters in tube 1, or report -1.
Level

Medium5 of 10

Topics
Implementation, Math
Solved
No attempts yet

Statement

Vasya attends his Chemistry classes. During the latest semester, his group has been studying dry liquids. In a lab session on mixing liquids, Vasya received oxygen oxide. This substance has unpredictable consequences after mixing. The liquid is stable only when it is mixed in a one-to-one ratio.

Vasya has nn test tubes, and each one contains 1 nanoliter of oxygen oxide. Because of the properties of the oxide, Vasya pours liquid from test tube AA into test tube BB so that the resulting volume in test tube BB doubles. To make the experiment succeed, Vasya needs exactly kk nanoliters of oxide in one of the test tubes. Help him do this.

Input

The only line contains two integers nn and kk (1≤n≤1000001 ≤ n ≤ 100000, 1≤k≤n1 ≤ k ≤ n).

Output

Output the sequence of pours that leaves exactly kk nanoliters of oxide in the first test tube.

On the first line, output the number of pours mm (0≤m≤3n0 ≤ m ≤ 3n). Then output mm lines, each with two integers aa and bb (1≤a,b≤n1 ≤ a, b ≤ n), meaning Vasya pours oxide from test tube aa into test tube bb.

If no such sequence exists, output -1. If several solutions exist, output any of them. It is guaranteed that if a sequence exists, one exists with at most 3n3n pours.

Examples2

  1. Example 1

    Input
    5 3
    
    Expected output
    4
    2 1
    4 3
    3 1
    1 5
    
  2. Example 2

    Input
    5 5
    
    Expected output
    -1