F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Parentheses Matrix

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1794    Accepted Submission(s): 626
Special Judge


Problem Description
A $\textit{parentheses matrix}$ is a matrix where every element is either '(' or ')'. We define the $\textit{goodness}$ of a parentheses matrix as the number of $\textit{balanced}$ rows (from left to right) and columns (from up to down). Note that:

- an empty sequence is balanced;
- if $A$ is balanced, then $(A)$ is also balanced;
- if $A$ and $B$ are balanced, then $AB$ is also balanced.

For example, the following parentheses matrix is a $2 \times 4$ matrix with goodness 3, because the second row, the second column and the fourth column are balanced:

)()(
()()

Now, give you the width and the height of the matrix, please construct a parentheses matrix with maximum goodness.
 

Input
The first line of input is a single integer $T$ $(1 \leq T \leq 50)$, the number of test cases.

Each test case is a single line of two integers $h, w$ $(1 \leq h, w \leq 200)$, the height and the width of the matrix, respectively.
 

Output
For each test case, display $h$ lines, denoting the parentheses matrix you construct. Each line should contain exactly $w$ characters, and each character should be either '(' or ')'. If multiple solutions exist, you may print any of them.
 

Sample Input
3 1 1 2 2 2 3
 

Sample Output
( () )( ((( )))
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 10:02:35, Gzip enabled