T=[0,9,15,20,25,30,35,40,44,48,52,56,60,65,70,75,80,85,92,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]=d else:a.append(str(L[p])+" "+str(d)) Z[p]+=1 if Z[p]>=4:Z[p]=0 print(len(a)) if len(a)>0:print("\n".join(a))