n,m=map(int,input().split())
a=[]
b=[]
s=[]
for i in range(n):
a.append(i+1)
for i in range(m):
b.append(list(map(int,input().split())))
for i in range(m):
c=b[i][1]
if b[i][0]==0:
s=a[:c]
s.sort(reverse=True)
a=a[c:]
a=s+a
if b[i][0]==1:
s=a[c-1:]
a=a[:c-1]
s.sort()
a=a+s
for i in range(n):
print(a[i],end=' ')
只得了60分,后面运行超时