#include #include #include #include #include #include #include using namespace std; typedef long long ll; const int maxn = 1e3 + 10; int main(){ int t; scanf("%d", &t); while(t--) { ll n, m; stack s; scanf("%I64d%I64d", &m, &n); ll k = n; while(k) { k %= 3; if(k == 0) s.push('R'); else if(k == 1) s.push('G'); else s.push('B'); if(s.size() >= m) break; n /= 3; k = n; } for(int i = 0; i < m-s.size(); i++) printf("R"); while(!s.empty()){ printf("%c", s.top()); s.pop(); } printf("\n"); } return 0; }