def main():
    n, k = map(int, input().split())
    mx = (n-1)*(n-2)//2
    if mx < k:
        print(-1)
        return
    ans = []
    for i in range(n-1):
        ans.append([i+1,n])     # star graph
    add = mx - k
    edge = []
    for i in range(n-1):
        for j in range(i):
            edge.append([i+1, j+1]) # complete graph
    for i in range(add):
        ans.append(edge[i])         # add本のedgeを追加
    m = len(ans)
    print(m)
    for i in range(m):
        print(*ans[i])

main() def main():
    n, k = map(int, input().split())
    mx = (n-1)*(n-2)//2
    if mx < k:
        print(-1)
        return
    ans = []
    for i in range(n-1):
        ans.append([i+1,n])     # star graph
    add = mx - k
    edge = []
    for i in range(n-1):
        for j in range(i):
            edge.append([i+1, j+1]) # complete graph
    for i in range(add):
        ans.append(edge[i])         # add本のedgeを追加
    m = len(ans)
    print(m)
    for i in range(m):
        print(*ans[i]) main n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k mx = (n-1)*(n-2)//2 mx (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 if mx < k:
        print(-1)
        return
     mx < k mx k print(-1) print -1 return ans = [] ans [] for i in range(n-1):
        ans.append([i+1,n])     # star graph
     i range(n-1) range n-1 n 1 ans.append([i+1,n]) ans.append ans append [i+1,n] i+1 i 1 n add = mx - k add mx - k mx k edge = [] edge [] for i in range(n-1):
        for j in range(i):
            edge.append([i+1, j+1]) # complete graph
     i range(n-1) range n-1 n 1 for j in range(i):
            edge.append([i+1, j+1]) # complete graph
     j range(i) range i edge.append([i+1, j+1]) edge.append edge append [i+1, j+1] i+1 i 1 j+1 j 1 for i in range(add):
        ans.append(edge[i])         # add本のedgeを追加
     i range(add) range add ans.append(edge[i]) ans.append ans append edge[i] edge i m = len(ans) m len(ans) len ans print(m) print m for i in range(m):
        print(*ans[i]) i range(m) range m print(*ans[i]) print *ans[i] ans[i] ans i main() main def main():
    n, k = map(int, input().split())
    mx = (n-1)*(n-2)//2
    if mx < k:
        print(-1)
        return
    ans = []
    for i in range(n-1):
        ans.append([i+1,n])     # star graph
    add = mx - k
    edge = []
    for i in range(n-1):
        for j in range(i):
            edge.append([i+1, j+1]) # complete graph
    for i in range(add):
        ans.append(edge[i])         # add本のedgeを追加
    m = len(ans)
    print(m)
    for i in range(m):
        print(*ans[i]) def main():
    n, k = map(int, input().split())
    mx = (n-1)*(n-2)//2
    if mx < k:
        print(-1)
        return
    ans = []
    for i in range(n-1):
        ans.append([i+1,n])     # star graph
    add = mx - k
    edge = []
    for i in range(n-1):
        for j in range(i):
            edge.append([i+1, j+1]) # complete graph
    for i in range(add):
        ans.append(edge[i])         # add本のedgeを追加
    m = len(ans)
    print(m)
    for i in range(m):
        print(*ans[i]) main
def main():
    n, k = map(int, input().split())
    mx = (n-1)*(n-2)//2
    if mx < k:
        print(-1)
        return
    ans = []
    for i in range(n-1):
        ans.append([i+1,n])     # star graph
    add = mx - k
    edge = []
    for i in range(n-1):
        for j in range(i):
            edge.append([i+1, j+1]) # complete graph
    for i in range(add):
        ans.append(edge[i])         # add本のedgeを追加
    m = len(ans)
    print(m)
    for i in range(m):
        print(*ans[i])

main()
