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

if K > L:
    print(-1)
else:
    Ms = []
    for i in range(2, N+1):
        Ms.append((1, i))
    c = L
    for i in range(2, N):
        if c <= K:
            break
        for j in range(i+1, N+1):
            Ms.append((i, j))
            c -= 1
            if c <= K:
                break

    print(len(Ms))
    for u, v in Ms:
        print(u, v) N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K L = (N-1)*(N-2)//2 L (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 if K > L:
    print(-1)
else:
    Ms = []
    for i in range(2, N+1):
        Ms.append((1, i))
    c = L
    for i in range(2, N):
        if c <= K:
            break
        for j in range(i+1, N+1):
            Ms.append((i, j))
            c -= 1
            if c <= K:
                break

    print(len(Ms))
    for u, v in Ms:
        print(u, v) K > L K L print(-1) print -1 Ms = [] Ms [] for i in range(2, N+1):
        Ms.append((1, i))
     i range(2, N+1) range 2 N+1 N 1 Ms.append((1, i)) Ms.append Ms append (1, i) 1 i c = L c L for i in range(2, N):
        if c <= K:
            break
        for j in range(i+1, N+1):
            Ms.append((i, j))
            c -= 1
            if c <= K:
                break

     i range(2, N) range 2 N if c <= K:
            break
         c <= K c K break for j in range(i+1, N+1):
            Ms.append((i, j))
            c -= 1
            if c <= K:
                break

     j range(i+1, N+1) range i+1 i 1 N+1 N 1 Ms.append((i, j)) Ms.append Ms append (i, j) i j c -= 1 c 1 if c <= K:
                break

     c <= K c K break print(len(Ms)) print len(Ms) len Ms for u, v in Ms:
        print(u, v) u v Ms print(u, v) print u v c -= 1 1 c Ms = [] [] Ms K = map(int, input().split()) map(int, input().split()) K N, K = map(int, input().split()) map(int, input().split()) N L = (N-1)*(N-2)//2 (N-1)*(N-2)//2 L c = L L c
N, K = map(int, input().split())
L = (N-1)*(N-2)//2

if K > L:
    print(-1)
else:
    Ms = []
    for i in range(2, N+1):
        Ms.append((1, i))
    c = L
    for i in range(2, N):
        if c <= K:
            break
        for j in range(i+1, N+1):
            Ms.append((i, j))
            c -= 1
            if c <= K:
                break

    print(len(Ms))
    for u, v in Ms:
        print(u, v)