import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,K = LI()
    sa = (N - 1) * (N - 2) // 2 - K
    if sa < 0:
        print(-1)
        return

    ans = []
    for i in range(2,N+1):
        ans.append((1,i))
    i = 2
    j = 3
    while sa > 0:
        ans.append((i,j))
        sa -= 1
        j += 1
        if j > N:
            i += 1
            j = i + 1
    print(len(ans))
    for x in ans:
        print(x[0],x[1])

if __name__ == '__main__':
    main() import sys,queue,math,copy,itertools,bisect,collections,heapq sys queue math copy itertools bisect collections heapq def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,K = LI()
    sa = (N - 1) * (N - 2) // 2 - K
    if sa < 0:
        print(-1)
        return

    ans = []
    for i in range(2,N+1):
        ans.append((1,i))
    i = 2
    j = 3
    while sa > 0:
        ans.append((i,j))
        sa -= 1
        j += 1
        if j > N:
            i += 1
            j = i + 1
    print(len(ans))
    for x in ans:
        print(x[0],x[1]) main sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 INF = 10**18 INF 10**18 10 18 MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 int(x) for x in sys.stdin.readline().split() for x in sys.stdin.readline().split() x sys.stdin.readline().split() sys.stdin.readline().split sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline split for x in sys.stdin.readline().split() int(x) int x LI = lambda : [int(x) for x in sys.stdin.readline().split()] LI lambda : [int(x) for x in sys.stdin.readline().split()] [int(x) for x in sys.stdin.readline().split()] NI = lambda : int(sys.stdin.readline()) NI lambda : int(sys.stdin.readline()) int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline SI = lambda : sys.stdin.readline().rstrip() SI lambda : sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip N,K = LI() N LI() LI K sa = (N - 1) * (N - 2) // 2 - K sa (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 if sa < 0:
        print(-1)
        return

     sa < 0 sa 0 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 i = 2 i 2 j = 3 j 3 while sa > 0:
        ans.append((i,j))
        sa -= 1
        j += 1
        if j > N:
            i += 1
            j = i + 1
     sa > 0 sa 0 ans.append((i,j)) ans.append ans append (i,j) i j sa -= 1 sa 1 j += 1 j 1 if j > N:
            i += 1
            j = i + 1
     j > N j N i += 1 i 1 j = i + 1 j i + 1 i 1 print(len(ans)) print len(ans) len ans for x in ans:
        print(x[0],x[1]) x ans print(x[0],x[1]) print x[0] x 0 x[1] x 1 if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,K = LI()
    sa = (N - 1) * (N - 2) // 2 - K
    if sa < 0:
        print(-1)
        return

    ans = []
    for i in range(2,N+1):
        ans.append((1,i))
    i = 2
    j = 3
    while sa > 0:
        ans.append((i,j))
        sa -= 1
        j += 1
        if j > N:
            i += 1
            j = i + 1
    print(len(ans))
    for x in ans:
        print(x[0],x[1]) def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,K = LI()
    sa = (N - 1) * (N - 2) // 2 - K
    if sa < 0:
        print(-1)
        return

    ans = []
    for i in range(2,N+1):
        ans.append((1,i))
    i = 2
    j = 3
    while sa > 0:
        ans.append((i,j))
        sa -= 1
        j += 1
        if j > N:
            i += 1
            j = i + 1
    print(len(ans))
    for x in ans:
        print(x[0],x[1]) main
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()

    N,K = LI()
    sa = (N - 1) * (N - 2) // 2 - K
    if sa < 0:
        print(-1)
        return

    ans = []
    for i in range(2,N+1):
        ans.append((1,i))
    i = 2
    j = 3
    while sa > 0:
        ans.append((i,j))
        sa -= 1
        j += 1
        if j > N:
            i += 1
            j = i + 1
    print(len(ans))
    for x in ans:
        print(x[0],x[1])

if __name__ == '__main__':
    main()