n, k = map(int, input().split())

edges = [(0, i) for i in range(1, n)]
cnt = (n-1) * (n-2) // 2

if k == cnt:
    print(n-1)
    for u, v in edges:
        print(u+1, v+1)
    exit()

for i in range(1, n-1):
    for j in range(i+1, n):
        edges.append((i, j))
        cnt -= 1
        if cnt == k:
            print(len(edges))
            for u, v in edges:
                print(u+1, v+1)
            exit()

print(-1) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k (0, i) for i in range(1, n) for i in range(1, n) i range(1, n) range 1 n for i in range(1, n) (0, i) 0 i edges = [(0, i) for i in range(1, n)] edges [(0, i) for i in range(1, n)] cnt = (n-1) * (n-2) // 2 cnt (n-1) * (n-2) // 2 (n-1) * (n-2) n-1 n 1 n-2 n 2 2 if k == cnt:
    print(n-1)
    for u, v in edges:
        print(u+1, v+1)
    exit() k == cnt k cnt print(n-1) print n-1 n 1 for u, v in edges:
        print(u+1, v+1)
     u v edges print(u+1, v+1) print u+1 u 1 v+1 v 1 exit() exit for i in range(1, n-1):
    for j in range(i+1, n):
        edges.append((i, j))
        cnt -= 1
        if cnt == k:
            print(len(edges))
            for u, v in edges:
                print(u+1, v+1)
            exit() i range(1, n-1) range 1 n-1 n 1 for j in range(i+1, n):
        edges.append((i, j))
        cnt -= 1
        if cnt == k:
            print(len(edges))
            for u, v in edges:
                print(u+1, v+1)
            exit() j range(i+1, n) range i+1 i 1 n edges.append((i, j)) edges.append edges append (i, j) i j cnt -= 1 cnt 1 if cnt == k:
            print(len(edges))
            for u, v in edges:
                print(u+1, v+1)
            exit() cnt == k cnt k print(len(edges)) print len(edges) len edges for u, v in edges:
                print(u+1, v+1)
             u v edges print(u+1, v+1) print u+1 u 1 v+1 v 1 exit() exit print(-1) print -1 cnt = (n-1) * (n-2) // 2 (n-1) * (n-2) // 2 cnt cnt -= 1 1 cnt n, k = map(int, input().split()) map(int, input().split()) n k = map(int, input().split()) map(int, input().split()) k edges = [(0, i) for i in range(1, n)] [(0, i) for i in range(1, n)] edges
n, k = map(int, input().split())

edges = [(0, i) for i in range(1, n)]
cnt = (n-1) * (n-2) // 2

if k == cnt:
    print(n-1)
    for u, v in edges:
        print(u+1, v+1)
    exit()

for i in range(1, n-1):
    for j in range(i+1, n):
        edges.append((i, j))
        cnt -= 1
        if cnt == k:
            print(len(edges))
            for u, v in edges:
                print(u+1, v+1)
            exit()

print(-1)
