#include <iostream>
char *v;
size_t j, m;
void recursie() {
if (j == m)
std::cout << v << '\n';
else for (size_t i = '1'; i <= '3'; ++i) {
v[j] = i;
++j;
recursie();
--j;
}
}
int main() {
std::cin >> m;
v = new char[m + 1]();
recursie();
delete[] v;
}