import java.util.LinkedList;
import java.util.Scanner;
public class Main {
public static void main (String [] args) {
Scanner cin=new Scanner(System.in);
LinkedList<Integer> linklist=new LinkedList();
while(cin.hasNext()) {
int n=cin.nextInt();
for(int i=0;i<n;i++) {
String a=cin.next();
char c=a.charAt(0);
if(c=='O') {
if(!linklist.isEmpty()) linklist.removeFirst();
}
if(c=='P') {
linklist.addFirst(cin.nextInt());
}
if(c=='A') {
if(!linklist.isEmpty()) System.out.println(linklist.getFirst());
else System.out.println("E");
}
}
System.out.println("");
}
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.