# Balancing Game SOLUTIONS BRBAL

Page Contents

### Balancing Game SOLUTIONS BRBAL

Two of your companions (we should signify them by [Math Processing Error] and [Math Processing Error]) are playing a game and you are going about as their seller. The principles of the game are as per the following:

There are [Math Processing Error] section arrangements, indicated by [Math Processing Error].

At first, the two players don’t have any groupings. They play up to [Math Processing Error] turns. For each legitimate [Math Processing Error], in the [Math Processing Error]-th turn, you need to pick one player and give the section grouping [Math Processing Error] to this player.

After each turn, in the event that it is conceivable to orchestrate all the arrangements of one part in some request and connect them so that the subsequent section grouping is non-vacant and adjusted, that player promptly dominates and the match closes. Note that it is incomprehensible for the two players to frame non-void adjusted groupings simultaneously.

You like [Math Processing Error] more and henceforth need [Math Processing Error] to win. Locate the most modest number of turns you need so as to make [Math Processing Error] win or verify that it is difficult to accomplish this.

Notes:

A section succession is a self-assertive string containing just characters ‘(‘ and ‘)’.

A reasonable section arrangement is one of the accompanying:

An unfilled string.

A string shaped by adding ‘(‘ to the start and ‘)’ to the furthest limit of a decent section grouping.

Information

The principal line of the information contains a solitary whole number [Math Processing Error] meaning the quantity of experiments. The depiction of [Math Processing Error] experiments follows.

The main line of each experiment contains a solitary whole number [Math Processing Error].

[Math Processing Error] lines follow. For each legitimate [Math Processing Error], the [Math Processing Error]-th of these lines contains a solitary string [Math Processing Error].

Yield

For each experiment, print a solitary line containing one whole number ― the most modest number of goes expected to make [Math Processing Error] win or [Math Processing Error] on the off chance that it is outlandish.

Imperatives

[Math Processing Error]

[Math Processing Error]

[Math Processing Error] for each substantial [Math Processing Error]

Model Input

())

((

()))

()((

Model Output

Clarification

Model case 1: You can give [Math Processing Error] to [Math Processing Error] and [Math Processing Error] and [Math Processing Error] to [Math Processing Error].

Related: