#include <iostream>
#include <list>
using namespace std;
int cnt = 0,total = 0;
void EachT()
{
cnt++;
string str;
int n;
cin >> str;
if(cnt == 471 && total = 130000){
cout << str << endl;
}
string s;
char T;
s = str;
str.clear();
for (int i = 1; i < s.size(); i++)
{
if ((s[i - 1] == 'S' && s[i] == 'P') || (s[i - 1] == 'P' && s[i] == 'R') || (s[i - 1] == 'R' && s[i] == 'S'))
{
str.push_back(s[i - 1]);
}
else
{
str.push_back(s[i]);
}
}
s.clear();
while (s.size() != 1)
{
s.clear();
bool flag = true;
for (int i = 0; i < str.size(); i++)
{
T = str[i];
if (s.size() == 0 || s.back() != T)
{
s.push_back(T);
}
else
{
flag = false;
}
}
if (flag)
{
break;
}
str.clear();
for (int i = 1; i < s.size(); i++)
{
if ((s[i - 1] == 'S' && s[i] == 'P') || (s[i - 1] == 'P' && s[i] == 'R') || (s[i - 1] == 'R' && s[i] == 'S'))
{
str.push_back(s[i - 1]);
}
else
{
str.push_back(s[i]);
}
}
}
if (s.size() == 1)
{
cout << s[0] << endl;
}
else
{
if ((s[0] == 'S' && s[1] == 'P') || (s[0] == 'P' && s[1] == 'R') || (s[0] == 'R' && s[1] == 'S'))
{
cout << s[0] << endl;
}
else
{
cout << s[s.size() - 1] << endl;
}
}
}
int main()
{
int t;
cin >> t;
total = t;
while (t--)
{
EachT();
}
}