#include <iostream>
using namespace std;
int main() {
int n, v[10000], 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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgbiwgdlsxMDAwMF0sIG0sIGssIHg7CiAgICBjaW4gPj4gbjsKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47ICsraSkgewogICAgICAgIGNpbiA+PiB2W2ldOwogICAgfQogICAgY2luID4+IG07CiAgICBmb3IgKGludCBqID0gMTsgaiA8PSBtOyArK2opIHsKICAgICAgICBjaW4gPj4gazsKICAgICAgICBpZiAoayA9PSAxKSB7CiAgICAgICAgICAgIGNpbiA+PiB4OwogICAgICAgICAgICArK247CiAgICAgICAgICAgIHZbbl0gPSB4OwogICAgICAgIH0KICAgICAgICBpZiAoayA9PSAyKSB7CiAgICAgICAgICAgIC0tbjsKICAgICAgICB9CiAgICB9CiAgICBjb3V0IDw8IG4gPDwgIlxuICI7CiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyArK2kpIHsKICAgICAgICBjb3V0IDw8IHZbaV0gPDwgIiAiOwogICAgfQogICAgcmV0dXJuIDA7Cn0=