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

if K > (N - 1) * (N - 2) // 2:
    print(-1)
    exit()

# N を中心とするスターグラフ
uvs = [(i, N) for i in range(1, N)]

to_decrease = (N - 1) * (N - 2) // 2 - K
for i in range(1, N):
    for j in range(i+1, N):
        if to_decrease == 0:
            break
        uvs.append((i, j))
        to_decrease -= 1
    else:
        continue
    break

print(len(uvs))
for u, v in uvs:
    print(u, v) N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K if K > (N - 1) * (N - 2) // 2:
    print(-1)
    exit()

# N を中心とするスターグラフ K > (N - 1) * (N - 2) // 2 K (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 print(-1) print -1 exit() exit (i, N) for i in range(1, N) for i in range(1, N) i range(1, N) range 1 N for i in range(1, N) (i, N) i N uvs = [(i, N) for i in range(1, N)] uvs [(i, N) for i in range(1, N)] to_decrease = (N - 1) * (N - 2) // 2 - K to_decrease (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 for i in range(1, N):
    for j in range(i+1, N):
        if to_decrease == 0:
            break
        uvs.append((i, j))
        to_decrease -= 1
    else:
        continue
    break i range(1, N) range 1 N for j in range(i+1, N):
        if to_decrease == 0:
            break
        uvs.append((i, j))
        to_decrease -= 1
    else:
        continue
     j range(i+1, N) range i+1 i 1 N if to_decrease == 0:
            break
         to_decrease == 0 to_decrease 0 break uvs.append((i, j)) uvs.append uvs append (i, j) i j to_decrease -= 1 to_decrease 1 continue break print(len(uvs)) print len(uvs) len uvs for u, v in uvs:
    print(u, v) u v uvs print(u, v) print u v K = map(int, input().split()) map(int, input().split()) K to_decrease = (N - 1) * (N - 2) // 2 - K (N - 1) * (N - 2) // 2 - K to_decrease to_decrease -= 1 1 to_decrease uvs = [(i, N) for i in range(1, N)] [(i, N) for i in range(1, N)] uvs N, K = map(int, input().split()) map(int, input().split()) N
N, K = map(int, input().split())

if K > (N - 1) * (N - 2) // 2:
    print(-1)
    exit()

# N を中心とするスターグラフ
uvs = [(i, N) for i in range(1, N)]

to_decrease = (N - 1) * (N - 2) // 2 - K
for i in range(1, N):
    for j in range(i+1, N):
        if to_decrease == 0:
            break
        uvs.append((i, j))
        to_decrease -= 1
    else:
        continue
    break

print(len(uvs))
for u, v in uvs:
    print(u, v)