//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << "[" << H << "]";
debug_out(T...);
}
#ifdef dddxxz
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
#define SZ(s) ((int)s.size())
clock_t startTime;
double getCurrentTime() {
return (double) (clock() - startTime) / CLOCKS_PER_SEC;
}
typedef long long ll;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
const double eps = 0.00001;
const int MOD = 1e9 + 7;
const int INF = 1000000101;
const long long LLINF = 1223372000000000555;
const int N = 1e6 + 3e1;
const int M = 1111;
vector<int> A, B, C;
int ans[N];
void out(){
int a = 0, b = 0, c = 0;
int n = A.size() + B.size() + C.size();
for (int i : A) ans[i] = 1, a += i;
for (int i : B) ans[i] = 2, b += i;
for (int i : C) ans[i] = 3, c += i;
for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
assert(a + 1 == b && b + 1 == c);
exit(0);
}
void solve(int TC) {
int n;
cin >> n;
if (n * (n + 1) % 6 != 0 || n == 2){
cout << "IMPOSSIBLE";
return;
}
if (n % 6 == 0){
A = {1, 5}, B = {3, 4}, C = {2, 6};
for (int i = 7; i <= n; i++){
if (i % 6 == 1 || i % 6 == 0) A.push_back(i);
if (i % 6 == 2 || i % 6 == 5) B.push_back(i);
if (i % 6 == 3 || i % 6 == 4) C.push_back(i);
}
out();
}
if (n % 6 == 2){
A = {1, 3, 7}, B = {4, 8}, C = {2, 5, 6};
for (int i = 9; i <= n; i++){
if (i % 6 == 3 || i % 6 == 2) A.push_back(i);
if (i % 6 == 4 || i % 6 == 1) B.push_back(i);
if (i % 6 == 5 || i % 6 == 0) C.push_back(i);
}
out();
}
if (n % 6 == 3){
A = {1}, B = {2}, C = {3};
for (int i = 4; i <= n; i++){
if (i % 6 == 4 || i % 6 == 3) A.push_back(i);
if (i % 6 == 5 || i % 6 == 2) B.push_back(i);
if (i % 6 == 0 || i % 6 == 1) C.push_back(i);
}
out();
}
if (n % 6 == 5){
A = {1, 3}, B = {5}, C = {2, 4};
for (int i = 6; i <= n; i++){
if (i % 6 == 0 || i % 6 == 5) A.push_back(i);
if (i % 6 == 1 || i % 6 == 4) B.push_back(i);
if (i % 6 == 2 || i % 6 == 3) C.push_back(i);
}
out();
}
}
int main() {
startTime = clock();
ios_base::sync_with_stdio(false);
bool llololcal = false;
#ifdef dddxxz
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
llololcal = true;
#endif
int TC = 1;
//cin >> TC;
for (int test = 1; test <= TC; test++) {
debug(test);
solve(test);
}
if (llololcal) cerr << endl << "Time: " << getCurrentTime() * 1000 << " ms" << endl;
return 0;
}