#Lutece3327. Shift the Permutation

Shift the Permutation

Description

There is a permutation of length nn, initially in ascending order from 11 to nn, i.e. permutation {1,2,,n}\{1,2,\ldots, n\}. Now, mm consecutive shift operations will be performed on this permutation. There are two types of operations:

  • a\texttt{a}: Move the last number in the permutation to the front.
  • b\texttt{b}: Move the third number in the permutation to the front.

The consecutive operations are represented in the form of kak\texttt{a} or kbk\texttt{b}, where kk is the number of times the operation is repeated. Given the sequence of mm consecutive operations, please output the resulting permutation after performing the operations.

Input

The first line contains two integers n,m (3n105,1m105)n,m\ (3\le n\le 10^5,1\le m\le 10^5), indicating the length of permutation and the number of operations.

The second line contains mm operations, each operation is a string formed in kak\texttt{a} or kbk\texttt{b} (1k1091\le k\le 10^9).

Output

Output nn integers in one line, indicating the resulting permutation.

Samples

4 3
3a 2b 2a
2 1 3 4

Note

  1. After operation 3a3\texttt{a}, the permutation becomes {2,3,4,1}\{2,3,4,1\}.
  2. After operation 2b2\texttt{b}, the permutation becomes {3,4,2,1}\{3,4,2,1\}.
  3. After operation 2a2\texttt{a}, the permutation becomes {2,1,3,4}\{2,1,3,4\}.

Resources

电子科技大学第十四届 ACM 趣味程序设计竞赛