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