#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;
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) {
--n;
}
}
cout << n << "\n ";
for (int i = 1; i <= n; ++i) {
cout << v[i] << " ";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWF9TSVpFID0gMTAwMDA7CgppbnQgbWFpbigpIHsKICAgIGludCBuLCB2W01BWF9TSVpFICsgMV0sIG0sIGssIHg7CiAgICBjaW4gPj4gbjsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewogICAgICAgIGNpbiA+PiB2W2ldOwogICAgfQogICAgY2luID4+IG07CiAgICBmb3IgKGludCBqID0gMTsgaiA8PSBtOyArK2opIHsKICAgICAgICBjaW4gPj4gazsKICAgICAgICBpZiAoayA9PSAxKSB7CiAgICAgICAgCWlmKG4gPCBNQVhfU0laRSl7CiAgICAgICAgICAgIAljaW4gPj4geDsKICAgICAgICAgICAgCSsrbjsKICAgICAgICAgICAgCXZbbl0gPSB4OwogICAgICAgIAl9CiAgICAgICAgfQogICAgICAgIGlmIChrID09IDIpIHsKICAgICAgICAgICAgLS1uOwogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgbiA8PCAiXG4gIjsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewogICAgICAgIGNvdXQgPDwgdltpXSA8PCAiICI7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==
MwoxIDIgMwoyCjIKMgoKMQoxMDAwMAo5CjEgMQoxIDIKMSAzCjEgNAoxIDUKMSA2CjEgNwoxIDgKMSA5LTEwCiAxMDAwMCAxIDIgMyA0IDUgNiA3IDggOSAK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