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