#include <iostream>
using namespace std;
int main() {
int n, v[10001], 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) {
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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgbiwgdlsxMDAwMV0sIG0sIGssIHg7CgljaW4gPj4gbjsKCWZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewoJCWNpbiA+PiB2W2ldOwoJfQoJY2luID4+IG07Cglmb3IgKGludCBqID0gMTsgaiA8PSBtOyArK2opIHsKCQljaW4gPj4gazsKCQlpZihrID09IDEpIHsKCQkJY2luID4+IHg7CgkJCSsrbjsKCQkJdltuXSA9IHg7CgkJfQoJCWlmKGsgPT0gMikgewoJCQktLW47CgkJfQoJfQoJY291dCA8PCBuIDw8ICJcbiAiOwoJZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CgkJY291dCA8PCB2W2ldIDw8IiAiOwoJfQoJcmV0dXJuIDA7Cn0=