N, K = map(int, input().split())

total = (N - 1) * (N - 2) // 2
if K > total:
    print(-1)
else:
    edges = []
    for k in range(2, N + 1):
        edges.append([1, k])

    res = total - K
    cnt = 0
    for u in range(2, N + 1):
        if cnt == res:
            break
    
        for v in range(u + 1, N + 1):
            edges.append([u, v])
            cnt += 1

            if cnt == res:
                break

    print(len(edges))
    for v in edges:
        print(*v) N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K total = (N - 1) * (N - 2) // 2 total (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 if K > total:
    print(-1)
else:
    edges = []
    for k in range(2, N + 1):
        edges.append([1, k])

    res = total - K
    cnt = 0
    for u in range(2, N + 1):
        if cnt == res:
            break
    
        for v in range(u + 1, N + 1):
            edges.append([u, v])
            cnt += 1

            if cnt == res:
                break

    print(len(edges))
    for v in edges:
        print(*v) K > total K total print(-1) print -1 edges = [] edges [] for k in range(2, N + 1):
        edges.append([1, k])

     k range(2, N + 1) range 2 N + 1 N 1 edges.append([1, k]) edges.append edges append [1, k] 1 k res = total - K res total - K total K cnt = 0 cnt 0 for u in range(2, N + 1):
        if cnt == res:
            break
    
        for v in range(u + 1, N + 1):
            edges.append([u, v])
            cnt += 1

            if cnt == res:
                break

     u range(2, N + 1) range 2 N + 1 N 1 if cnt == res:
            break
    
         cnt == res cnt res break for v in range(u + 1, N + 1):
            edges.append([u, v])
            cnt += 1

            if cnt == res:
                break

     v range(u + 1, N + 1) range u + 1 u 1 N + 1 N 1 edges.append([u, v]) edges.append edges append [u, v] u v cnt += 1 cnt 1 if cnt == res:
                break

     cnt == res cnt res break print(len(edges)) print len(edges) len edges for v in edges:
        print(*v) v edges print(*v) print *v v cnt = 0 0 cnt K = map(int, input().split()) map(int, input().split()) K total = (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) // 2 total res = total - K total - K res cnt += 1 1 cnt edges = [] [] edges N, K = map(int, input().split()) map(int, input().split()) N
N, K = map(int, input().split())

total = (N - 1) * (N - 2) // 2
if K > total:
    print(-1)
else:
    edges = []
    for k in range(2, N + 1):
        edges.append([1, k])

    res = total - K
    cnt = 0
    for u in range(2, N + 1):
        if cnt == res:
            break
    
        for v in range(u + 1, N + 1):
            edges.append([u, v])
            cnt += 1

            if cnt == res:
                break

    print(len(edges))
    for v in edges:
        print(*v)