N, K = map(int, input().split())
M = (N - 1) * (N - 2) // 2

if K <= M:
    edges = []
    for i in range(2, N + 1):
        edges.append((1, i))
    dis = M - K
    for i in range(2, N + 1):
        for j in range(i + 1, N + 1):
            if dis > 0:
                edges.append((i, j))
                dis -= 1
            else:
                break
        else:
            continue
        break
    print(len(edges))
    for fr, to in edges:
        print(fr, to)
else:
    print(-1) N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K M = (N - 1) * (N - 2) // 2 M (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 if K <= M:
    edges = []
    for i in range(2, N + 1):
        edges.append((1, i))
    dis = M - K
    for i in range(2, N + 1):
        for j in range(i + 1, N + 1):
            if dis > 0:
                edges.append((i, j))
                dis -= 1
            else:
                break
        else:
            continue
        break
    print(len(edges))
    for fr, to in edges:
        print(fr, to)
else:
    print(-1) K <= M K M edges = [] edges [] for i in range(2, N + 1):
        edges.append((1, i))
     i range(2, N + 1) range 2 N + 1 N 1 edges.append((1, i)) edges.append edges append (1, i) 1 i dis = M - K dis M - K M K for i in range(2, N + 1):
        for j in range(i + 1, N + 1):
            if dis > 0:
                edges.append((i, j))
                dis -= 1
            else:
                break
        else:
            continue
        break
     i range(2, N + 1) range 2 N + 1 N 1 for j in range(i + 1, N + 1):
            if dis > 0:
                edges.append((i, j))
                dis -= 1
            else:
                break
        else:
            continue
         j range(i + 1, N + 1) range i + 1 i 1 N + 1 N 1 if dis > 0:
                edges.append((i, j))
                dis -= 1
            else:
                break
         dis > 0 dis 0 edges.append((i, j)) edges.append edges append (i, j) i j dis -= 1 dis 1 break continue break print(len(edges)) print len(edges) len edges for fr, to in edges:
        print(fr, to) fr to edges print(fr, to) print fr to print(-1) print -1 M = (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) // 2 M edges = [] [] edges dis = M - K M - K dis dis -= 1 1 dis N, K = map(int, input().split()) map(int, input().split()) N K = map(int, input().split()) map(int, input().split()) K
N, K = map(int, input().split())
M = (N - 1) * (N - 2) // 2

if K <= M:
    edges = []
    for i in range(2, N + 1):
        edges.append((1, i))
    dis = M - K
    for i in range(2, N + 1):
        for j in range(i + 1, N + 1):
            if dis > 0:
                edges.append((i, j))
                dis -= 1
            else:
                break
        else:
            continue
        break
    print(len(edges))
    for fr, to in edges:
        print(fr, to)
else:
    print(-1)
