import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 最大はスター　0から(N-1)C2まで可能
N, K = lr()
max = (N-1) * (N-2) // 2
if K > max:
    print(-1)
    exit()
minus = max - K
print(N - 1 + minus) # 辺の数
# 1を中心とする
for i in range(2, N+1):
    print(1, i)

leaf_com = []
for x in itertools.combinations(range(2, N+1), 2):
    leaf_com.append(x)

for i in range(minus):
    u, v = leaf_com[i]
    print(u, v)

# 38 import sys sys import itertools itertools sr = lambda: sys.stdin.readline().rstrip() sr 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 ir = lambda: int(sr()) ir lambda: int(sr()) int(sr()) int sr() sr lr = lambda: list(map(int, sr().split())) lr lambda: list(map(int, sr().split())) list(map(int, sr().split())) list map(int, sr().split()) map int sr().split() ().split () sr split N, K = lr() N lr() lr K max = (N-1) * (N-2) // 2 max (N-1) * (N-2) // 2 (N-1) * (N-2) N-1 N 1 N-2 N 2 2 if K > max:
    print(-1)
    exit() K > max K max print(-1) print -1 exit() exit minus = max - K minus max - K max K print(N - 1 + minus) print N - 1 + minus N - 1 N 1 minus for i in range(2, N+1):
    print(1, i) i range(2, N+1) range 2 N+1 N 1 print(1, i) print 1 i leaf_com = [] leaf_com [] for x in itertools.combinations(range(2, N+1), 2):
    leaf_com.append(x) x itertools.combinations(range(2, N+1), 2) itertools.combinations itertools combinations range(2, N+1) range 2 N+1 N 1 2 leaf_com.append(x) leaf_com.append leaf_com append x for i in range(minus):
    u, v = leaf_com[i]
    print(u, v)

# 38 i range(minus) range minus u, v = leaf_com[i] u leaf_com[i] leaf_com i v print(u, v) print u v v = leaf_com[i] leaf_com[i] v sr = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() sr minus = max - K max - K minus max = (N-1) * (N-2) // 2 (N-1) * (N-2) // 2 max u, v = leaf_com[i] leaf_com[i] u N, K = lr() lr() N lr = lambda: list(map(int, sr().split())) lambda: list(map(int, sr().split())) lr leaf_com = [] [] leaf_com ir = lambda: int(sr()) lambda: int(sr()) ir K = lr() lr() K
import sys
import itertools

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 最大はスター　0から(N-1)C2まで可能
N, K = lr()
max = (N-1) * (N-2) // 2
if K > max:
    print(-1)
    exit()
minus = max - K
print(N - 1 + minus) # 辺の数
# 1を中心とする
for i in range(2, N+1):
    print(1, i)

leaf_com = []
for x in itertools.combinations(range(2, N+1), 2):
    leaf_com.append(x)

for i in range(minus):
    u, v = leaf_com[i]
    print(u, v)

# 38