import std.stdio, std.string, std.algorithm, std.array;

void bracket (int count)
{
	for (int i = count; i >= 1; i--)
	{
		string s = "";
		s ~= replicate("(", i);
		s ~= replicate(")", i);
		s ~= replicate("(", count - i);
		s ~= replicate(")", count - i);
		writeln(s);
	}
}

void main()
{
    int t;
    scanf("%d", &t);
    getchar();
    foreach(_; 0..t){
	int n;
	scanf("%d", &n);
	bracket(n);
    }
}
