#include <iostream>
using namespace std;
const int MAX_SIZE = 10;
int main() {
int n, m, v[MAX_SIZE + 1], x;
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> v[i];
}
for (int j = 1; j <= m; ++j) {
int k;
cin >> k;
if (k == 1) {
if (n > 0) {
--n;
for (int i = 1; i <= n; ++i) {
v[i] = v[i + 1];
}
}
} else if (k == 2) {
if (n < MAX_SIZE) {
cin >> x;
++n;
v[n] = x;
}
}
}
cout << n << "\n";
for (int i = 1; i <= n; ++i) {
cout << v[i] << " ";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IE1BWF9TSVpFID0gMTA7CgppbnQgbWFpbigpIHsKICAgIGludCBuLCBtLCB2W01BWF9TSVpFICsgMV0sIHg7CiAgICBjaW4gPj4gbiA+PiBtOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CiAgICAgICAgY2luID4+IHZbaV07CiAgICB9CiAgICBmb3IgKGludCBqID0gMTsgaiA8PSBtOyArK2opIHsKICAgICAgICBpbnQgazsKICAgICAgICBjaW4gPj4gazsKICAgICAgICBpZiAoayA9PSAxKSB7CiAgICAgICAgICAgIGlmIChuID4gMCkgewogICAgICAgICAgICAgICAgLS1uOwogICAgICAgICAgICAgICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbjsgKytpKSB7CiAgICAgICAgICAgICAgICAgICAgdltpXSA9IHZbaSArIDFdOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfSBlbHNlIGlmIChrID09IDIpIHsgCiAgICAgICAgICAgIGlmIChuIDwgTUFYX1NJWkUpIHsgCiAgICAgICAgICAgICAgICBjaW4gPj4geDsKICAgICAgICAgICAgICAgICsrbjsKICAgICAgICAgICAgICAgIHZbbl0gPSB4OwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgY291dCA8PCBuIDw8ICJcbiI7CiAgICBm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