#include <bits/stdc++.h>
#define arr array 
#define pb push_back
#define fs first 
#define sc second
#define eb emplace_back
#define vt vector
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;
typedef long long ll;
const int maxn=2e5;
const int MAXINT=1e9;
const ll MAXLL=1e18;


void solve(){
    int n;
    cin >> n;
    n*=2;
    vt<arr<int, 3>> a(n);
    rep(i, 0, n) cin >> a[i][0], a[i][1]=i;
    sort(a.begin(), a.end(), [&](arr<int, 3> x, arr<int, 3> y){
        return x[0]<y[0];
    });
    rep(i, 0, n/2) a[i][2]=1;
    rep(i, n/2, n) a[i][2]=0;
    sort(a.begin(), a.end(), [&](arr<int, 3> x, arr<int, 3> y){
        return x[1]<y[1];
    });
    
    //rep(i, 0, n) cout << a[i][2] << " "; cout << endl;
    vt<int> st;
    vt<char> ans(n);
    rep(i, 0, n){
        if (!st.empty()&&a[i][2]!=a[st.back()][2]) ans[st.back()]='(', ans[i]=')', st.pop_back();
        else st.pb(i);
    }
    rep(i, 0, n) cout << ans[i]; cout << endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int t=1;
    while(t--){
        solve();
    }
}
/**
 * author: BohaoWang (bj050323@gmail.com)
 * id:
 * tag:
 */
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <list>
#include <algorithm>
#include <climits>
#include <cassert>
#ifdef XDebug
#include "../../debug.h" 
#endif
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;

#define INF 1e9
#define MAXN 100
#define all(A) A.begin(), A.end()

#ifndef XDebug
#define dumpArray(...) 42
#define dumpGraph(...) 42
#endif

// CODE HERE
ll extgcd(ll a, ll b, ll &x, ll &y) {
    ll d = a;
    if (b != 0) {
        d = extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1; y = 0;
    }
    return d;
}

ll modeq(ll a, ll b, ll n) {
    ll e, i, d, x, y;
    d = extgcd(a, n, x, y);
    if (b % d > 0) {
        return -1;
    }
    else {
        ll mi = -1;
        e = (x * (b / d)) % n;
        ll super = ((e + n) % (n/d)) %n;
        return super;
    }
}

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    int n, t;
    cin >> t;
    for (int i = 0; i < t; ++i) {
        int s, k;
        cin >> n >> s >> k;
        cout << modeq(k,n-s,n) << endl;
    }
    return 0;
}
