Huseyn has many things to do at ADA University. He puts them into his queue. Anyway he is very indecisive, so sometimes he uses the front, sometimes the back and sometimes he decides to reverse it.
The first line contains the number of queries q~(1 \le q \le 10^5). Each of them contains one of the following commands
back — Print number from back and then erase it;
front — Print number from front and then erase it;
reverse — Reverses all elements in queue;
push_back n — Add element n~(0 \le n \le 100) to back;
toFront n — Put element n~(0 \le n \le 100) to front
For each back / front query print appropriate number.
If the queue is empty when processing such a query, print "Nothing to do in ADA" instead.
Example 1