N,Q = map(int,input().split())
A = [a for a in range(1,N+1)]
for i in range(1,Q+1):
tmp = []
tmp = input().split()
if tmp[0] == 'reverse':
A.reverse()
elif tmp[0] == 'swap':
num = A[tmp[1]+1]
A[tmp[1]+1] = A[tmp[2]+1]
A[tmp[2]+1] = num
elif tmp[0] == 'resize':
c = int(tmp[1])
A = A[:c]
print(*A,sep="\n")