n, k = map(int, input().split())


MAX_PAIR = (n-1)*(n-2)//2
if MAX_PAIR < k:
    print(-1)
else:
    m = n-1+MAX_PAIR-k
    print(m)
    for v2 in range(2, n+1):
        print(1, v2)
        m -= 1
    if m == 0:
        exit()

    for v in range(2, n):
        for v2 in range(v+1, n+1):
            print(v, v2)
            m -= 1
            if m == 0:
                exit() n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k MAX_PAIR = (n-1)*(n-2)//2 MAX_PAIR (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 if MAX_PAIR < k:
    print(-1)
else:
    m = n-1+MAX_PAIR-k
    print(m)
    for v2 in range(2, n+1):
        print(1, v2)
        m -= 1
    if m == 0:
        exit()

    for v in range(2, n):
        for v2 in range(v+1, n+1):
            print(v, v2)
            m -= 1
            if m == 0:
                exit() MAX_PAIR < k MAX_PAIR k print(-1) print -1 m = n-1+MAX_PAIR-k m n-1+MAX_PAIR-k n-1+MAX_PAIR n-1 n 1 MAX_PAIR k print(m) print m for v2 in range(2, n+1):
        print(1, v2)
        m -= 1
     v2 range(2, n+1) range 2 n+1 n 1 print(1, v2) print 1 v2 m -= 1 m 1 if m == 0:
        exit()

     m == 0 m 0 exit() exit for v in range(2, n):
        for v2 in range(v+1, n+1):
            print(v, v2)
            m -= 1
            if m == 0:
                exit() v range(2, n) range 2 n for v2 in range(v+1, n+1):
            print(v, v2)
            m -= 1
            if m == 0:
                exit() v2 range(v+1, n+1) range v+1 v 1 n+1 n 1 print(v, v2) print v v2 m -= 1 m 1 if m == 0:
                exit() m == 0 m 0 exit() exit n, k = map(int, input().split()) map(int, input().split()) n m -= 1 1 m MAX_PAIR = (n-1)*(n-2)//2 (n-1)*(n-2)//2 MAX_PAIR k = map(int, input().split()) map(int, input().split()) k m = n-1+MAX_PAIR-k n-1+MAX_PAIR-k m m -= 1 1 m
n, k = map(int, input().split())


MAX_PAIR = (n-1)*(n-2)//2
if MAX_PAIR < k:
    print(-1)
else:
    m = n-1+MAX_PAIR-k
    print(m)
    for v2 in range(2, n+1):
        print(1, v2)
        m -= 1
    if m == 0:
        exit()

    for v in range(2, n):
        for v2 in range(v+1, n+1):
            print(v, v2)
            m -= 1
            if m == 0:
                exit()