from itertools import combinations

n, k = map(int, input().split())
star = []
max_k = (n - 1) * (n - 2) // 2
delta = max_k - k
cnt = 0
if k <= max_k:
    ans = []
    for i in range(2, n + 1):
        star.append((1, i))
        cnt += 1

    if delta > 0:
        kumiawase = list(combinations(range(2, n+1), 2))
        for j in range(delta):
            kumi = kumiawase[j]
            star.append(kumi)
            cnt += 1
    print(cnt)
    for pair in star:
        print(*pair, sep=" ")
else:
    print(-1) from itertools import combinations n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k star = [] star [] max_k = (n - 1) * (n - 2) // 2 max_k (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 delta = max_k - k delta max_k - k max_k k cnt = 0 cnt 0 if k <= max_k:
    ans = []
    for i in range(2, n + 1):
        star.append((1, i))
        cnt += 1

    if delta > 0:
        kumiawase = list(combinations(range(2, n+1), 2))
        for j in range(delta):
            kumi = kumiawase[j]
            star.append(kumi)
            cnt += 1
    print(cnt)
    for pair in star:
        print(*pair, sep=" ")
else:
    print(-1) k <= max_k k max_k ans = [] ans [] for i in range(2, n + 1):
        star.append((1, i))
        cnt += 1

     i range(2, n + 1) range 2 n + 1 n 1 star.append((1, i)) star.append star append (1, i) 1 i cnt += 1 cnt 1 if delta > 0:
        kumiawase = list(combinations(range(2, n+1), 2))
        for j in range(delta):
            kumi = kumiawase[j]
            star.append(kumi)
            cnt += 1
     delta > 0 delta 0 kumiawase = list(combinations(range(2, n+1), 2)) kumiawase list(combinations(range(2, n+1), 2)) list combinations(range(2, n+1), 2) combinations range(2, n+1) range 2 n+1 n 1 2 for j in range(delta):
            kumi = kumiawase[j]
            star.append(kumi)
            cnt += 1
     j range(delta) range delta kumi = kumiawase[j] kumi kumiawase[j] kumiawase j star.append(kumi) star.append star append kumi cnt += 1 cnt 1 print(cnt) print cnt for pair in star:
        print(*pair, sep=" ") pair star print(*pair, sep=" ") print *pair pair sep=" " sep " " print(-1) print -1 cnt += 1 1 cnt star = [] [] star ans = [] [] ans kumi = kumiawase[j] kumiawase[j] kumi delta = max_k - k max_k - k delta cnt = 0 0 cnt kumiawase = list(combinations(range(2, n+1), 2)) list(combinations(range(2, n+1), 2)) kumiawase k = map(int, input().split()) map(int, input().split()) k max_k = (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) // 2 max_k cnt += 1 1 cnt n, k = map(int, input().split()) map(int, input().split()) n
from itertools import combinations

n, k = map(int, input().split())
star = []
max_k = (n - 1) * (n - 2) // 2
delta = max_k - k
cnt = 0
if k <= max_k:
    ans = []
    for i in range(2, n + 1):
        star.append((1, i))
        cnt += 1

    if delta > 0:
        kumiawase = list(combinations(range(2, n+1), 2))
        for j in range(delta):
            kumi = kumiawase[j]
            star.append(kumi)
            cnt += 1
    print(cnt)
    for pair in star:
        print(*pair, sep=" ")
else:
    print(-1)
