You are fed up with your messy room, so you decided to clean it up.

Your room is a bracket sequence $s=s_{1}s_{2}\dots s_{n}$ of length $n$. Each character of this string is either an opening bracket '(' or a closing bracket ')'.

In one operation you can choose any consecutive substring of $s$ and reverse it. In other words, you can choose any substring $s[l \dots r]=s_l, s_{l+1}, \dots, s_r$ and change the order of elements in it into $s_r, s_{r-1}, \dots, s_{l}$.

For example, if you will decide to reverse substring $s[2 \dots 4]$ of string $s=$"((()))" it will be equal to $s=$"()(())".

A regular (aka balanced) 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 "()()", "(())" are regular (the resulting expressions are: "(1)+(1)", "((1+1)+1)"), and ")(" and "(" are not.

A prefix of a string $s$ is a substring that starts at position $1$. For example, for $s=$"(())()" there are $6$ prefixes: "(", "((", "(()", "(())", "(())(" and "(())()".

In your opinion, a neat and clean room $s$ is a bracket sequence that:

  the whole string $s$ is a regular bracket sequence;  and there are exactly $k$ prefixes of this sequence which are regular (including whole $s$ itself). 

For example, if $k = 2$, then "(())()" is a neat and clean room.

You want to use at most $n$ operations to make your room neat and clean. Operations are applied one after another sequentially.

It is guaranteed that the answer exists. Note that you do not need to minimize the number of operations: find any way to achieve the desired configuration in $n$ or less operations.


-----Input-----

The first line contains integer number $t$ ($1 \le t \le 100$) — the number of test cases in the input. Then $t$ test cases follow.

The first line of a test case contains two integers $n$ and $k$ ($1 \le k \le \frac{n}{2}, 2 \le n \le 2000$, $n$ is even) — length of $s$ and required number of regular prefixes.

The second line of a test case contains $s$ of length $n$ — the given bracket sequence. It contains only '(' and ')'.

It is guaranteed that there are exactly $\frac{n}{2}$ characters '(' and exactly $\frac{n}{2}$ characters ')' in the given string.

The sum of all values $n$ over all the test cases in the input doesn't exceed $2000$.


-----Output-----

For each test case print an answer.

In the first line print integer $m$ ($0 \le m \le n$) — the number of operations. You do not need to minimize $m$, any value is suitable.

In the following $m$ lines print description of the operations, each line should contain two integers $l,r$ ($1 \le l \le r \le n$), representing single reverse operation of $s[l \dots r]=s_{l}s_{l+1}\dots s_{r}$. Operations are applied one after another sequentially.

The final $s$ after all operations should be a regular, also it should be exactly $k$ prefixes (including $s$) which are regular.

It is guaranteed that the answer exists. If there are several possible answers you can print any.


-----Example-----
Input
4
8 2
()(())()
10 3
))()()()((
2 1
()
2 1
)(

Output
4
3 4
1 1
5 8
2 2
3
4 10
1 4
6 7
0
1
1 2



-----Note-----

In the first example, the final sequence is "()(()())", where two prefixes are regular, "()" and "()(()())". Note, that all the operations except "5 8" in the example output are useless (they do not change $s$).

Difficulty: interview

Starter code:

Solutions:
t = int(input())
for tt in range(t):
    n,k=list(map(int,input().split()))
    s = input()
    ans = []
    if s[0] == ')':
        for i in range(n):
            if s[i] == '(':
                ans.append([1,i+1])
                s = s[i::-1] + s[i+1:]
                break
    for i in range(1,(k-1)*2):
        if i%2==0:
            if s[i]!='(':
                for j in range(i+1,n):
                    if s[j] == '(':
                        ans.append([i+1,j+1])
                        s = s[:i] + s[j:i-1:-1] + s[j+1:]
                        break
        else:
            if s[i]!=')':
                for j in range(i+1,n):
                    if s[j] == ')':
                        ans.append([i+1,j+1])
                        s = s[:i] + s[j:i-1:-1] + s[j+1:]
                        break
    for i in range((k-1)*2,(n+(2*(k-1)))//2+1):
        if s[i]!='(':
            for j in range(i+1,n):
                if s[j] == '(':
                    ans.append([i+1,j+1])
                    s = s[:i] + s[j:i-1:-1] + s[j+1:]
                    break
    print(len(ans))
    for i in ans:
        print(*i)
            





t = int(input())
for test_i in range(t):
    n, k = map(int, input().split())
    s = list(input())
    ans = []
    for i in range(k - 1):
        if s[2 * i] != '(':
            i0 = s.index('(', 2 * i)
            ans.append((2 * i + 1, i0 + 1))
            s[2 * i], s[i0] = '(', ')'
        if s[2 * i + 1] != ')':
            i0 = s.index(')', 2 * i + 1)
            ans.append((2 * i + 2, i0 + 1))
            s[2 * i + 1], s[i0] = ')', '('
    for i in range(n // 2 - k + 1):
        if s[2 * (k - 1) + i] != '(':
            i0 = s.index('(', 2 * (k - 1) + i)
            ans.append((2 * (k - 1) + i + 1, i0 + 1))
            s[2 * (k - 1) + i], s[i0] = '(', ')'
    print(len(ans))
    for pair in ans:
        print(*pair)

for _ in range(int(input())):
    n, k = map(int, input().split())
    st = input()
    s = [st[i] for i in range(n)]
    res = '()' * (k - 1) + '(' * ((n - 2 * (k - 1)) // 2) + ')' * ((n - 2 * (k - 1)) // 2)
    ans = []
    for i in range(n):
        if  s[i] != res[i]:
            for j in range(i + 1, n):
                if res[i] == s[j]:
                    ans.append([i + 1, j + 1])
                    sub = s[i:j + 1]
                    sub = sub[::-1]
                    #print(sub)
                    for k in range(len(sub)):
                        s[i + k] = sub[k]
                    break
    #print(res, s)
    print(len(ans))
    for i in range(len(ans)):
        print(ans[i][0], ans[i][1])

m = int(input())
for h in range(m):
    n, b = list(map(int, input().split()))
    a = input()
    t = 0
    ans = []
    while b != 1:
        if a[t] == ')':
            for i in range(t, n):
                if a[i] == '(':
                    k = i
                    break
            c = a[t:k + 1]
            a = a[:t] + c[::-1]  + a[k + 1:]
            #print(t, k, a)
            ans.append([t, k]) 
        if a[t + 1] == '(':
            for i in range(t + 1, n):
                if a[i] == ')':
                    k = i
                    break
            c = a[t + 1:k + 1]
            a = a[:t + 1] + c[::-1]  + a[k + 1:]
            #print(t, k, a)
            ans.append([t + 1, k])
        t += 2
        b -= 1
    for i in range(t, t + (n - t) // 2):
        if a[i] == ')':
            for j in range(i, n):
                if a[j] == '(':
                    k = j
                    break
            #print(i, k)
            c = a[i:k + 1]
            a = a[:i] + c[::-1]  + a[k + 1:]
            ans.append([i, k])
    #print(a)
    for i in range(t + (n - t) // 2, n):
        if a[i] == '(':
            for j in range(i, n):
                if a[j] == ')':
                    k = j
                    break
            c = a[i:k + 1]
            a = a[:i] + c[::-1] + a[k + 1:]
            ans.append([i, k])
            
    print(len(ans))
    for i in ans:
        print(i[0] + 1, i[1] + 1)


t = int(input())
for i in range(t):
    n, k = map(int, input().split())
    a = []
    s = input()
    for j in range(len(s)):
        a.append(s[j:j + 1])
    answer = (k - 1) * "()" + (n // 2 - k + 1) * "(" + (n // 2 - k + 1) * ")"
    b = []
    for j in range(len(answer)):
        b.append(answer[j:j + 1])
    ans = []
    j = 0
    while j < len(answer):
        if b[j] == a[j]:
            j += 1
        else:
            x = j + 1
            while a[x] == a[j]:
                x += 1
            ans.append([j + 1, x + 1])
            for f in range(j, j + (x - j + 1) // 2):
                a[f], a[x - f + j] = a[x - f + j], a[f]
            j += 1
    print(len(ans))
    for j in range(len(ans)):
        print(" ".join(map(str, ans[j])))

t = int(input())
for z in range(t):
    n, k = map(int, input().split())
    arr = list(input())
    need = '()' * (k - 1) + '(' * ((n - (k - 1) * 2) // 2) + ')' * ((n - (k - 1) * 2) // 2)
    #print(need)
    li = 0
    ri = n - 1
    ln = 0
    rn = n - 1
    ret = []
    rev = 0
    while li < n:
        if arr[li] != need[li]:
            ri = li + 1
            while arr[ri] != need[li]:
                ri += 1
            ret.append([li, ri])
            arr = arr[:li] + list(reversed(arr[li:ri+1])) + arr[ri+1:]
        li += 1
    #print(*arr, sep='')
            
    print(len(ret))
    for x in ret:
        print(x[0] + 1, x[1] + 1)

t=int(input())
for r in range(t):
 n,k=list(map(int,input().split()))
 k-=1
 want='()'*k+'('*(n//2-k)+')'*(n//2-k)
 have=input()
 prn=[]
 for w in range(len(want)):
  if have[w]!=want[w]:
   e=w+have[w:].index(want[w])
   have=have[:w]+have[w:e+1][::-1]+have[e+1:]
   prn+=[[w+1,e+1]]
 print(len(prn))
 for w in prn:
  print(*w)


for _ in range(int(input())):
    n, k = tuple(map(int, input().split()))
    s = list(input())
    ans = list("()" * (k - 1) + "(" * ((n // 2) - k + 1) + ")" * (n // 2 - k + 1))
    ops = []
    i = 0
    while ans != s and i < n:
        # print("----" , i, "----")
        if ans[i] != s[i]:
            j = s[i:].index(ans[i]) + i
            # print(0,"|",j, s[j], s[i])
            ops.append(str(i + 1) + " " + str(j + 1))
            for k in range(i, (j + i + 1) // 2):
                # print(11, "|", j, s[k], s[j + i - k])
                (s[k], s[j + i - k]) = (s[j + i - k], s[k])
                # print(12, "|", j, s[k], s[j + i - k])
        # print(" ".join(s))
        # print(" ".join(ans))
        # print("|".join(ops))
        i += 1
    print(len(ops))
    if len(ops) != 0:
        print("\n".join(ops))


t = int(input())
for request in range(t):
    n, k = map(int, input().split())
    box = list(input())
    pattern = '()' * (k - 1) + '(' + ('()' * ((n - (k) * 2) // 2) ) + ')'
    changes = []
    for i in range(n):
        if box[i] != pattern[i]:
            for j in range(i + 1, n):
                if box[j] == pattern[i]:
                    for z in range((j - i + 1) // 2):
                        box[i + z], box[j - z] = box[j - z], box[i + z]
                    changes.append((i + 1, j + 1))
                    break
    print(len(changes))
    for i in range(len(changes)):
        print(*changes[i])

t = int(input())

for i in range(t):
    n, k = map(int, input().split())
    *s, = input()
    operations = []
    best = (['('] + [')']) * (k - 1) + (['('] * (n // 2 - k + 1) + [')'] * (n // 2 - k + 1))

    for startx_pos in range((k - 1) * 2):
        try:
            if s[startx_pos - 1] == ')' or startx_pos == 0:
                end_pos = s.index('(', startx_pos)
            else:
                end_pos = s.index(')', startx_pos)
        except ValueError:
            continue
        if startx_pos == end_pos:
            continue
        if startx_pos == 0:
            s = s[:startx_pos] + s[end_pos::-1] + s[end_pos + 1:]
        else:
            s = s[:startx_pos] + s[end_pos:startx_pos - 1:-1] + s[end_pos + 1:]
        operations.append(f'{startx_pos + 1} {end_pos + 1}')

    for startx_pos in range((k - 1) * 2, (k - 1) * 2 + (n // 2 - k + 1)):
        try:
            end_pos = s.index('(', startx_pos)
        except ValueError:
            continue
        if startx_pos == end_pos:
            continue
        if startx_pos == 0:
            s = s[:startx_pos] + s[end_pos::-1] + s[end_pos + 1:]
        else:
            s = s[:startx_pos] + s[end_pos:startx_pos - 1:-1] + s[end_pos + 1:]
        operations.append(f'{startx_pos + 1} {end_pos + 1}')

    print(len(operations))
    if len(operations):
        print(*operations, sep='\n')




def openBracket(i):
    nonlocal firstOpen, ans
    ind = index[0][firstOpen]
    a = s[i: ind + 1]
    a.reverse()
    #print(i + 1, ind + 1)
    s[i: ind + 1] = a
    ans += [[i + 1, ind + 1]]
    firstOpen += 1
    

def closeBracket(i):
    nonlocal firstClose, ans
    ind = index[1][firstClose]
    a = s[i: ind + 1]
    a.reverse()
    #print(i + 1, ind + 1)
    ans += [[i + 1, ind + 1]]
    s[i: ind + 1] = a
    firstClose += 1
    
    
t = int(input())
for h in range(t):
    n, k = map(int, input().split())
    s = list(input())
    ans = []
    fl = 0
    index = [[], []]
    firstOpen = 0
    firstClose = 0
    for i in range(n):
        if s[i] == "(":
            index[0] += [i];
        else:
            index[1] += [i];
    for i in range(2 * k - 2):
        if fl == 0:
            if s[i] != "(":
                openBracket(i)
            else:
                firstOpen += 1
        elif fl == 1:
            if s[i] != ")":
                closeBracket(i)
            else:
                firstClose += 1
        fl = abs(fl - 1)
    fl = 0
    for i in range(2 * k - 2, n):
        if fl == 0:
            if s[i] != "(":
                openBracket(i)
            else:
                firstOpen += 1
        elif fl == 1:
            if s[i] != ")":
                closeBracket(i)
            else:
                firstClose += 1
        if i == n // 2 - k + 2 * k - 2:
            fl = 1
    print(len(ans))
    [print(*i) for i in ans]


t=int(input())
while t:
    n,k=list(map(int,input().split()))
    s=list(input())
    hyp=[]
    k1=k
    while (k-1):
        hyp.append('(')
        hyp.append(')')
        k-=1
    ll=(n//2)-(k1-1)
    for i in range(ll):
        hyp.append('(')
    for i in range(ll):
        hyp.append(')')
    #print(hyp,s)   
    ans=[]
    for i in range(n):
        if hyp[i]!=s[i]:
            l=[]
            c=0
            for j in range(i,n):
                l.append(s[j])
                c+=1
                if s[j]==hyp[i]:
                    ans.append(i+1)
                    ans.append(j+1)
                    break
            k=i    
            for l2 in range(c-1,-1,-1):
                s[k]=l[l2]
                k+=1
    l3=len(ans)//2
    print(l3)
    j=0
    for i in range(l3):
        print(ans[j],ans[j+1])
        j+=2
    t-=1



def replace(i, right_s):
    j = i + 1
    while j < n and s[j] != right_s:
        j += 1
    else:
        for k in range((j - i + 1) // 2):
            s[i + k], s[j - k] = s[j - k], s[i + k]
    return j

t = int(input())
operations = []
for _ in range(t):
    n, k = input().split()
    n = int(n)
    k = int(k) - 1
    s = list(input())
    operations.append([])
    for i in range(n):
        if i < 2 * k:
            if i % 2 and s[i] == '(':
                operations[_].append([i, replace(i, ')')])
            elif i % 2 == 0 and s[i] == ')':
                operations[_].append([i, replace(i, '(')])
        elif i < n // 2 + k and s[i] == ')':
            operations[_].append([i, replace(i, '(')])
        elif i >= n // 2 + k and s[i] == '(':
            operations[_].append([i, replace(i, ')')])
for i in range(t):
    print(len(operations[i]))
    for operation in operations[i]:
        print(operation[0] + 1, operation[1] + 1)


def craftIdeal(length, zeroes):
    asdf = []
    x = 0
    for i in range(zeroes - 1):
        asdf.append(True)
        asdf.append(False)
        x += 2
    for j in range(x, x + (length - x)//2):
        asdf.append(True)
    for k in range(x + (length - x)//2, length):
        asdf.append(False)
    return asdf

def getAns(string, l, m):
    real = []
    for char in string:
        if char == ")":
            real.append(False)
        else:
            real.append(True)
    endgoal = craftIdeal(l, m)
    operations = []
    temp = []
    
    for i in range(l):
        target = endgoal[i]
        if real[i] != target:
            nextDiffIndex = i + 1
            while real[nextDiffIndex] != target:
                nextDiffIndex += 1
                
            temp = real[i:nextDiffIndex + 1]
            for j in range(i, nextDiffIndex + 1):
                real[j] = temp[nextDiffIndex - j]
                
            operations.append(str(i + 1) + " " + str(nextDiffIndex + 1))
    print(len(operations))
    for e in operations:
        print(e)
    return
    
n = int(input())
for i in range(n):
    k = [int(x) for x in input().split(' ')]
    getAns(input(), k[0], k[1])


for T in range(int(input())):
	n, k = list(map(int, input().split()))
	s = input()
	lp = 0
	rp = 0
	l = []
	for i in range(k * 2 - 2):
		while lp < n and s[lp] != '(' or lp < i:
			lp += 1
		while rp < n and s[rp] != ')' or rp < i:
			rp += 1
		if i % 2 == 0 and s[i] == '(' or i % 2 == 1 and s[i] == ')':
			continue
		elif i % 2 == 0:
			lp += 1
			s = s[: i] + s[i: lp][::-1] + s[lp:]
			l.append([i + 1, lp])
			rp = i

		else:
			rp += 1
			s = s[: i] + s[i: rp][::-1] + s[rp: ]
			l.append([i + 1, rp])
			lp = i
	
	for i in range(k * 2 - 2, (n+k+k-2)//2):
		while lp < n and s[lp] != '(' or lp < i:
			lp += 1
		while rp < n and s[rp] != ')' or rp < i:
			rp += 1
		if i<(n+k+k-2)//2 and s[i] == '(' or i>=(n+k+k-2)//2 and s[i] == ')':
			continue
		elif i<(n+k+k)//2:
			lp += 1
			s = s[: i] + s[i: lp][::-1] + s[lp: ]
			l.append([i + 1, lp])
			rp = i

		else:
			rp += 1
			s = s[: i] + s[i: rp][::-1] + s[rp: ]
			l.append([i + 1, rp])
			lp = i
	print(len(l))
	for i in l:
		print(*i)


t = int(input())

def conv1(v) :
    nonlocal z
    index, q = 0, 0
    for i in range(len(v)) :
        if v[i] == '(' : q += 1
        else : q -= 1
        if q == 0 and v[i] == '(' :
            if i != len(v) : v = v[:index] + list(reversed(v[index:i+1])) + v[i+1:]
            else : v = v[:index] + list(reversed(v[index:i+1]))
            z.append([index+1, i+1])
            index = i+1
        elif q == 0 : index = i+1
    return v

def count(v) :
    q, k = 0, 0
    for i in v :
        if i == '(' : q += 1
        else : q -= 1
        if q == 0 : k += 1
    return k

def conv_min(v, k, n) :
    nonlocal z
    q = 0
    for i in range(0, len(v)) :
        if k == n : return v
        if v[i] == '(' : q += 1
        else : q -= 1
        if q == 0 :
            z.append([i+1, i+2])
            n -= 1

def conv_max(v, k, n) :
    nonlocal z
    q = 0
    for i in range(0, len(v)) :
        if k == n : return v
        if v[i] == '(' : q += 1
        else :
            if q == 2 :
                v[i-1], v[i] = v[i], v[i-1]
                q = 1
                z.append([i, i+1])
                n += 1
            elif q > 2 :
                v[i-q+1], v[i] = v[i], v[i-q+1]
                z.append([i-q+1, i+1])
                z.append([i-q+1, i-q+2])
                q -= 1
                n += 1
            else : q = 0

if 1 == 2 :
    s = list('()(())')
    z = []
    print(''.join(conv_max(s, 3, 2)))
    raise SystemExit

for _ in range(t) :
    _, k = [int(x) for x in input().split()]
    s = list(input())
    z = []
    
    s = conv1(s)
    ct = count(s)
    if ct >= k : conv_min(s, k, ct)
    else : conv_max(s, k, ct)
    print(len(z))
    print('\n'.join(list([str(x[0])+' '+str(x[1]) for x in z])))


t=int(input())
for i3 in range(t):
    n,k=map(int,input().split())
    inp=str(input())
    s,ans,x=[],[],[]
    for i in range(n): x.append(inp[i])
    for i in range(k-1):
        s.append("(")
        s.append(")")
    for i in range(n//2-k+1): s.append("(")
    for i in range(n//2-k+1): s.append(")")
    for i in range(n):
        if x[i]==s[i]:
            pass
        else:
            temp=[]
            for i2 in range(i,n):
                temp.append(x[i])
                if x[i2]==s[i]:
                    ans.append([i+1,i2+1])
                    temp.reverse()
                    for i3 in range(i,i2+1):
                        x[i3]=temp[i3-i]
                    break
    print(len(ans))
    for i in range(len(ans)):
        print(ans[i][0],ans[i][1])