#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
using PII=pair<ll,ll>;
using PIII=pair<int,pair<int,int>>;
const ld ESP = 1e-10;
const ld PI = acosl(-1);
const int N=1e5+10;
const int M=2e5+10;
// const int mod = 1000000007;
const int mod = 998244353;
//随机化
random_device rd;
mt19937 gen(rd());
uniform_int_distribution<> dis(1, 1000000000);
// cout<<fixed<<setprecision(10);


void solve(){
    // int x=999999999;
    // vector<pair<int,int>> ans;
    // for(int i=2;i*i<=x;i++){
    //     int cnt=0;
    //     while(x%i==0){
    //         cnt++;
    //         x/=i;
    //     }
    //     if(cnt){
    //         ans.push_back({i,cnt});
    //     }
    // }  
    // if(x)ans.push_back({x,1});
    // for(auto [p,cnt]:ans){
    //     cout<<p<<" "<<cnt<<'\n';
    // }
    // 3 4
    // 37 1
    // 333667 1
    int n;
    cin>>n;
    int cnt=n/3+n/37;
    if(n<=cnt*3){
        vector<int> v(n+1,0);
        vector<int> ans(n+1,-1);
        vector<int> pos;
        for(int i=2;i<=n;i+=3){
            pos.push_back(i);
        }
        if(n%3==1){
            pos.push_back(n);
        }
        int y=3,z=37;
        for(auto x:pos){
            if(y<=n){
                ans[x]=y;
                v[y]=1;
                y+=3;
            }else if(z<=n){
                ans[x]=z;
                v[z]=1;
                z+=37;
            }
        }
        int p=1;
        for(int i=1;i<=n;i++){
            if(ans[i]==-1){
                while(v[p]){
                    p++;
                }
                ans[i]=p;
                v[p]=1;
            }
        }
        for(int i=1;i<=n;i++){
            cout<<ans[i]<<" ";
        }
    }else{
        cout<<"Baka!"<<'\n';
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int _=1;
    // cin>>_;
    while(_--){
        solve();
    }
    return 0;
}