import sys
def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    num = (N-1)*(N-2)//2
    if K > num:
        print(-1)
        return
    ans = []
    for i in range(2, N+1):
        ans.append((1, i))
    for i in range(2, N+1):
        for j in range(i+1, N+1):
            if num == K: break
            ans.append((i, j))
            num -= 1
    print(len(ans))
    for u, v in ans:
        print(u, v)

if __name__ == '__main__':
    main() import sys sys def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    num = (N-1)*(N-2)//2
    if K > num:
        print(-1)
        return
    ans = []
    for i in range(2, N+1):
        ans.append((1, i))
    for i in range(2, N+1):
        for j in range(i+1, N+1):
            if num == K: break
            ans.append((i, j))
            num -= 1
    print(len(ans))
    for u, v in ans:
        print(u, v) main input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K num = (N-1)*(N-2)//2 num (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 if K > num:
        print(-1)
        return
     K > num K num print(-1) print -1 return 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+1):
        for j in range(i+1, N+1):
            if num == K: break
            ans.append((i, j))
            num -= 1
     i range(2, N+1) range 2 N+1 N 1 for j in range(i+1, N+1):
            if num == K: break
            ans.append((i, j))
            num -= 1
     j range(i+1, N+1) range i+1 i 1 N+1 N 1 if num == K: break
             num == K num K ans.append((i, j)) ans.append ans append (i, j) i j num -= 1 num 1 print(len(ans)) print len(ans) len ans for u, v in ans:
        print(u, v) u v ans print(u, v) print u v if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    num = (N-1)*(N-2)//2
    if K > num:
        print(-1)
        return
    ans = []
    for i in range(2, N+1):
        ans.append((1, i))
    for i in range(2, N+1):
        for j in range(i+1, N+1):
            if num == K: break
            ans.append((i, j))
            num -= 1
    print(len(ans))
    for u, v in ans:
        print(u, v) def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    num = (N-1)*(N-2)//2
    if K > num:
        print(-1)
        return
    ans = []
    for i in range(2, N+1):
        ans.append((1, i))
    for i in range(2, N+1):
        for j in range(i+1, N+1):
            if num == K: break
            ans.append((i, j))
            num -= 1
    print(len(ans))
    for u, v in ans:
        print(u, v) main
import sys
def main():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    num = (N-1)*(N-2)//2
    if K > num:
        print(-1)
        return
    ans = []
    for i in range(2, N+1):
        ans.append((1, i))
    for i in range(2, N+1):
        for j in range(i+1, N+1):
            if num == K: break
            ans.append((i, j))
            num -= 1
    print(len(ans))
    for u, v in ans:
        print(u, v)

if __name__ == '__main__':
    main()