Link to this code: https://cses.fi/paste/08eda841e0f99e2121bc4c/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define M 1000000007
# define endl '\n'
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
void grayCode(string s,int i,int n)
{
    if(i==n)
    {
        cout<<s<<endl;
        return;
    }
    
    s.push_back('0');
    grayCode(s,i+1,n);
    s.pop_back();
    s.push_back('1');
    grayCode(s,i+1,n);
    
}

int main() {
    
// 	ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
	
	int n;cin>>n;
	string s = "";
	grayCode(s,0,n);
   
	return 0;
}