luogu#P10161. [DTCPC 2024] 小方的疑惑 10

    ID: 9811 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>2024Special Judge背包 DP组合数学构造洛谷月赛线性 DP

[DTCPC 2024] 小方的疑惑 10

Background

Xiaofang always has many doubts.

Problem Description

On Little C's birthday a few years ago, he received a gift: a string of length nn consisting only of (\text{(} and )\text{)}, in which exactly kk substrings are valid bracket sequences.

Since Xiaofang is very curious about what this gift looks like, you need to construct such a string, or output 1-1 to indicate that there is no solution.

A valid bracket sequence satisfies the following conditions:

  • ()\text{()} is a valid bracket sequence.
  • If A\text{A} and B\text{B} are valid bracket sequences, then (A)\text{(A)} and AB\text{AB} are valid bracket sequences.
  • All other sequences are not valid bracket sequences.

Xiaofang has many doubts, so he will ask you TT times.

Input Format

The first line contains an integer TT representing the number of queries.

The next TT lines each contain two integers nn and kk (1n,k1051\le n,k \le 10^5, n106\sum n\le 10^6).

The input and output size of this problem is large, so please use fast I/O.

Output Format

For each query, if a solution exists, output a string of length nn on one line; otherwise output 1-1.

3
5 2
5 3
5 4

(())(
()()(
-1

Hint

Translated by ChatGPT 5