#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int P, N;
cin >> P >> N;
if (P == 1) {
int K = 7;
cout << K << endl;
for (int i = 0; i < N - 1; i++) {
int idx;
cin >> idx;
int val = (i % K) + 1;
cout << val << endl;
}
}
else {
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
vector<int> score(N, 0);
for (int shift = 0; shift < 7; shift++) {
int mismatches = 0;
for (int i = 0; i < N; i++) {
int expected = ((i + shift) % 7) + 1;
if (A[i] != expected) mismatches++;
}
score[shift] = mismatches;
}
vector<pair<int,int>> best;
for (int i = 0; i < 7; i++) {
best.push_back({score[i], i});
}
sort(best.begin(), best.end());
int s1 = best[0].second;
int s2 = best[1].second;
cout << s1 << " " << s2 << "\n";
}
return 0;
}