Recently, you found a bot to play "Rock paper scissors" with. Unfortunately, the bot uses quite a simple algorithm to play: he has a string s = s_1 s_2 ... s_{n} of length n where each letter is either R, S or P.

While initializing, the bot is choosing a starting index pos (1 ≤ pos ≤ n), and then it can play any number of rounds. In the first round, he chooses "Rock", "Scissors" or "Paper" based on the value of s_{pos}: 

  * if s_{pos} is equal to R the bot chooses "Rock"; 
  * if s_{pos} is equal to S the bot chooses "Scissors"; 
  * if s_{pos} is equal to P the bot chooses "Paper"; 



In the second round, the bot's choice is based on the value of s_{pos + 1}. In the third round — on s_{pos + 2} and so on. After s_n the bot returns to s_1 and continues his game.

You plan to play n rounds and you've already figured out the string s but still don't know what is the starting index pos. But since the bot's tactic is so boring, you've decided to find n choices to each round to maximize the average number of wins.

In other words, let's suggest your choices are c_1 c_2 ... c_n and if the bot starts from index pos then you'll win in win(pos) rounds. Find c_1 c_2 ... c_n such that (win(1) + win(2) + ... + win(n))/(n) is maximum possible.

Input

The first line contains a single integer t (1 ≤ t ≤ 1000) — the number of test cases.

Next t lines contain test cases — one per line. The first and only line of each test case contains string s = s_1 s_2 ... s_{n} (1 ≤ n ≤ 2 ⋅ 10^5; s_i ∈ \{R, S, P\}) — the string of the bot.

It's guaranteed that the total length of all strings in one test doesn't exceed 2 ⋅ 10^5.

Output

For each test case, print n choices c_1 c_2 ... c_n to maximize the average number of wins. Print them in the same manner as the string s.

If there are multiple optimal answers, print any of them.

Example

Input


3
RRRR
RSP
S


Output


PPPP
RSP
R

Note

In the first test case, the bot (wherever it starts) will always choose "Rock", so we can always choose "Paper". So, in any case, we will win all n = 4 rounds, so the average is also equal to 4.

In the second test case: 

  * if bot will start from pos = 1, then (s_1, c_1) is draw, (s_2, c_2) is draw and (s_3, c_3) is draw, so win(1) = 0; 
  * if bot will start from pos = 2, then (s_2, c_1) is win, (s_3, c_2) is win and (s_1, c_3) is win, so win(2) = 3; 
  * if bot will start from pos = 3, then (s_3, c_1) is lose, (s_1, c_2) is lose and (s_2, c_3) is lose, so win(3) = 0; 

The average is equal to (0 + 3 + 0)/(3) = 1 and it can be proven that it's the maximum possible average.

A picture from Wikipedia explaining "Rock paper scissors" game: 

<image>
/*
 * Remember a 6.72 student can know more than a 10.0 student.
 * Grades don't determine intelligence, they test obedience.
 * I Never Give Up.
 * I will become Candidate Master.
 * I will defeat Saurabh Anand.
 * Skills are Cheap,Passion is Priceless.
 * Obsession is necessary.
 * Author : Sameer Raj
 */
import java.lang.reflect.Array;
import java.text.CollationElementIterator;
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.Math.*;
import java.math.BigInteger;

import static java.lang.System.*;
import static java.util.Arrays.fill;
import static java.lang.Math.log;
import static java.lang.Math.abs;
import static java.lang.Math.pow;
import static java.lang.Math.sqrt;
import static java.lang.Math.floor;
import static java.lang.Math.ceil;
import static java.lang.Math.sin;
import static java.lang.Math.cos;
import static java.lang.Math.tan;
import static java.util.Arrays.spliterator;
public class ContestMain implements Runnable{
	private static Reader in=new Reader();
	private static StringBuilder ans=new StringBuilder();
	private static long MOD=(long)1e9+7;
	private static final int N=(int) (2e5+7); // 2e5+7
	//	private static ArrayList<Integer> v[]=new ArrayList[N];
//	private static boolean mark[]=new boolean[N];
//	private static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	/*Not try to hack the sort function*/
	public static void sort(long arr[]){
		for(int i=arr.length-1;i>=2;i--){
			int x=new Random().nextInt(i-1);
			long temp=arr[x];
			arr[x]=arr[i];
			arr[i]=temp;
		}
		Arrays.sort(arr);
	}
	public static void sort(int arr[]){
		for(int i=arr.length-1;i>=2;i--){
			int x=new Random().nextInt(i-1);
			int temp=arr[x];
			arr[x]=arr[i];
			arr[i]=temp;
		}
		Arrays.sort(arr);
	}
	public static void sort(String arr[]){
		for(int i=arr.length-1;i>=2;i--){
			int x=new Random().nextInt(i-1);
			String temp=arr[x];
			arr[x]=arr[i];
			arr[i]=temp;
		}
		Arrays.sort(arr);
	}
	public static void sort(Pair arr[]){
		for(int i=arr.length-1;i>=2;i--){
			int x=new Random().nextInt(i-1);
			Pair temp=arr[x];
			arr[x]=arr[i];
			arr[i]=temp;
		}
		Arrays.sort(arr);
	}
	private static long gcd(long a, long b){
		if(b==0)return a;
		return gcd(b,a%b);
	}
	public static long lcm(long a,long b){
		return min(a,b)*(max(a,b)/gcd(a,b));
	}
	/*--------------------------------------------------------------------------------------------------------------*/
	/*Code lies here*/
	@Override
	public void run(){
		int t=in.nextInt();
		String s;
		HashMap<Character,Integer> map=new HashMap<>();
		int c;
		char ch;
		while(t-->0){
			s=in.next();
			c=0;ch='0';
			for(int i=0;i<s.length();i++){
				if(!map.containsKey(s.charAt(i)))map.put(s.charAt(i),1);
				else map.put(s.charAt(i),map.get(s.charAt(i))+1);
			}
			for(char a:map.keySet()){
				if(map.get(a)>c){
					c=map.get(a);
					ch=a;
				}
			}
			if(ch=='R')ch='P';
			else if(ch=='S')ch='R';
			else ch='S';
			for(int i=0;i<s.length();i++)
				app(ch);
			app("\n");
			map.clear();
		}
		pn(ans);
	}
	public static void main(String[] args) throws IOException{
		new Thread(null,new ContestMain(),"Accepted",1<<26).start();
		/* 0_0 I am watching you 0_0 */
	}
	static class Pair<T> implements Comparable<Pair>{
		long l;
		long r;
		Pair(){
			l=0;
			r=0;
		}
		Pair(long k,long v){
			l=k;
			r=v;
		}
		@Override
		public int compareTo(Pair o){
			if(l!=o.l)return (int)(l-o.l);
			return (int)(r-o.r);
		}
	}
	/* BINARY SEARCH FUNCTIONS */
	public static int ceilSearch(int l,int r,int val,int ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]<val)l=mid;
			else r=mid;
		}
		if(ar[l]>=val)return l;
		else if(ar[r]>=val)return r;
		else return -1;
	}
	public static int ceilSearch(int l,int r,long val,long ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]<val)l=mid;
			else r=mid;
		}
		if(ar[l]>=val)return l;
		else if(ar[r]>=val)return r;
		else return -1;
	}
	public static int floorSearch(int l,int r,int val,int ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]>val)r=mid;
			else l=mid;
		}
		if(ar[r]<=val)return r;
		else if(ar[l]<=val)return l;
		else return -1;
	}
	public static int floorSearch(int l,int r,long val,long ar[]){
		int mid;
		while(l+1!=r&&l<r){
			mid=(l+r)/2;
			if(ar[mid]>val)r=mid;
			else l=mid;
		}
		if(ar[r]<=val)return r;
		else if(ar[l]<=val)return l;
		else return -1;
	}
	/* MODULAR OPERATIONS */
	private static long mod(long a,long b){ //a%b
		return (b+a%b)%b;
	}
	private static long modInv(long a){
		return powmod(a,MOD-2);
	}
	private static long powmod(long x,long n){
		if(n==0||x==0)return 1;
		else if(n%2==0)return(powmod((x*x)%MOD,n/2));
		else return (x*(powmod((x*x)%MOD,(n-1)/2)))%MOD;
	}
	public static long mult(long a,long b){
		return mod(mod(a,MOD)*mod(b,MOD),MOD);
	}
	public static long add(long a,long b){
		return mod(mod(a,MOD)+mod(b,MOD),MOD);
	}
	public static long sub(long a,long b){
		return mod(mod(a,MOD)-mod(b,MOD),MOD);
	}
	/* MAX-MIN FUNCTIONS */
	public static long min(long a,long b){
		return Math.min(a, b);
	}
	public static int min(int a,int b){
		return Math.min(a, b);
	}
	public static long max(long a,long b){
		return Math.max(a, b);
	}
	public static int max(int a,int b){
		return Math.max(a, b);
	}
	public static long min(long ar[]){
		return Arrays.stream(ar).min().getAsLong();
	}
	public static int min(int ar[]){
		return Arrays.stream(ar).min().getAsInt();
	}
	public static long max(long ar[]){ return Arrays.stream(ar).max().getAsLong();}
	public static int max(int ar[]){ return Arrays.stream(ar).max().getAsInt(); }
	//Reader Class
	static class Reader{
		BufferedReader br;
		StringTokenizer st;
		public Reader(){br=new BufferedReader(new InputStreamReader(System.in));}
		String next(){
			while(st==null||!st.hasMoreElements()){
				try{st=new StringTokenizer(br.readLine());
				}catch(IOException e){e.printStackTrace();}
			}
			return st.nextToken();
		}
		int nextInt(){return Integer.parseInt(next());}
		long nextLong(){return Long.parseLong(next());}
		double nextDouble(){return Double.parseDouble(next());}
		String nextLine(){
			String str="";
			try{
				str=br.readLine();
			}catch(IOException e){
				e.printStackTrace();
			}
			return str;
		}
	}
	//Looping methods
	static void rep(int ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.nextInt();

	}
	static void rep(long ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.nextLong();
	}
	static void rep(String ar[],int start,int end){
		for(int i=start;i<end;i++)
			ar[i]=in.next();
	}
	static void rep(int ar[][],int n,int m){
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++)
				ar[i][j]=in.nextInt();
		}
	}
	static void rep(long ar[][],int n,int m){
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++)
				ar[i][j]=in.nextLong();
		}
	}
	//Printer Methods
	static void pn(Object o){out.print(o);}
	static void pln(Object o){out.println(o);}
	static void pln(){out.println();}
	static void pf(String format,Object o){out.printf(format,o);}
	//Appenders
	static void app(Object o){ans.append(o);}
	static void appn(Object o){ans.append(o+"\n");}
}