import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) #input = sys.stdin.readline #n = int(input()) # #alist = [] input = sys.stdin.readline n,q = map(int,input().split()) h = [] c = collections.defaultdict(int) for i in range(q): t = input().split() if t[0] == '1': t,s,r = t r = int(r) heapq.heappush(h,(r,s)) c[s] = r if t[0] == '2': t,x = t x = int(x) n -= x if t[0] == '3': t,s,x = t x = int(x) n += x h.remove((c[s],s)) h.append((c[s] | (1<<40),s)) c[s] |= 1<<40 heapq.heapify(h) a = [] while len(h) > n: ans = heapq.heappop(h) ans = list(ans) if (ans[0] >> 40) & 1 == 1: ans[0] -= 1<<40 a.append((ans[0],ans[1])) a.sort() for k,l in a: print(l)