from bisect import bisect def f(x,y): ret=0 for i in range(L): ret+=pow(K,i)*((x%K+y%K)%K) x//=K y//=K return ret K,Q=map(int,input().split()) L=1 lg=1 while lg<10**10: lg*=K L+=1 used={0} ap=[0] for i in range(Q): t,x=map(int,input().split()) if t==1: if x in used: continue aft=set() for i in used: now=i for j in range(K): aft.add(now) now=f(now,x) used=aft ap=sorted(list(used)) elif t==2: if len(used)