#include <iostream>
using namespace std;
const int MAX_SIZE = 10000;
int main() {
int n, m, v[MAX_SIZE + 1], k, x, t;
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> v[i];
}
cin >> m;
while(m--) {
cin >> k;
if(k == 1) {
cin >> x;
++n;
v[n] = x;
} else {
--n;
}
}
t = n;
cout << t << "\n ";
for (int i = 1; i <= t; ++i) {
cout << v[i] <<" ";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWF9TSVpFID0gMTAwMDA7CgppbnQgbWFpbigpIHsKCWludCBuLCBtLCB2W01BWF9TSVpFICsgMV0sIGssIHgsIHQ7CgljaW4gPj4gbjsKCWZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewoJCWNpbiA+PiB2W2ldOwoJfQoJY2luID4+IG07Cgl3aGlsZShtLS0pIHsKCQljaW4gPj4gazsKCQlpZihrID09IDEpIHsKCQkJY2luID4+IHg7CgkJCSsrbjsKCQkJdltuXSA9IHg7CgkJfSBlbHNlIHsKCQkJLS1uOwoJCX0KCX0KCXQgPSBuOwoJY291dCA8PCB0IDw8ICJcbiAiOwoJZm9yIChpbnQgaSA9IDE7IGkgPD0gdDsgKytpKSB7CgkJY291dCA8PCB2W2ldIDw8IiAiOwoJfQoJcmV0dXJuIDA7Cn0=