#include <iostream>
using namespace std;
const int MAX_SIZE = 10000;
int main() {
int n, v[MAX_SIZE + 1], m, k, x;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> v[i];
}
cin >> m;
if(m <= MAX_SIZE){
for (int j = 1; j <= m; ++j) {
cin >> k;
if (k == 1) {
if (n < MAX_SIZE) {
cin >> x;
++n;
v[n] = x;
}
}
if (k == 2) {
if( n> 0){
--n;
}
}
}}
cout << n << "\n ";
for (int i = 1; i <= n; ++i) {
cout << v[i] << " ";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWF9TSVpFID0gMTAwMDA7CgppbnQgbWFpbigpIHsKICAgIGludCBuLCB2W01BWF9TSVpFICsgMV0sIG0sIGssIHg7CiAgICBjaW4gPj4gbjsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewogICAgICAgIGNpbiA+PiB2W2ldOwogICAgfQogICAgY2luID4+IG07CiAgICBpZihtIDw9IE1BWF9TSVpFKXsKICAgIGZvciAoaW50IGogPSAxOyBqIDw9IG07ICsraikgewogICAgICAgIGNpbiA+PiBrOwogICAgICAgIGlmIChrID09IDEpIHsKICAgICAgICAgICAgaWYgKG4gPCBNQVhfU0laRSkgewogICAgICAgICAgICAgICAgY2luID4+IHg7CiAgICAgICAgICAgICAgICArK247CiAgICAgICAgICAgICAgICB2W25dID0geDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAoayA9PSAyKSB7CiAgICAgICAgICAgIGlmKCBuPiAwKXsKICAgICAgICAgICAgLS1uOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfX0KICAgIGNvdXQgPDwgbiA8PCAiXG4gIjsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewogICAgICAgIGNvdXQgPDwgdltpXSA8PCAiICI7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==
MyAxIDIgMyA0IDEgYSAxIDQuNSAyIDIKCjUgMTAgMjAgMzAgNDAgNTAgNyAxIDYwIDIgMSA3MCAyIDEgODAgMiAxIDkwLS02CiAxMCAyMCAzMCA0MCA1MCA5MCAgCgo1CiAxMDAwMDAgMjAwMDAwIDMwMDAwMCA0MDAwMDAgNTAwMDAwIAozIAoyIAoxIDEwMDAwMDAgCjEgMjAwMDAwMC0tNgogMTAwMDAwIDIwMDAwMCAzMDAwMDAgNDAwMDAwIDEwMDAwMDAgMjAwMDAwMCAKCjQgCjUgMTAgMTUgMjAgCjQgCjIgCjEgLTI1IAoyIC0tMiA1IDEwCjI=
3 1 2 3 4 1 a 1 4.5 2 2
5 10 20 30 40 50 7 1 60 2 1 70 2 1 80 2 1 90--6
10 20 30 40 50 90
5
100000 200000 300000 400000 500000
3
2
1 1000000
1 2000000--6
100000 200000 300000 400000 1000000 2000000
4
5 10 15 20
4
2
1 -25
2 --2 5 10
2