#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main(void){
// freopen("input.txt", "r", stdin);
int P, n; cin>>P>>n;
int M = sqrt(n);
if(P == 1){
cout<<2*M - 1<<endl;
vector<int> sel(M, 0);
vector<int> bucketSize(M, M);
for(int i = 0; i<(n - (M*M)); i++) bucketSize[i] = M+1;
int x_count = M+1;
for(int i = 0; i<n-1; i++){
int ind; cin>>ind;
ind = (ind-1)/M;
if(sel[ind] < bucketSize[ind] - 1){
sel[ind] ++;
cout<<sel[ind]<<endl;
}
else{
sel[ind] ++;
cout<<x_count<<endl;
x_count++;
}
}
}
if(P == 2){
vector<int> v(n, 0);
for(int i = 0; i<n; i++) cin>>v[i];
// vector<pair<int, int>> bucketSize(M, {0, 0});
// bucketSize()
// for(int i = 0; i<(n- (M*M)); i++) bucketSize[i] = {bucketSize[i-1].second, bucketSize[i-1].second + M};
vector<pair<int, int>> freq(2*M, {-1, -1});
for(int i = 0; i<v.size(); i++){
if(freq[v[i]].first == -1) freq[v[i]].first = i;
else freq[v[i]].second = i;
}
for(int i = M+1; i<freq.size(); i++){
if(freq[i].second != -1){
cout<<freq[i].first<<' '<<freq[i].second<<endl;
return 0;
}
}
for(int i = 0; i<M; i++){
freq.assign(2*M+2, {-1, -1});
int b = M;
if((n-(M*M))>i) b++;
int st = (M*i) + min(i, n-(M*M));
for(int j = st; j<st+b; j++){
if(freq[v[j]].first == -1) freq[v[j]].first = j;
else{
cout<<freq[v[j]].first<<' '<<j<<endl;
return 0;
}
}
}
for(int i = 0; i<M; i++){
int b = M;
if((n-(M*M))>i) b++;
int st = (M*i) + min(i, n-(M*M));
for(int j = st; j<st+b; j++){
if(v[j] == b && b <= M){
cout<<j<<' '<<j<<endl;
}
}
}
}
return 0;
}