#include<bits/stdc++.h>
using namespace std;
void gen(vector&vs , string &s , int n , int open , int close)
{
if(open == close && open == n)
{
vs.push_back(s);
return;
}
if(open < n)
{
s.push_back(’(’);
gen(vs, s , n , open + 1 ,close);
s.pop_back();
}
if(close < open)
{
s.push_back(’)’);
gen(vs, s, n , open , close + 1);
s.pop_back();
}
}
vector<string> generateParenthesis(int n)
{
vector<string>vs;
string s;
gen(vs , s , n , 0 , 0);
return vs;
}
int main()
{
int n;
cin>>n;
vector<string>ans = generateParenthesis(n);
for(int i=0;i<ans.size();i++)
{
cout<<ans[i]<<" ";
cout<<endl;
}
}