#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <map>
using namespace std;

#define pb push_back
string imp()
{
    return  "IMPOSSIBLE";
}
// 0 - R 
// 1 - P
// 2 - S
const int MAXCNT = 501;
int ccnt[MAXCNT];
int cnt[MAXCNT][3];
void solve()
{
    for(int i = 0; i < MAXCNT; i++)
    {
        ccnt[i] = 0;
        for(int j = 0; j < 3; j++)
        {
            cnt[i][j] = 0;
        }
    }
    int a; cin >> a;
    vector<string> opp(a);
    for(int i = 0; i < a; i++)
    {
        cin >> opp[i];
    }
    for(int i = 0; i < a; i++)
    {
        string st = opp[i];
        int stl = st.size();
        for (int j = 0; j < MAXCNT; j++)
        {
            if (st[j % stl] == 'R')
            {
                cnt[j][0] += 1;
            }
            else if (st[j % stl] == 'P')
            {
                cnt[j][1] += 1;
            }
            else
            {
                cnt[j][2] += 1;
            }
        }
    }
    for (int i = 0; i < MAXCNT; i++)
    {
        int temp = 0;
        for (int j = 0; j < 3; j++)
            if (cnt[i][j] != 0)
                temp += 1;
        ccnt[i] = temp;
    }

    map<char,char> mp1;
    mp1['R'] = 'P';
    mp1['P'] = 'S';
    mp1['S'] = 'R';
    map<string, char> mp2;
    mp2["RP"] = 'P';
    mp2["PR"] = 'P';
    mp2["RS"] = 'R';
    mp2["SR"] = 'R';
    mp2["SP"] = 'S';
    mp2["PS"] = 'S';
    
    
    int x1 = 0;
    for (int i = 0; i < MAXCNT; i++)
    {
        if(ccnt[i] == 1) 
            x1 += 1;
    }
    if(x1 == 0)
    {
        cout << imp() << "\n";
        return;
    }
    int x3 = 0;
    int i = 0;
    while (i < MAXCNT && ccnt[i] != 1)
    {
        if (ccnt[i] == 3)
            x3 += 1;
        i += 1;
    }
    if (x3 >= 1)
    {
        cout << imp() << "\n";
        return;
    }
    string fans = "";
    i = 0;
    while (i < MAXCNT && ccnt[i] != 1)
    {
        string ss = "";
        if (cnt[i][0] != 0)
            ss.pb('R');
        if (cnt[i][1] != 0)
            ss.pb('P');
        if (cnt[i][2] != 0)
            ss.pb('S');
        i += 1;
        fans.pb(mp2[ss]);
    }
    char ch;
    if (cnt[i][0] != 0)
        ch = 'R';
    if (cnt[i][1] != 0)
        ch = 'P';;
    if (cnt[i][2] != 0)
        ch = 'S';
    fans.pb(mp1[ch]);
    cout << fans << "\n";
}

int main()
{
    int num_test_cases;
    cin >> num_test_cases;
    for (int t = 1; t <= num_test_cases; ++t)
    {
        cout << "Case #" << t << ": ";
        solve();
    }
    return 0;
}
