#include<bits/stdc++.h>
using namespace std;
int main() {
    int n, i = 0;
    cin >> n;
     
    for (int num = 2; num <= n; ++num) {
        bool j = true;
        for (int i = 2; i * i <= num; ++i) {
            if (num % i == 0) {
                j = false;
                break;
            }
        }
        if (j) {
            cout << num << " ";
            if (++i % 5 == 0) cout << endl;
        }
    }
}
/**************************************************************
	Problem: 1064
	User: wengsihan
	Language: C++
	Result: Accepted
	Time:12 ms
	Memory:2072 kb
****************************************************************/