n, k = map(int, input().split())
if k > (n - 1) * (n - 2) / 2:
    print(-1)
else:
    #頂点1を中心のスター型グラフを作る
    ans = []
    appended_edges = set()
    for i in range(2,n+1):
        ans.append([1,i])
        appended_edges.add((1,i))
    #そのあとで、いらない分だけ頂点をつなげばいい
    flag = False
    #いま、最短距離が2の頂点の数
    count = (n-1)*(n-2) / 2
    for i in range(2,n+1):
        for j in range(i,n+1):
            if k == count:
                flag = True
                break
            if (i,j) not in appended_edges and i != j:
                ans.append([i,j])
                appended_edges.add((i,j))
                count -= 1
        if flag:
            break
    print(len(ans))
    for i in range(len(ans)):
        print("{} {}".format(ans[i][0], ans[i][1])) 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)
else:
    #頂点1を中心のスター型グラフを作る
    ans = []
    appended_edges = set()
    for i in range(2,n+1):
        ans.append([1,i])
        appended_edges.add((1,i))
    #そのあとで、いらない分だけ頂点をつなげばいい
    flag = False
    #いま、最短距離が2の頂点の数
    count = (n-1)*(n-2) / 2
    for i in range(2,n+1):
        for j in range(i,n+1):
            if k == count:
                flag = True
                break
            if (i,j) not in appended_edges and i != j:
                ans.append([i,j])
                appended_edges.add((i,j))
                count -= 1
        if flag:
            break
    print(len(ans))
    for i in range(len(ans)):
        print("{} {}".format(ans[i][0], ans[i][1])) 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 ans = [] ans [] appended_edges = set() appended_edges set() set for i in range(2,n+1):
        ans.append([1,i])
        appended_edges.add((1,i))
    #そのあとで、いらない分だけ頂点をつなげばいい
     i range(2,n+1) range 2 n+1 n 1 ans.append([1,i]) ans.append ans append [1,i] 1 i appended_edges.add((1,i)) appended_edges.add appended_edges add (1,i) 1 i flag = False flag False count = (n-1)*(n-2) / 2 count (n-1)*(n-2) / 2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 for i in range(2,n+1):
        for j in range(i,n+1):
            if k == count:
                flag = True
                break
            if (i,j) not in appended_edges and i != j:
                ans.append([i,j])
                appended_edges.add((i,j))
                count -= 1
        if flag:
            break
     i range(2,n+1) range 2 n+1 n 1 for j in range(i,n+1):
            if k == count:
                flag = True
                break
            if (i,j) not in appended_edges and i != j:
                ans.append([i,j])
                appended_edges.add((i,j))
                count -= 1
         j range(i,n+1) range i n+1 n 1 if k == count:
                flag = True
                break
             k == count k count flag = True flag True break if (i,j) not in appended_edges and i != j:
                ans.append([i,j])
                appended_edges.add((i,j))
                count -= 1
         (i,j) not in appended_edges and i != j (i,j) not in appended_edges (i,j) i j appended_edges i != j i j ans.append([i,j]) ans.append ans append [i,j] i j appended_edges.add((i,j)) appended_edges.add appended_edges add (i,j) i j count -= 1 count 1 if flag:
            break
     flag break print(len(ans)) print len(ans) len ans for i in range(len(ans)):
        print("{} {}".format(ans[i][0], ans[i][1])) i range(len(ans)) range len(ans) len ans print("{} {}".format(ans[i][0], ans[i][1])) print "{} {}".format(ans[i][0], ans[i][1]) "{} {}".format "{} {}" format ans[i][0] [i] ans i 0 ans[i][1] [i] ans i 1 flag = True True flag count = (n-1)*(n-2) / 2 (n-1)*(n-2) / 2 count k = map(int, input().split()) map(int, input().split()) k flag = False False flag n, k = map(int, input().split()) map(int, input().split()) n count -= 1 1 count ans = [] [] ans appended_edges = set() set() appended_edges
n, k = map(int, input().split())
if k > (n - 1) * (n - 2) / 2:
    print(-1)
else:
    #頂点1を中心のスター型グラフを作る
    ans = []
    appended_edges = set()
    for i in range(2,n+1):
        ans.append([1,i])
        appended_edges.add((1,i))
    #そのあとで、いらない分だけ頂点をつなげばいい
    flag = False
    #いま、最短距離が2の頂点の数
    count = (n-1)*(n-2) / 2
    for i in range(2,n+1):
        for j in range(i,n+1):
            if k == count:
                flag = True
                break
            if (i,j) not in appended_edges and i != j:
                ans.append([i,j])
                appended_edges.add((i,j))
                count -= 1
        if flag:
            break
    print(len(ans))
    for i in range(len(ans)):
        print("{} {}".format(ans[i][0], ans[i][1]))
