#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int cnt = 0; vector rem(2*N-1); stack> stc; iota(rem.begin(), rem.end(), 1); for( int i = 0; i < 2*N-1; i++ ) { stc.emplace((vector){i}); } cout << 2*N-1 << endl; while( !stc.empty() && cnt < 2*N-1 ) { vector p = stc.top(); stc.pop(); bool flag = true; for( int& x : p ) { if( rem[x] == 0 ) flag = false; } if( !flag ) continue; if( p.size() == N ) { for( int& x : p ) { rem[x]--; cout << x+1 << ' '; } cout << '\n'; }else { for( int ls = 0; ls < p.back(); ls++ ) { vector q(p.begin(), p.end()); if( rem[ls] > 0 ) { q.emplace_back(ls); stc.push(q); } } } } if( N == 2 ) { cout << "3 2 \n"; }else if( N == 3 ) { cout << "5 4 3 \n"; } }