def main():
    N, K = map(int, input().split())
    max_K = (N - 1) * (N - 2) // 2
    if K > max_K:
        print(-1)
        exit()

    ans = []
    for i in range(2, N+1):
        ans.append((1,i))

    cand = []
    for i in range(2,N):
        for j in range(i+1,N+1):
            cand.append((i,j))

    
    for i in range(max_K - K):
        a, b = cand.pop()
        ans.append((a,b))

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



if __name__ == "__main__":
    main() def main():
    N, K = map(int, input().split())
    max_K = (N - 1) * (N - 2) // 2
    if K > max_K:
        print(-1)
        exit()

    ans = []
    for i in range(2, N+1):
        ans.append((1,i))

    cand = []
    for i in range(2,N):
        for j in range(i+1,N+1):
            cand.append((i,j))

    
    for i in range(max_K - K):
        a, b = cand.pop()
        ans.append((a,b))

    print(len(ans))
    for u, v in ans:
        print(u,v) main N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K max_K = (N - 1) * (N - 2) // 2 max_K (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 if K > max_K:
        print(-1)
        exit()

     K > max_K K max_K print(-1) print -1 exit() exit 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 cand = [] cand [] for i in range(2,N):
        for j in range(i+1,N+1):
            cand.append((i,j))

    
     i range(2,N) range 2 N for j in range(i+1,N+1):
            cand.append((i,j))

    
     j range(i+1,N+1) range i+1 i 1 N+1 N 1 cand.append((i,j)) cand.append cand append (i,j) i j for i in range(max_K - K):
        a, b = cand.pop()
        ans.append((a,b))

     i range(max_K - K) range max_K - K max_K K a, b = cand.pop() a cand.pop() cand.pop cand pop b ans.append((a,b)) ans.append ans append (a,b) a b 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():
    N, K = map(int, input().split())
    max_K = (N - 1) * (N - 2) // 2
    if K > max_K:
        print(-1)
        exit()

    ans = []
    for i in range(2, N+1):
        ans.append((1,i))

    cand = []
    for i in range(2,N):
        for j in range(i+1,N+1):
            cand.append((i,j))

    
    for i in range(max_K - K):
        a, b = cand.pop()
        ans.append((a,b))

    print(len(ans))
    for u, v in ans:
        print(u,v) def main():
    N, K = map(int, input().split())
    max_K = (N - 1) * (N - 2) // 2
    if K > max_K:
        print(-1)
        exit()

    ans = []
    for i in range(2, N+1):
        ans.append((1,i))

    cand = []
    for i in range(2,N):
        for j in range(i+1,N+1):
            cand.append((i,j))

    
    for i in range(max_K - K):
        a, b = cand.pop()
        ans.append((a,b))

    print(len(ans))
    for u, v in ans:
        print(u,v) main
def main():
    N, K = map(int, input().split())
    max_K = (N - 1) * (N - 2) // 2
    if K > max_K:
        print(-1)
        exit()

    ans = []
    for i in range(2, N+1):
        ans.append((1,i))

    cand = []
    for i in range(2,N):
        for j in range(i+1,N+1):
            cand.append((i,j))

    
    for i in range(max_K - K):
        a, b = cand.pop()
        ans.append((a,b))

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



if __name__ == "__main__":
    main()