#include #include #define MAX_N 1005 using namespace std; int main() { __int64 t, m, n; int str[MAX_N]; scanf("%I64d", &t); while (t--) { memset(str, 0, sizeof(str)); scanf("%I64d %I64d", &m, &n); __int64 cnt = 0; while (n) { str[cnt++] = n % 3; n /= 3; } if (cnt < m) { for (__int64 i = 0; i < m - cnt; i++) printf("R"); for (__int64 i = cnt - 1; i >= 0; i--) { if (str[i] == 0) printf("R"); else if (str[i] == 1) printf("G"); else if (str[i] == 2) printf("B"); } } else{ for (__int64 i = m - 1; i >= 0; i--) { if (str[i] == 0) printf("R"); else if (str[i] == 1) printf("G"); else if (str[i] == 2) printf("B"); } } printf("\n"); } return 0; }