https://codeforces.com/contest/1092/problem/C

/*
*@Author:   STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=10000;
const int MOD=1e9+7;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,q;
char pre[105],sa[105];
int vis[201];
struct node
{
	char s[105];
	int id;
	bool operator<(const node& t)const
	{
		return strlen(s)<strlen(t.s);
	}
}a[205];
int isp(char s[105])
{
	int m=strlen(s);
	for(int i=0;i<m;i++)
	if(s[i]!=pre[i])return 0;
	return 1;
}
int issa(char s[105])
{
	int m=strlen(s);
	for(int i=0,j=n-1-m;i<m;i++,j++)
	if(s[i]!=sa[j])return 0;
	return 1;
}
void print()
{
	for(int i=1;i<=n*2-2;i++)
	if(vis[i]==1)printf("P");
	else printf("S");
}
int main()
{
#ifdef DEBUG
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
    cin>>n;
	for(int i=1;i<=n*2-2;i++)cin>>a[i].s,a[i].id=i;
	sort(a+1,a+n*2-1);
	strcpy(pre,a[n*2-3].s);
	strcpy(sa,a[n*2-2].s);
	int flag=1;
	for(int i=1;i<=n*2-2;i+=2){
		if(isp(a[i].s)&&issa(a[i+1].s))
            vis[a[i].id]=1,vis[a[i+1].id]=2;
		else if(isp(a[i+1].s)&&issa(a[i].s))
            vis[a[i].id]=2,vis[a[i+1].id]=1;
		else flag=0,break;
	}
	if(flag)print();
	else{
		strcpy(sa,a[n*2-3].s);
		strcpy(pre,a[n*2-2].s);
		for(int i=1;i<=n*2-2;i+=2){
			if(isp(a[i].s)&&issa(a[i+1].s))
                vis[a[i].id]=1,vis[a[i+1].id]=2;
			else
                vis[a[i].id]=2,vis[a[i+1].id]=1;
		}
		print();
	}
    //cout << "Hello world!" << endl;
    return 0;
}