#include <iostream>
using namespace std;
const int MAX_SIZE = 10000;
int main() {
int n, m, v[MAX_SIZE], k, x;
cin >> n;
for (int i = 0; i < n; ++i) {
cin >> v[i];
}
int size = n;
cin >> m;
while (m--) {
cin >> k;
if (k == 1) {
cin >> x;
if (size < MAX_SIZE) {
v[size] = x;
++size;
}
} else if (k == 2) {
if (size > 0) {
--size;
}
}
}
cout << size << "\n";
for (int i = 0; i < size; ++i) {
cout << v[i] << " ";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWF9TSVpFID0gMTAwMDA7CgppbnQgbWFpbigpIHsKICAgIGludCBuLCBtLCB2W01BWF9TSVpFXSwgaywgeDsKICAgIGNpbiA+PiBuOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKICAgICAgICBjaW4gPj4gdltpXTsKICAgIH0KICAgIGludCBzaXplID0gbjsKICAgIGNpbiA+PiBtOyAKICAgIHdoaWxlIChtLS0pIHsKICAgICAgICBjaW4gPj4gazsgCiAgICAgICAgaWYgKGsgPT0gMSkgewogICAgICAgICAgICBjaW4gPj4geDsgCiAgICAgICAgICAgIGlmIChzaXplIDwgTUFYX1NJWkUpIHsKICAgICAgICAgICAgICAgIHZbc2l6ZV0gPSB4OyAKICAgICAgICAgICAgICAgICsrc2l6ZTsgCiAgICAgICAgICAgIH0KICAgICAgICB9IGVsc2UgaWYgKGsgPT0gMikgewogICAgICAgICAgICBpZiAoc2l6ZSA+IDApIHsKICAgICAgICAgICAgICAgIC0tc2l6ZTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgc2l6ZSA8PCAiXG4iOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBzaXplOyArK2kpIHsKICAgICAgICBjb3V0IDw8IHZbaV0gPDwgIiAiOyAKICAgIH0KICAgIHJldHVybiAwOwp9
MwoxIDIgMyAKMwoyCjIKMgotMAoKNwo1IC00IDAgLTcgNyA3IDIKNQoyCjEgMTAwCjIKMSAwCjEgMwotOAo1IC00IDAgLTcgNyA3IDAgMwoKMwoxIDIgMyAKNgoxIDkKMSA5CjEgOQoxIDkKMSA5CjEgOQotOQoxIDIgMyA5IDkgOSA5IDkgOQoKaHR0cHM6Ly9sLi4uY29udGVudC1hdmFpbGFibGUtdG8tYXV0aG9yLW9ubHkuLi5lLnJvL3N1Ym1pc3Npb24vMTU5MjU1MAo=
3
1 2 3
3
2
2
2
-0
7
5 -4 0 -7 7 7 2
5
2
1 100
2
1 0
1 3
-8
5 -4 0 -7 7 7 0 3
3
1 2 3
6
1 9
1 9
1 9
1 9
1 9
1 9
-9
1 2 3 9 9 9 9 9 9
https://l...content-available-to-author-only...e.ro/submission/1592550