//    01001100 01001111 01010100 01000001    \\
            //                                           \\
            //                ╦  ╔═╗╔╦╗╔═╗               \\
            //                ║  ║ ║ ║ ╠═╣               \\
            //                ╩═╝╚═╝ ╩ ╩ ╩               \\
            //                                           \\
            //    01001100 01001111 01010100 01000001    \\
#include <bits/stdc++.h>
using namespace std;
#define N 1000001
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define ld long double
#define terminator main
#define pll pair<ll,ll>
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
char c[N];
void solve1(){
    int n;
    string s;
    cin >> s;
    n = s.size();
    queue<int> l, r;
    for(int i = 0; i < n; i++){
        c[i] = '?';
        if(s[i] == '(') l.push(i);
        else r.push(i);
        if(r.size() > l.size()){
            if(l.empty()){
                cout << "impossible\n";
                return;
            }
            c[l.front()] = 'G';
            l.pop();
            c[r.front()] = 'R';
            r.pop();
            c[r.front()] = 'B';
            r.pop();
        }
    }
    while(!l.empty())
        l.pop();
    while(!r.empty())
        r.pop();
    for(int i = n - 1; i >= 0; i--){
        if(c[i] != '?') continue;
        if(s[i] == ')') l.push(i);
        else r.push(i);
        if(r.size() > l.size()){
            if(l.empty()){
                cout << "impossible\n";
                return;
            }
            c[l.front()] = 'G';
            l.pop();
            c[r.front()] = 'R';
            r.pop();
            c[r.front()] = 'B';
            r.pop();
        }
    }
    if(l.size() != r.size()){
        cout << "impossible\n";
        return;
    }
    for(int i = 0; i < n; i++){
        if(c[i] == '?') c[i] = 'G';
        cout << c[i];
    }
    cout << nl;
}
void solve2(){
    
}
void solve(){
    int t, n;
    cin >> t >> n;
    while(n--){
        if(t == 1)
            solve1();
        else solve2();
    }
}
int terminator(){
    L0TA;
    solve();
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |