import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())

    M = (N - 1) * (N - 2) // 2
    if K > M:
        print(-1)
        return

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

    cnt = 0
    for i in range(1, N):
        done = False
        for j in range(i + 1, N):
            if cnt == M - K:
                done = True
                break
            ans.append((i, j))
            cnt += 1
        if done:
            break

    print(len(ans))
    for i, j in ans:
        print(i, j)

    return


if __name__ == '__main__':
    main() import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 1 << 60 INF 1 << 60 1 60 MOD = 1000000007 MOD 1000000007 def main():
    N, K = map(int, readline().split())

    M = (N - 1) * (N - 2) // 2
    if K > M:
        print(-1)
        return

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

    cnt = 0
    for i in range(1, N):
        done = False
        for j in range(i + 1, N):
            if cnt == M - K:
                done = True
                break
            ans.append((i, j))
            cnt += 1
        if done:
            break

    print(len(ans))
    for i, j in ans:
        print(i, j)

    return main N, K = map(int, readline().split()) N map(int, readline().split()) map int readline().split() ().split () readline split K M = (N - 1) * (N - 2) // 2 M (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 if K > M:
        print(-1)
        return

     K > M K M print(-1) print -1 return ans = [] ans [] for i in range(1, N):
        ans.append((i, N))

     i range(1, N) range 1 N ans.append((i, N)) ans.append ans append (i, N) i N cnt = 0 cnt 0 for i in range(1, N):
        done = False
        for j in range(i + 1, N):
            if cnt == M - K:
                done = True
                break
            ans.append((i, j))
            cnt += 1
        if done:
            break

     i range(1, N) range 1 N done = False done False for j in range(i + 1, N):
            if cnt == M - K:
                done = True
                break
            ans.append((i, j))
            cnt += 1
         j range(i + 1, N) range i + 1 i 1 N if cnt == M - K:
                done = True
                break
             cnt == M - K cnt M - K M K done = True done True break ans.append((i, j)) ans.append ans append (i, j) i j cnt += 1 cnt 1 if done:
            break

     done break 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 return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main INF = 1 << 60 1 << 60 INF def main():
    N, K = map(int, readline().split())

    M = (N - 1) * (N - 2) // 2
    if K > M:
        print(-1)
        return

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

    cnt = 0
    for i in range(1, N):
        done = False
        for j in range(i + 1, N):
            if cnt == M - K:
                done = True
                break
            ans.append((i, j))
            cnt += 1
        if done:
            break

    print(len(ans))
    for i, j in ans:
        print(i, j)

    return def main():
    N, K = map(int, readline().split())

    M = (N - 1) * (N - 2) // 2
    if K > M:
        print(-1)
        return

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

    cnt = 0
    for i in range(1, N):
        done = False
        for j in range(i + 1, N):
            if cnt == M - K:
                done = True
                break
            ans.append((i, j))
            cnt += 1
        if done:
            break

    print(len(ans))
    for i, j in ans:
        print(i, j)

    return main read = sys.stdin.read sys.stdin.read read readlines = sys.stdin.readlines sys.stdin.readlines readlines readline = sys.stdin.readline sys.stdin.readline readline MOD = 1000000007 1000000007 MOD
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())

    M = (N - 1) * (N - 2) // 2
    if K > M:
        print(-1)
        return

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

    cnt = 0
    for i in range(1, N):
        done = False
        for j in range(i + 1, N):
            if cnt == M - K:
                done = True
                break
            ans.append((i, j))
            cnt += 1
        if done:
            break

    print(len(ans))
    for i, j in ans:
        print(i, j)

    return


if __name__ == '__main__':
    main()
