#include #include #include #include #define LL long long using namespace std; LL a[40], n, m, al; LL d[31]; char co[3] = { 'R', 'G', 'B' }; int main (){ LL i, j, k, T; scanf ( "%I64d", &T ); d[0] = 1; for ( i = 1; i <= 30; i ++ ) d[i] = d[i-1]*3; while ( T -- ){ scanf ( "%I64d%I64d", &m, &n ); n %= d[m]; al = 0; memset ( a, 0, sizeof (a) ); while ( n > 0 ){ a[++al] = n%3; n /= 3; } for ( i = m; i >= 1; i -- ) printf ( "%c", co[a[i]] ); printf ( "\n" ); } return 0; }