n,k = map(int,input().split())
if n*(n-1)//2 - (n-1) < k:
    print(-1)
else:
    e = n*(n-1)//2 - k
    print(e)
    cnt = 0
    for i in range(1, n):
        for j in range(i+1, n+1):
            print(i,j)
            cnt += 1
            if cnt == e:
                exit() n,k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k if n*(n-1)//2 - (n-1) < k:
    print(-1)
else:
    e = n*(n-1)//2 - k
    print(e)
    cnt = 0
    for i in range(1, n):
        for j in range(i+1, n+1):
            print(i,j)
            cnt += 1
            if cnt == e:
                exit() n*(n-1)//2 - (n-1) < k n*(n-1)//2 - (n-1) n*(n-1)//2 n*(n-1) n n-1 n 1 2 n-1 n 1 k print(-1) print -1 e = n*(n-1)//2 - k e n*(n-1)//2 - k n*(n-1)//2 n*(n-1) n n-1 n 1 2 k print(e) print e cnt = 0 cnt 0 for i in range(1, n):
        for j in range(i+1, n+1):
            print(i,j)
            cnt += 1
            if cnt == e:
                exit() i range(1, n) range 1 n for j in range(i+1, n+1):
            print(i,j)
            cnt += 1
            if cnt == e:
                exit() j range(i+1, n+1) range i+1 i 1 n+1 n 1 print(i,j) print i j cnt += 1 cnt 1 if cnt == e:
                exit() cnt == e cnt e exit() exit 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 e = n*(n-1)//2 - k n*(n-1)//2 - k e cnt = 0 0 cnt
n,k = map(int,input().split())
if n*(n-1)//2 - (n-1) < k:
    print(-1)
else:
    e = n*(n-1)//2 - k
    print(e)
    cnt = 0
    for i in range(1, n):
        for j in range(i+1, n+1):
            print(i,j)
            cnt += 1
            if cnt == e:
                exit()
