description: A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, bracket sequences "()()" and "(())" are regular (the resulting expressions are: "(1)+(1)" and "((1+1)+1)"), and ")(", "(" and ")" are not.
  
  You are given an integer n. Your goal is to construct and print exactly n different regular bracket sequences of length 2n.
  
  Input
  
  The first line contains one integer t (1 ≤ t ≤ 50) — the number of test cases.
  
  Each test case consists of one line containing one integer n (1 ≤ n ≤ 50).
  
  Output
  
  For each test case, print n lines, each containing a regular bracket sequence of length exactly 2n. All bracket sequences you output for a testcase should be different (though they may repeat in different test cases). If there are multiple answers, print any of them. It can be shown that it's always possible.
  
  Example
  
  Input
  
  
  3
  3
  1
  3
  
  
  Output
  
  
  ()()()
  ((()))
  (()())
  ()
  ((()))
  (())()
  ()(())
solution: import java.io.*;
  import java.util.Arrays;
  import java.util.StringTokenizer;
  
  public class A {
  
      // 注意不要用Arrays.sort()
      // 注意Math.pow可能导致精度问题
      // 注意int溢出问题
      static class Task {
  
          public void solve(int testNumber, InputReader in, PrintWriter out) {
              int t = in.nextInt();
              while ((t--) > 0) {
                  int n = in.nextInt();
                  for (int i = 1; i <= n; i++) {
                      int count = n / i;
                      int oldCount = count;
                      StringBuilder sb = new StringBuilder();
                      while ((count--) > 0) {
                          for (int j = 0; j < i; j++) {
                              sb.append('(');
                          }
                          for (int j = 0; j < i; j++) {
                              sb.append(')');
                          }
                      }
  
                      int left = (n - i * oldCount);
                      while ((left--) > 0) {
                          sb.append('(');
                          sb.append(')');
                      }
  
                      out.println(sb.toString());
                  }
              }
          }
      }
  
      private static void sort(double[] arr) {
          Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
          Arrays.sort(objArr);
          for (int i = 0; i < arr.length; i++) {
              arr[i] = objArr[i];
          }
      }
  
      private static void sortDesc(double[] arr) {
          Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
          Arrays.sort(objArr);
          for (int i = 0; i < arr.length; i++) {
              arr[i] = objArr[arr.length - i - 1];
          }
      }
  
      private static void sort(int[] arr) {
          Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
          Arrays.sort(objArr);
          for (int i = 0; i < arr.length; i++) {
              arr[i] = objArr[i];
          }
      }
  
      private static void sortDesc(int[] arr) {
          Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
          Arrays.sort(objArr);
          for (int i = 0; i < arr.length; i++) {
              arr[i] = objArr[arr.length - i - 1];
          }
      }
  
      private static void sort(long[] arr) {
          Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
          Arrays.sort(objArr);
          for (int i = 0; i < arr.length; i++) {
              arr[i] = objArr[i];
          }
      }
  
      private static void sortDesc(long[] arr) {
          Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
          Arrays.sort(objArr);
          for (int i = 0; i < arr.length; i++) {
              arr[i] = objArr[arr.length - i - 1];
          }
      }
  
      private static void solve() {
          InputStream inputStream = System.in;
          OutputStream outputStream = System.out;
          InputReader in = new InputReader(inputStream);
          PrintWriter out = new PrintWriter(outputStream);
          Task task = new Task();
          task.solve(1, in, out);
          out.close();
      }
  
      public static void main(String[] args) {
          new Thread(null, () -> solve(), "1", 1 << 26).start();
      }
  
      static class InputReader {
  
          public BufferedReader reader;
          public StringTokenizer tokenizer;
  
          public InputReader(InputStream stream) {
              reader = new BufferedReader(new InputStreamReader(stream), 32768);
              tokenizer = null;
          }
  
          public String next() {
              while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                  try {
                      tokenizer = new StringTokenizer(reader.readLine());
                  } catch (IOException e) {
                      throw new RuntimeException(e);
                  }
              }
              return tokenizer.nextToken();
          }
  
          public int nextInt() {
              return Integer.parseInt(next());
          }
  
          public long nextLong() {
              return Long.parseLong(next());
          }
  
          public double nextDouble() {
              return Double.parseDouble(next());
          }
  
      }
  
  }