1 #include<iostream>
2 #include<cstdio>
3 int s[10010];
4 using namespace std;
5 int main()
6 {
7 int n,a,b,top=0;
8 cin>>n;
9 for(int i=1;i<=n;++i)
10 {
11 scanf("%d",&a); //输入a
12 if(a==1){scanf("%d",&b);top++;s[top]=b;} //若a是1,则输入b栈顶++;
13 if(a==2){top--;} //若输入2,栈顶--;
14 }
15 if(top>0)cout<<s[top];
16 else if(top<=0)cout<<"impossible!"; //栈空时
17 return 0;
18 }