T=[0,8,15,20,25,30,35,40,44,48,52,56,60,65,70,75,80,85,93,101] Z=[0]*20 L=[0]*20 d=0 for t in range(int(input().split()[0])): N=map(int,input().split()[1:]) a=[] for i in N: d+=1 p=0 while T[p]<=i:p+=1 if Z[p]==0:L[p],Z[p]=d,1 else:a.append(str(Z[p])+" "+str(d)) if Z[p]>=4:Z[p]=0 print(len(a)) print("\n".join(a))