#include <iostream>
using namespace std;
int main() {
const int MAX_SIZE = 1300000;
const int MAX_OPERATIONS = 400000;
int n, v[MAX_SIZE + 2], m, w[MAX_OPERATIONS + 1];
cin >> n >> m;
for (int j = 1; j <= n; ++j) {
cin >> v[j];
}
int x, count = 1;
for (int i = 1; i <= m; ++i) {
cin >> w[i];
if (w[i] == 1 && n >= count) {
++count;
} else if (w[i] == 2) {
cin >> x;
++n;
v[n] = x;
}
}
if (count >= n) {
cout << 0;
} else {
cout << n - count + 1 << "\n";
for (int j = count; j <= n; ++j) {
cout << v[j] << " ";
}
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7Cgljb25zdCBpbnQgTUFYX1NJWkUgPSAxMzAwMDAwOwoJY29uc3QgaW50IE1BWF9PUEVSQVRJT05TID0gNDAwMDAwOwoJaW50IG4sIHZbTUFYX1NJWkUgKyAyXSwgbSwgd1tNQVhfT1BFUkFUSU9OUyArIDFdOwoJY2luID4+IG4gPj4gbTsKCWZvciAoaW50IGogPSAxOyBqIDw9IG47ICsraikgewoJCWNpbiA+PiB2W2pdOwoJfQoJaW50IHgsIGNvdW50ID0gMTsKCWZvciAoaW50IGkgPSAxOyBpIDw9IG07ICsraSkgewoJICAgIGNpbiA+PiB3W2ldOwoJICAgIGlmICh3W2ldID09IDEgJiYgbiA+PSBjb3VudCkgewoJICAgICAgICArK2NvdW50OwoJICAgIH0gZWxzZSBpZiAod1tpXSA9PSAyKSB7CgkgICAgICAgIGNpbiA+PiB4OwoJICAgICAgICArK247CgkgICAgICAgIHZbbl0gPSB4OwoJICAgIH0KCX0KCWlmIChjb3VudCA+PSBuKSB7CgkgICAgY291dCA8PCAwOwoJfSBlbHNlIHsKCSAgY291dCA8PCBuIC0gY291bnQgICsgMSA8PCAiXG4iOyAKCSAgZm9yIChpbnQgaiA9IGNvdW50OyBqIDw9IG47ICsraikgewoJICAgICAgY291dCA8PCB2W2pdIDw8ICIgIjsKCX0KCX0KCXJldHVybiAwOwp9