Chemistry

시간 제한1초메모리 제한1024 MB

요약
각 시험관은 1단위로 시작하고, a를 b에 부으면 b가 두 배가 된다. 시험관 1에 정확히 k단위가 남도록 붓는 순서를 만들거나, 불가능하면 -1을 출력한다.
난이도

보통10점 중 6점

유형
수학, 그리디, 구현, 비트 연산
정답자
아직 제출이 없습니다

문제

Android Vasya attends his Chemistry classes. During the latest semester Vasya's group is studying dry liquids. At the laboratory work on mixing liquids Vasya has got oxygen oxide. An important feature of this substance is its unpredictable consequences after mixing. The liquid is stable only after mixing it in one to one proportion.

Vasya has got nn test tubes, with one nano liter of oxygen oxide in each. Due to the features of the oxide Vasya pours liquids from test tube AA to test tube BB in such a way that the resulting liquid volume in test tube BB doubles. To set the experiment successfully Vasya needs to make exactly kk nano liters of the oxide in any of the test tubes. Help him do this.

입력

The only line contains two integers --- nn and kk (1≤n≤100,0001 \leq n \leq 100\\,000, 1≤k≤n1 \leq k \leq n).

출력

Output the sequence of transfers (i. e. pouring from one test tube to another), which results in exactly kk nano liters of the oxide being in the first test tube. In the first line output the number of transfers of the liquid mm (0≤m≤3n0 \leq m \leq 3n). Then in mm lines output pairs of integers aa, bb (1≤a,b≤N1 \leq a, b \leq N), meaning that Vasya needs to pour the oxide from the test tube number aa to the test tube number bb. If such sequence doesn't exist output −1-1. If there are several solutions output any. It is guaranteed that if there is a sequence of transfers to get kk nano liters then there is one with no more than 3n3n transfers.

예제2

  1. 예제 1

    입력
    5 3
    
    예상 출력
    4
    2 1
    4 3
    3 1
    1 5
    
  2. 예제 2

    입력
    5 5
    
    예상 출력
    -1