#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define dd(x) cout<<#x<<" is "<<x<<endl;
#define dd2(x,y) cout<<#x<<" is "<<x<<" "<<#y<<" is "<<y<<endl;
typedef pair<int,int> pii;
signed main(){
//ios::sync_with_stdio(0); cin.tie(0);
int p,n; cin>>p>>n;
if(p==1){
cout<<631<<endl;
int cnt[320] = {}, val = 316;
for(int i=0; i<n-1; i++){
int id; cin>>id;
int group = id/316;
cnt[group]++;
if(group == 316 and cnt[group] == 144){
cout<<val<<endl;
val++;
} else if(cnt[group] == 316){
cout<<val<<endl;
val++;
} else {
cout<<cnt[group]<<endl;
}
}
} else {
int cnt[640] = {};
int a[n];
int tg = -1;
for(int i=0; i<n; i++) cin>>a[i];
for(int i=0; i<n; i++){
if(a[i] >= 316){
cnt[a[i]]++;
if(cnt[a[i]] == 2){
tg = a[i];
break;
}
}
}
if(tg != -1){
for(int i=0; i<n; i++){
if(a[i] == tg) cout<<i<<" ";
}
cout<<endl;
return 0;
}
int arr[320][320] = {};
pii target;
for(int i=0; i<n; i++){
if(a[i] >= 316) continue;
int group = i/316;
arr[group][a[i]]++;
if(arr[group][a[i]] == 2){
target = {group,a[i]};
break;
}
}
int st = target.fi*316, en = (target.fi+1)*316;
for(int i=st; i<en; i++){
if(a[i] == target.se) cout<<i<<" ";
}
cout<<endl;
}
return 0;
}