#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
    int N, A, broj_setova = rand() % 5 + 3;
    cin>>N>>A;
    
    while (broj_setova * A >= N) {
        broj_setova--;
    }
    int a[broj_setova][2];
    if(broj_setova > 2){
        int  b[broj_setova];
        cout << broj_setova << endl;
        for(int i = 0; i < broj_setova; i++){
            for (int j = 0; j < 2; j ++) {
                a[i][j] = 0;
                b[i] = 0;
            }
        }
        N -= broj_setova * A;
        for(int i = 0;i < broj_setova;i++){
            if(i == broj_setova - 1){
                if(i < 3){
                    a[i][0] = A;
                    a[i][1] = N;
                    N -= a[i][1];
                }else{
                    a[i][1] = A;
                    a[i][0] = N;
                    N -= a[i][0];
                }
            }else if(i < 3){
                a[i][0] = A;
                a[i][1] = (int) random() % (A -2) % N;
                N -= a[i][1];
                b[i] =(int) random() % (a[i][0] - a[i][1] - 2) % N;
                N -= b[i];
                a[i][1] += b[i];
            }else if( i >= 3){
                a[i][1] = A;
                a[i][0] = (int) random() % (A -2) % N;
                N -= a[i][0];
                b[i] =(int) random() % (a[i][1] - a[i][0] - 2) % N;
                N -= b[i];
                a[i][0] += b[i];
            }
        }
        for (int i = 0; i < broj_setova; i++) {
               cout<<a[i][0]<<" "<<a[i][1]<<endl;
           }
    }else{
        cout<<-1<<endl;
    }
    return 0;
}