n = int(input()) count = [0]*90 l = [[] for i in range(90)] for i in range(n): a,b = map(int,input().split()) x = a%9 y = b%10 if a%18 >= 9: y = (y+5)%10 count[x*10+y] += 1 l[x*10+y].append(i+1) print(max(count)) ind = count.index(max(count)) for i in l[ind]: print(i)