//03-树3 Tree Traversals Againimport java.util.Scanner;import java.util.Stack;classnode{
int number =0;
int left =30;
int right =30;}publicclassMain{
final static int Max_Size =30;static int count =0;static node[]Read(Scanner s){
Stack<Integer> stack =newStack<Integer>();
String prec, curc;
int n = s.nextInt();
node[]T=newnode[Max_Size +1];
int x =0;
int f =1;
prec = s.next();
int top =0;
x = s.nextInt();T[0]=newnode();T[0].number = x;
top ++;
stack.push(0);if(n ==1){
curc = s.next();}for(int i =0; i <2* n -2; i ++){
curc = s.next();if(curc.equals("Push")){
x = s.nextInt();if(prec.equals("Push")){T[f]=newnode();T[f -1].left = f;T[f].number = x;
stack.push(f);
f ++;
top ++;}elseif(prec.equals("Pop")){T[f]=newnode();T[f].number = x;T[top].right = f;
stack.push(f);
f ++;
top ++;}
prec ="Push";}if(curc.equals("Pop")){
top = stack.pop();
prec ="Pop";}}returnT;}staticvoidPostOrderTraversal(node N, node[]T){
int n =0;while(T[n]!=null){
n ++;}if(N!=null){PostOrderTraversal(T[N.left],T);PostOrderTraversal(T[N.right],T);
System.out.print(N.number);
count ++;if(count < n){
System.out.print(" ");}}}publicstaticvoidmain(String args[]){
Scanner s =newScanner(System.in);
node[]T=Read(s);
s.close();//System.out.println();PostOrderTraversal(T[0],T);}}