#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
const ll col = 7, osn = 4;
vector<vector<ll>> devise_strategy(ll n) {
vector<vector<ll>> ans(col * (osn + 1), vector<ll>(n + 1));
for (ll i = 0; i < col * (osn + 1); i++) {
ll t = i % (osn + 1);
ll nb = i / (osn + 1);
if (t == 0) {
ans[i][0] = 0;
} else {
ans[i][0] = 1;
}
for (ll j = 1; j <= n; j++) {
ll nx = j - 1;
for (ll k = 0; k < col - nb - 1; k++) {
nx /= osn;
}
nx %= osn;
if (t == 0) {
ans[i][j] = i + nx + 1;
} else {
t--;
if (nx == t) {
ans[i][j] = i - t + osn;
if (ans[i][j] >= ans.size()) {
ans[i][j] = i;
}
}
if (nx > t) {
ans[i][j] = -1;
}
if (nx < t) {
ans[i][j] = -2;
}
t++;
}
}
}
return ans;
}