#include #include using namespace std; int arr[31]; int main() { int T;cin >> T; while(T --) { int m;long long n; memset(arr,0,sizeof(arr)); cin >> m >> n; for(int i = m;i >= 1 && n > 0;i --) arr[i] = n % 3,n = n / 3; for(int i = 1;i <= m;i ++) { if(arr[i] == 0) cout << "R"; else if(arr[i] == 1) cout << "G"; else cout << "B"; } cout << endl; } return 0; }