import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void calc(int n, int k) {
    if (n == 2) {
        if (k == 0) {
            writeln(1);
            writeln("1 2");
        }
        else writeln(-1);
        return;
    }
    else if (n == 3) {
        if (k == 1) {
            writeln(2);
            writeln("1 2");
            writeln("2 3");
        }
        else writeln(-1);
        return;
    }

    int e = (n - 1) * (n - 2) / 2;
    if (e < k) {
        writeln(-1);
        return;
    }

    long[][] edges;
    for (int i = 2; i <= n; i++) {
        edges ~= [1, i];
    }

    int del = e - k;
    for (int i = 2; i <= n; i++) {
        if (del == 0) break;
        for (int j = i + 1; j <= n; j++) {
            edges ~= [i, j];
            if (--del == 0) break;
        }
    }

    writeln(edges.length);
    foreach (x; edges) {
        writeln(x[0], " ", x[1]);
    }

}

void main() {
    int n, k; scan(n, k);
    calc(n, k);
}
