#include <bits/stdc++.h>
#define rep(_i, _j) for(int _i = 1; _i <= _j; ++_i)
const int inf = 0x3f3f3f3f;
typedef long long LL;
typedef double DB;
using namespace std;
const int maxn = 10000 + 1000 + 100;
int n, m, v[maxn];
set<int> s0, s2;
set<int>::iterator iter0, iter2;
void change(int p, int d) {
if(v[p] == 0) s0.erase(p);
if(v[p] == 2) s2.erase(p);
v[p] += d;
printf("%d %d ", p, v[p]);
if(v[p] == 0) s0.insert(p);
if(v[p] == 2) s2.insert(p);
}
int main() {
scanf("%d%d", &n, &m);
++n;
for(int i = 0; i < n + m; ++i) {
s0.insert(i);
v[i] = 0;
}
s2.insert(n + m);
for(int i = 1, p; i <= m; ++i) {
scanf("%d", &p);
iter2 = s2.upper_bound(p);
iter0 = s0.upper_bound(*iter2);
--iter0;
if(*iter0 <= p) {
printf("3 ");
change(p, 1);
change(*iter2, -2);
change(*iter2 + 1, +1);
} else if(v[p] > 0) {
printf("2 ");
change(p, -1);
change(p + 1, 1);
} else {
printf("1 ");
change(p, 1);
}
puts("");
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgcmVwKF9pLCBfaikgZm9yKGludCBfaSA9IDE7IF9pIDw9IF9qOyArK19pKQpjb25zdCBpbnQgaW5mID0gMHgzZjNmM2YzZjsKdHlwZWRlZiBsb25nIGxvbmcgTEw7CnR5cGVkZWYgZG91YmxlIERCOwp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgbWF4biA9IDEwMDAwICsgMTAwMCArIDEwMDsKaW50IG4sIG0sIHZbbWF4bl07CnNldDxpbnQ+IHMwLCBzMjsKc2V0PGludD46Oml0ZXJhdG9yIGl0ZXIwLCBpdGVyMjsKdm9pZCBjaGFuZ2UoaW50IHAsIGludCBkKSB7CglpZih2W3BdID09IDApIHMwLmVyYXNlKHApOwoJaWYodltwXSA9PSAyKSBzMi5lcmFzZShwKTsKCXZbcF0gKz0gZDsKCXByaW50ZigiJWQgJ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