def main():
    N, K = map(int, input().split())
    if (N -1) * (N - 2) / 2 < K:
        print(-1)
        return -1
    l = [(1, i) for i in range(2,N+1)]
    i = 2
    j = 3
    for _ in range(int((N-1) * (N-2)/2) - K):
        l.append((i,j))
        if j == N:
            i += 1
            j = i + 1
        else:
            j += 1
    print(len(l))
    for i, j in l:
        print(i, j)
main() def main():
    N, K = map(int, input().split())
    if (N -1) * (N - 2) / 2 < K:
        print(-1)
        return -1
    l = [(1, i) for i in range(2,N+1)]
    i = 2
    j = 3
    for _ in range(int((N-1) * (N-2)/2) - K):
        l.append((i,j))
        if j == N:
            i += 1
            j = i + 1
        else:
            j += 1
    print(len(l))
    for i, j in l:
        print(i, j) main N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K if (N -1) * (N - 2) / 2 < K:
        print(-1)
        return -1
     (N -1) * (N - 2) / 2 < K (N -1) * (N - 2) / 2 (N -1) * (N - 2) N -1 N 1 N - 2 N 2 2 K print(-1) print -1 return -1 -1 (1, i) for i in range(2,N+1) for i in range(2,N+1) i range(2,N+1) range 2 N+1 N 1 for i in range(2,N+1) (1, i) 1 i l = [(1, i) for i in range(2,N+1)] l [(1, i) for i in range(2,N+1)] i = 2 i 2 j = 3 j 3 for _ in range(int((N-1) * (N-2)/2) - K):
        l.append((i,j))
        if j == N:
            i += 1
            j = i + 1
        else:
            j += 1
     _ range(int((N-1) * (N-2)/2) - K) range int((N-1) * (N-2)/2) - K int((N-1) * (N-2)/2) int (N-1) * (N-2)/2 (N-1) * (N-2) N-1 N 1 N-2 N 2 2 K l.append((i,j)) l.append l append (i,j) i j if j == N:
            i += 1
            j = i + 1
        else:
            j += 1
     j == N j N i += 1 i 1 j = i + 1 j i + 1 i 1 j += 1 j 1 print(len(l)) print len(l) len l for i, j in l:
        print(i, j) i j l print(i, j) print i j main() main def main():
    N, K = map(int, input().split())
    if (N -1) * (N - 2) / 2 < K:
        print(-1)
        return -1
    l = [(1, i) for i in range(2,N+1)]
    i = 2
    j = 3
    for _ in range(int((N-1) * (N-2)/2) - K):
        l.append((i,j))
        if j == N:
            i += 1
            j = i + 1
        else:
            j += 1
    print(len(l))
    for i, j in l:
        print(i, j) def main():
    N, K = map(int, input().split())
    if (N -1) * (N - 2) / 2 < K:
        print(-1)
        return -1
    l = [(1, i) for i in range(2,N+1)]
    i = 2
    j = 3
    for _ in range(int((N-1) * (N-2)/2) - K):
        l.append((i,j))
        if j == N:
            i += 1
            j = i + 1
        else:
            j += 1
    print(len(l))
    for i, j in l:
        print(i, j) main
def main():
    N, K = map(int, input().split())
    if (N -1) * (N - 2) / 2 < K:
        print(-1)
        return -1
    l = [(1, i) for i in range(2,N+1)]
    i = 2
    j = 3
    for _ in range(int((N-1) * (N-2)/2) - K):
        l.append((i,j))
        if j == N:
            i += 1
            j = i + 1
        else:
            j += 1
    print(len(l))
    for i, j in l:
        print(i, j)
main()
