import java.util.*;
abstract class stack
{
public abstract void draw();
}
class push extends stack
{
public void draw(String a)
{
s[top++]=a;
if(top>=199)
{
return;
}
}
@Override
public void draw()
{
return;
}
}
class pop extends stack
{
public void draw()
{
if(top==-1)
return;
return s[top--];
}
}
class view extends stack
{
public void draw()
{
System.out.println(s[top]);
}
}
public class Main
{
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
int n;
String a;
String name;
char key[] = new char[20];
push u = new push();
pop p = new pop();
view v = new view();
int stack;
stack[] s = new stack[200];
int top=-1;
System.out.println("pop(1) push(2) view(3) finish(4)");
n = t.nextInt();
while(n!=4)
{
if(n==2)
{
System.out.println("숫자를 고르시오");
a = t.next();
u.draw(a);
}
else if(n==2)
{
p.draw();
}
else if(n==3)
{
v.draw();
}
n = t.nextInt();
}
}
}