#include <bits/stdc++.h>
using std::string;
using std::vector;
constexpr int MAX_SIZE = 2e5 + 5;
char bot_seq[MAX_SIZE] = {0};
char ans[MAX_SIZE] = {0};
char choices[3] = {'P', 'R', 'S'};
int win_counts[30] = {0};
int main() {
  int num_cases = 0;
  ::scanf("%d", &num_cases);
  for (int i_case = 0; i_case < num_cases; ++i_case) {
    ::scanf("%s", bot_seq);
    int len = ::strlen(bot_seq);
    ::memset(win_counts, 0, sizeof(int) * 30);
    for (int i = 0; i < len; ++i) {
      win_counts[bot_seq[i] - 'A']++;
    }
    char ans_ch = choices[(
        (win_counts['R' - 'A']) > (win_counts['S' - 'A'])
            ? ((win_counts['R' - 'A']) > (win_counts['P' - 'A']) ? 0 : 2)
            : ((win_counts['S' - 'A']) > (win_counts['P' - 'A']) ? 1 : 2))];
    for (int i = 0; i < len; ++i) {
      ans[i] = ans_ch;
    }
    ans[len] = 0;
    ::printf("%s\n", ans);
  }
  return 0;
}
