You may have tried your level best to help Chef but Dr Doof has managed to come up with his masterplan in the meantime. Sadly, you have to help Chef once again. Dr Doof has designed a parenthesis-inator. It throws a stream of $N$ brackets at the target, $1$ bracket per second. The brackets can either be opening or closing. Chef appears in front of the stream at time $t$. If Chef faces an opening bracket, he gets hit. However, if he faces a closing bracket, he may choose to let it pass through him (Chef is immune to closing brackets). Chef gets a chance to counter attack Doof as soon as he finds a balanced non-empty bracket sequence. Help Chef by providing him the minimum time $x$ at which he will be able to launch his counter attack. If Chef is unable to counter attack, answer $-1$.
Formally, you are given a string $S$ of length $N$ consisting only of opening brackets $($ and closing brackets $)$. The substring of $S$ starting at index $L$ and ending at index $R$, i.e. $S_L S_{L+1} \ldots S_{R}$ is denoted by $S[L, R]$ . Consider $Q$ cases. In the $i^{\text{th}}$ case, Chef appears at time $t_i$ $(1 \leq t_i \leq N)$ and faces all characters from index $t_i$ to $N$. Find the minimum index $x$ $(t_i \leq x \leq N)$ such that the substring $S[t_i, x]$ contains a non-empty balanced bracket subsequence containing the same number of opening brackets as $S[t_i, x]$ (i.e., you cannot remove any opening bracket from the substring). If such an $x$ does not exist, print $-1$.
A string $X$ is called a subsequence of a string $Y$ if it is possible to obtain $X$ by erasing some (possibly zero) characters from $Y$ without changing the order of the remaining characters.
A balanced bracket sequence is defined as:  
- an empty string is a balanced bracket sequence.
- if $s$ is a balanced bracket sequence, then so is $(s)$.
- if $s$ and $t$ are balanced bracket sequences, then so is $st$.
$Note :-$ The input files are large. The use of Fast I/O is recommended.

-----Input-----
- The first line contains a single integer $T$ denoting the number of testcases.
- The first line of each test case contains the string $S$.
- The next line contains a single integer $Q$ denoting the number of cases to consider.
- The next line contains $Q$ space separated integers, each denoting $t_i$.

-----Output-----
For each query, print the minimum value of $x$ in a separate line. If no such $x$ exists, print $-1$.

-----Constraints-----
- $1 \leq T \leq 10^3$
- $1 \leq |S| \leq 10^7$
- $1 \leq Q \leq 10^6$
- $1 \leq t_i \leq N$
- Every character of $S$ is either $($ or $)$.
- Sum of $|S|$ and $Q$ over all testcases for a particular test file does not exceed $10^7$ and $10^6$ respectively.

-----Sample Input-----
1
)())((()
3
1 7 6

-----Sample Output-----
3
8
-1

-----Explanation-----
For the first query, Chef chooses to let $S_1$ pass through him, gets hit by $S_2$ and finally completes a balanced bracket sequence by adding $S_3$ to $S_2$ at time $x$ = $3$.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'import sys\nimport bisect as bi\nimport math\nfrom collections import defaultdict as dd\ninput=sys.stdin.readline\n##sys.setrecursionlimit(10**7)\ndef cin():\n    return list(map(int,sin().split()))\ndef ain():            \n    return list(map(int,sin().split()))\ndef sin():\n    return input()\ndef inin():\n    return int(input())\nfor _ in range(inin()):\n    s=sin().strip();q=inin();a=ain();n=len(s);store=[0]*n;store1=[-1]*n;f=0;d=dd(int)#input wgera\n    store[0]=1 if s[0]==\'(\' else -1\n    d[store[0]]=1\n    for i in range(1,n):\n        if(s[i]==\'(\'):\n            store[i]=store[i-1]+1\n            d[store[i]]=i+1\n        else:\n            store[i]=store[i-1]-1\n            if(d[store[i-1]]):\n                store1[d[store[i-1]]-1]=i+1\n    post=[-1]*n;\n    if(n==1 or(n==2 and s!="()")):f=1   # corner case\n    for i in range(n-2,-1,-1):\n        if(s[i]==\'(\'):    #dekhna h ki agla agr ( h toh -1 hi rhega wrna wo jo stored tha uppr\n            if(store1[i]!=-1):post[i]=store1[i] #wo iska ans ho jayega\n        else:post[i]=post[i+1]  #jo iske agle ka answer hoga wahi iska hoga\n    for i in a:\n        if(f):print(-1)  #cond ki jaroorat nhi thi pr tasalli (>_<)\n        else:print(post[i-1]) #wrna uska ans print kra do\n    \n    \n##n=m=0\n##s=\'\'\n##t=\'\'\n##dp=[]\n##def solve(inds,indt,k,cont):\n##    ans=-999999999999999\n##    print(dp)\n##    if(k<0):return 0\n##    elif(inds>=n and indt>=m):return 0\n##    elif(dp[inds][indt][k][cont]!=-1):return dp[inds][indt][k][cont]\n##    else:\n##        if(indt<m):ans=max(ans,solve(inds,indt+1,k,0))\n##        if(inds<n):ans=max(ans,solve(inds+1,indt,k,0))\n##        if(s[inds]==t[indt]):\n##            ans=max(ans,solve(inds+1,indt+1,k-1,1)+1)\n##            if(cont):ans=max(ans,solve(inds+1,indt+1,k,1)+1)\n##        dp[inds][indt][k][cont]=ans\n##        return ans    \n\n##    n,m,k=cin()\n##    s=sin().strip()\n##    t=sin().strip()\n##    dp=[[[[-1]*2 for i in range(k)] for i in range(m+1)] for i in range(n+1)]\n##    c=0\n##    for i in dp:\n##        for j in i:\n##            for l in j:\n##                c+=1\n##                print(l,c)\n##    print(solve(0,0,k,0))\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 15043