Ivan wants to play a game with you. He picked some string $s$ of length $n$ consisting only of lowercase Latin letters. 

You don't know this string. Ivan has informed you about all its improper prefixes and suffixes (i.e. prefixes and suffixes of lengths from $1$ to $n-1$), but he didn't tell you which strings are prefixes and which are suffixes.

Ivan wants you to guess which of the given $2n-2$ strings are prefixes of the given string and which are suffixes. It may be impossible to guess the string Ivan picked (since multiple strings may give the same set of suffixes and prefixes), but Ivan will accept your answer if there is at least one string that is consistent with it. Let the game begin!


-----Input-----

The first line of the input contains one integer number $n$ ($2 \le n \le 100$) — the length of the guessed string $s$.

The next $2n-2$ lines are contain prefixes and suffixes, one per line. Each of them is the string of length from $1$ to $n-1$ consisting only of lowercase Latin letters. They can be given in arbitrary order.

It is guaranteed that there are exactly $2$ strings of each length from $1$ to $n-1$. It is also guaranteed that these strings are prefixes and suffixes of some existing string of length $n$.


-----Output-----

Print one string of length $2n-2$ — the string consisting only of characters 'P' and 'S'. The number of characters 'P' should be equal to the number of characters 'S'. The $i$-th character of this string should be 'P' if the $i$-th of the input strings is the prefix and 'S' otherwise.

If there are several possible answers, you can print any.


-----Examples-----
Input
5
ba
a
abab
a
aba
baba
ab
aba

Output
SPPSPSPS

Input
3
a
aa
aa
a

Output
PPSS

Input
2
a
c

Output
PS



-----Note-----

The only string which Ivan can guess in the first example is "ababa".

The only string which Ivan can guess in the second example is "aaa". Answers "SPSP", "SSPP" and "PSPS" are also acceptable.

In the third example Ivan can guess the string "ac" or the string "ca". The answer "SP" is also acceptable.

Difficulty: introductory

Starter code:

Solutions:
n = int(input())


def test(a, s):
    k = [''] * len(a)
    d = {}
    for i in range(len(a)):
        tof = True
        if a[i] == s[:len(a[i])]:
            if a[i] not in d:
                d[a[i]] = 'P'
                tof = False
                k[i] = 'P'
        if not tof:
            continue
        if a[i] == s[len(s) - len(a[i]):]:
            if a[i] not in d or d[a[i]] == 'P':
                d[a[i]] = 'S'
                tof = False
                k[i] = 'S'
        if tof:
            return [-1]
    return k
        


k = ['', '', '', '']
a = []
for i in range(2 * n - 2):
    s = input()
    a.append(s)
    if len(s) == 1:
        if k[0] == '':
            k[0] = s
        else:
            k[1] = s
    if len(s) == n - 1:
        if k[2] == '':
            k[2] = s
        else:
            k[3] = s
m = k[2] + k[0]
r = test(a, m)
if r != [-1]:
    for i in r:
        print(i, end='')
    return
m = k[2] + k[1]
r = test(a, m)
if r != [-1]:
    for i in r:
        print(i, end='')
    return
m = k[3] + k[0]
r = test(a, m)
if r != [-1]:
    for i in r:
        print(i, end='')
    return
m = k[3] + k[1]
r = test(a, m)
if r != [-1]:
    for i in r:
        print(i, end='')



n = int(input())
a = []
fe = -1
se = -1
for i in range(2*n - 2):
    s = input()
    if len(s) == n - 1:
        if fe == -1:
            fe = i
        else:
            se = i
    a.append(s)
fl = True
s = a[fe] + a[se][-1]
b = [''] * len(a)
pr = [False] * n
su = [False] * n
for i in range(len(a)):
    #pr
    flp = False
    ss = a[i]
    if not pr[len(ss) - 1]:
        if s[:len(ss)] == ss:
            b[i] = 'P'
            pr[len(ss) - 1] = True
            flp = True
    if not flp:
        if not su[-len(ss)]:
            if s[-len(ss):] == ss:
                b[i] = 'S'
                su[-len(ss)] = True
                flp = True
    if not flp:
        fl = False
        break
if not fl:
    s = a[se] + a[fe][-1]
    pr = [False] * n
    su = [False] * n
    for i in range(len(a)):
        #pr
        flp = False
        ss = a[i]
        if not pr[len(ss) - 1]:
            if s[:len(ss)] == ss:
                b[i] = 'P'
                pr[len(ss) - 1] = True
                flp = True
        if not flp:
            if not su[-len(ss)]:
                if s[-len(ss):] == ss:
                    b[i] = 'S'
                    su[-len(ss)] = True
                    flp = True
for i in b:
    print(i, end = '')
                
            


n=int(input())
AB=[input() for i in range(2*n-2)]

ABSORT=sorted(AB,key=lambda x:len(x),reverse=True)

CANDI=[]

if ABSORT[0][1:]==ABSORT[1][:-1]:
    CANDI.append(ABSORT[0]+ABSORT[1][-1])

if ABSORT[1][1:]==ABSORT[0][:-1]:
    CANDI.append(ABSORT[1]+ABSORT[0][-1])

if CANDI[0]==CANDI[-1]:
    CANDI=[CANDI[0]]

for c in CANDI:
    for s in AB:
        ls=len(s)

        if c[:ls]==s or c[-ls:]==s:
            continue
        else:
            break
    else:
        DE=c
        break


DEAB=[(AB[i],i) for i in range(2*n-2)]
DEAB.sort(key=lambda x:len(x[0]))

ANSLIST=[None]*(2*n-2)
for i in range(n-1):
    s,si=DEAB[2*i]
    t,ti=DEAB[2*i+1]
    ls=len(s)

    if DE[:ls]==s and DE[-ls:]==t:
        ANSLIST[si]="P"
        ANSLIST[ti]="S"
    else:
        ANSLIST[si]="S"
        ANSLIST[ti]="P"

for a in ANSLIST:
    print(a,end="")

print()




n = int(input())
s = []
for i in range(2*n-2):
	s.append(input().strip())

x,y = [x for x in s if len(x) == n-1]

def check(x,y,s,n):
	full = x+y[-1]
	taga = [0]*(n)
	tagb = [0]*(n)
	result = [0]*(2*n-2)
	for i in range(len(s)):
		p = s[i]
		if full.startswith(p) and taga[len(p)] == 0:
			taga[len(p)] = 1
			result[i] = 'P'
		elif full.endswith(p) and tagb[len(p)] == 0:
			tagb[len(p)] = 1
			result[i] = 'S'
	if 0 in result:
		return False,result
	return True,result


r,rr =check(x,y,s,n)
if r:
	# print(rr)
	print(''.join(rr))
else:
	r,rr = check(y,x,s,n)
	# print(rr)
	print(''.join(rr))



def main():
    n = int(input())
    ain = [input() for _ in range(2*n - 2)]
    a = sorted(ain, key=lambda x: len(x), reverse=True)

    s1 = a[0] + a[1][-1]
    d = { k: [] for k in a }

    next = False
    for i in range(1, n):
        try:
            d[s1[:i]].append('P')
            d[s1[-i:]].append('S')
        except KeyError:
            next = True

    if not next:
        result = []
        for e in ain:
            if not d[e]:
                break
            result.append(d[e][0])
            d[e].pop(0)
        else:
            print(''.join(result))
            return

    s1 = a[1] + a[0][-1]
    d = { k: [] for k in a }

    for i in range(1, n):
        d[s1[:i]].append('P')
        d[s1[-i:]].append('S')

    result = []
    for e in ain:
        if not d[e]:
            break
        result.append(d[e][0])
        d[e].pop(0)
    else:
        print(''.join(result))
        return

def __starting_point():
    main()

__starting_point()

n=int(input())
dict1={}
arr=[]
spr=[]
for i in range(2*n-2):
    s=str(input())
    try:
        dict1[s]+=1
    except:
        KeyError
        dict1[s]=1
    arr.append(s)
    if(len(s)==n-1):
        spr.append(s)
flag=0
temp=""
arr1=[0]*(2*n-2)
for i in range(n-1):
    temp+=spr[0][i]
    tempflag=0
    for j in range(2*n-2):
        if(arr[j]==temp and arr1[j]==0):
            arr1[j]=1
            tempflag=1
            break
    if(tempflag==0):
        flag=1
        break
    #print(*arr1)
if(flag==0):
    temp=''
    for i in range(n-2,-1,-1):
        temp=spr[1][i]+temp
        tempflag=0
        for j in range(2*n-2):
            if(arr[j]==temp and arr1[j]==0):
                arr1[j]=-1
                tempflag=1
                break
        if(tempflag==0):
            flag=1
            break
if(flag==0):
    s1=""
    for i in arr1:
        if(i==1):
            s1+='P'
        elif(i==-1):
            s1+='S'
    print(s1)

else:
    temp=""
    arr1=[0]*(2*n-2)
    for i in range(n-1):
        temp+=spr[1][i]
        tempflag=0
        for j in range(2*n-2):
            if(arr[j]==temp and arr1[j]==0):
                arr1[j]=1
                tempflag=1
                break
        if(tempflag==0):
            flag=1
            break
    temp=""
    if(flag==0):
        for i in range(n-2,-1,-1):
            temp=spr[0][i]+temp
            tempflag=0
            for j in range(2*n-2):
                if(arr[j]==temp and arr1[j]==0):
                    arr1[j]=-1
                    tempflag=1
                    break
            if(tempflag==0):
                flag=1
                break
    s1=""
    for i in arr1:
        if(i==1):
            s1+='P'
        else:
            s1+='S'
    print(s1)
#print(*arr1)


n = int(input())
a = []
d = []
for i in range(2 * n - 2):
    b = input()
    a.append(b)
    if len(b) == n-1:
        d.append(b)
s1 = d[0] + d[1][-1]
s2 = d[1] + d[0][-1]

def ans(s):
    l = ['' for _ in range(2 * n - 2)]
    for i in range(2 * n - 2):
        if l[i] != '': continue
        m1 = i
        m2 = -1
        for j in range(i + 1, 2 * n - 2):
            if len(a[j]) == len(a[i]):
                m2 = j
                break
        if s.startswith(a[i]) and s.endswith(a[j]):
            l[i] = 'P'
            l[j] = 'S'
        elif s.startswith(a[j]) and s.endswith(a[i]):
            l[j] = 'P'
            l[i] = 'S'
    if any(i == '' for i in l):
        return None
    return ''.join(l)

s = ans(s1)
if s:
    print(s)
else:
    print(ans(s2))


n = int(input())
all = [input() for _ in range(2 * n - 2)]
imp = []
ans = [0 for _ in range(2 * n - 2)]
pr = []
for a in all:
    if len(a) == n - 1:
        imp.append(a)

ok = True
for i in range(2 * n - 2):
    is1, is2 = False, False
    if imp[0].find(all[i]) == 0:
        is1 = True
    if imp[1].rfind(all[i]) == len(imp[1]) - len(all[i]):
        is2 = True

    if not is1 and not is2:
        ok = False
        continue

    if is1 and is2:
        if all[i] in pr:
            is1 = False
        else:
            is2 = False

    if is1:
        ans[i] = 1
        pr.append(all[i])
    else:
        ans[i] = 2

if not ok:
    imp[0], imp[1] = imp[1], imp[0]
    ans = [0 for _ in range(2 * n - 2)]
    pr = []

    for i in range(2 * n - 2):
        is1, is2 = False, False
        if imp[0].find(all[i]) == 0:
            is1 = True
        if imp[1].rfind(all[i]) == len(imp[1]) - len(all[i]):
            is2 = True

        if is1 and is2:
            if all[i] in pr:
                is1 = False
            else:
                is2 = False

        if is1:
            ans[i] = 1
            pr.append(all[i])
        else:
            ans[i] = 2

for i in range(2 * n - 2):
    if ans[i] == 1:
        print('P', end='')
    else:
        print('S', end='')
print()

import sys
from math import floor, ceil

input = sys.stdin.readline

n = int(input())

q = {}
for i in range(2*n - 2):
    curr = input().strip()
    if len(curr) not in q.keys():
        q[len(curr)] = []
    q[len(curr)].append((curr, i))

pre = q[1][0][0]
suf = q[1][1][0]
ans = [0 for i in range(2*n-2)]
ans[q[1][0][1]] = 'P'
ans[q[1][1][1]] = 'S'

valid = True
for i in range(2, n):
    first = q[i][0]
    second = q[i][1]
    # assuming first is prefix and second is suffix
    if (first[0][:-1] == pre) and (second[0][1:] == suf):
        ans[first[1]] = 'P'
        ans[second[1]] = 'S'
        pre = first[0]
        suf = second[0]
    elif (first[0][1:] == suf) and (second[0][:-1] == pre):
        ans[first[1]] = 'S'
        ans[second[1]] = 'P'
        suf = first[0]
        pre = second[0]
    else:
        valid = False
        break

if not valid:
    pre = q[1][1][0]
    suf = q[1][0][0]
    ans = [0 for i in range(2*n-2)]
    ans[q[1][0][1]] = 'S'
    ans[q[1][1][1]] = 'P'

    valid = True
    for i in range(2, n):
        first = q[i][0]
        second = q[i][1]
        # assuming first is prefix and second is suffix
        if (first[0][:-1] == pre) and (second[0][1:] == suf):
            ans[first[1]] = 'P'
            ans[second[1]] = 'S'
            pre = first[0]
            suf = second[0]
        elif (first[0][1:] == suf) and (second[0][:-1] == pre):
            ans[first[1]] = 'S'
            ans[second[1]] = 'P'
            suf = first[0]
            pre = second[0]
        else:
            valid = False
            break
print(''.join([str(x) for x in ans]))


def check(string, arr):
    tmp = []
    for i in range(1, len(string)):
        tmp.append(string[:i])
        tmp.append(string[i:])
    tmp = sorted(tmp)
    narr = sorted(arr)
    return tmp == narr

size = int(input())
values = []
tokens = []

for _ in range(2 * size - 2):
    values.append(input())

for value in values:
    if len(value) == size - 1:
        tokens.append(value)

if check(tokens[0] + tokens[1][-1], values):
    origin = tokens[0] + tokens[1][-1]
else:
    origin = tokens[1] + tokens[0][-1]

answer = ''
was = set()

for value in values:
    if origin.startswith(value) and not value in was:
        answer += 'P'
    else:
        answer += 'S'
    was.add(value)

print(answer)


n = int(input())
a = [(input(), q) for q in range(2*n-2)]
answer = ['S']*(2*n-2)
a.sort(key=lambda x: (len(x[0]), x))
a1, a = [q[1] for q in a], [q[0] for q in a]
if len(a) == 2:
    print('PS')
else:
    s = [a[-1]+a[0], a[-1]+a[1], a[-2]+a[0], a[-2]+a[1]]
    ans = 0
    for q in range(4):
        d = []
        for q1 in range(1, n):
            d.append(s[q][:q1])
        for q1 in range(n-1, 0, -1):
            d.append(s[q][q1:])
        if sorted(d, key=lambda x: (len(x), x)) == a:
            ans = q
    s = s[ans]
    f = [1]*(2*n-2)
    for q in range(1, n):
        if f[2*q-2] and a[2*q-2] == s[:q]:
            f[2*q-2] = 0
            answer[a1[2*q-2]] = 'P'
        else:
            f[2 * q - 1] = 0
            answer[a1[2 * q - 1]] = 'P'
    print(*answer, sep='')


#!/usr/bin/env python
# coding: utf-8

# In[42]:


import math
n=int(input())
fixes=[]
for i in range(2*n-2):
    fixes.append(input())


# In[82]:


fixessorted=[[] for i in range(n-1)]


# In[83]:


for i in fixes:
    fixessorted[len(i)-1].append(i)


# In[84]:


prefixes={}
suffixes={}


# In[85]:


pslist=[0 for i in range(2*n-2)]


# In[86]:


testprefix=fixessorted[n-2][0]
test=0
testsuffix=fixessorted[n-2][1]
for i in range(0,n-1):
    if  testprefix[:n-1-i]  in fixessorted[n-2-i]:
        prefixes[testprefix[:n-1-i]]=1
        fixessorted[n-2-i].remove(testprefix[:n-1-i])    
            
    else:
        test=1
            
for i in range(0,n-1):
    #print( testsuffix[i:])
    #print(fixessorted[n-2-i])
    if  testsuffix[i:]  in fixessorted[n-2-i]:
        suffixes[testsuffix[i+1:]]=1
            
            
    else:
        test=1            
            
#print(test)            
            
if test==1:
    
    fixessorted=[[] for i in range(n-1)]
    for i in fixes:
        fixessorted[len(i)-1].append(i)
    
    testprefix=fixessorted[n-2][1]
    prefixes={}
    for i in range(0,n-1):
        if  testprefix[:n-1-i]  in fixessorted[n-2-i]:
            prefixes[testprefix[:n-1-i]]=1


# In[87]:


for i in range(2*n-2):
    if fixes[i] in prefixes:
        pslist[i]="P"
        del prefixes[fixes[i]]
    else:
        pslist[i]='S'


# In[88]:


print(''.join(pslist))


# In[ ]:




def mi():
	return list(map(int, input().split()))
'''

'''
n = int(input())
a = [[] for i in range(n-1)]
aa = [0]*(2*n-2)
ba = [0]*(2*n-2)
for i in range(2*n-2):
	s = input()
	a[len(s)-1].append(s)
	aa[i] = s
	ba[2*n-3-i] = s
s1 = ['0']*n
s2 = ['0']*n
s1[0] = a[0][0]
s1[-1] = a[0][1]
s2[0] = a[0][1]
s2[-1] = a[0][0]
noans1 = False
noans2 = False
t1a = [0]*(2*n-2)
t2a = [0]*(2*n-2)
t1a[aa.index(a[0][0])] = 'P'
t1a[2*n-3-ba.index(a[0][1])] = 'S'
t2a[aa.index(a[0][0])] = 'S'
t2a[2*n-3-ba.index(a[0][1])] = 'P'
# print (aa, ba)
# print (a[1])
for i in range(1,n-1):
	ent1 = False
	# print (t1a)
	t1 = ''.join(s1)
	t2 = ''.join(s2)
	# print (t1, a[i][0][:-1], a[i][1][1:], a[i][0], a[i][1])
	if t1.startswith(a[i][0][:-1]) and t1.endswith(a[i][1][1:]):
		ent1 = True
		s1[i] = a[i][0][-1]
		s1[n-1-i] = a[i][1][0]
		# print (aa.index(a[i][0]), a[i][0])
		# print (2*n-3-ba.index(a[i][1]), a[i][1])
		t1a[aa.index(a[i][0])] = 'P'
		t1a[2*n-3-ba.index(a[i][1])] = 'S'
		# print (2*n-3-ba.index(a[i][1]))
	elif t1.startswith(a[i][1][:-1]) and t1.endswith(a[i][0][1:]):
		ent1 = True
		s1[i] = a[i][1][-1]
		s1[n-1-i] = a[i][0][0]
		t1a[aa.index(a[i][0])] = 'S'
		# print (aa.index(a[i][1]), a[i][1])
		t1a[2*n-3-ba.index(a[i][1])] = 'P'
		# print (2*n-3-ba.index(a[i][0]), a[i][0])
	if ent1==False:
		noans1 = True
	ent2 = False
	if t2.startswith(a[i][0][:-1]) and t2.endswith(a[i][1][1:]):
		ent2 = True
		s2[i] = a[i][0][-1]
		s2[n-1-i] = a[i][1][0]
		# print (aa.index(a[i][0]), a[i][0])
		# print (n-1-ba.index(a[i][1]), a[i][1])
		t2a[aa.index(a[i][0])] = 'P'
		t2a[2*n-3-ba.index(a[i][1])] = 'S'
	elif t2.startswith(a[i][1][:-1]) and t2.endswith(a[i][0][1:]):
		ent2 = True
		s2[i] = a[i][1][-1]
		s2[n-1-i] = a[i][0][0]
		# print (aa.index(a[i][1]), a[i][1])
		# print (n-1-ba.index(a[i][0]), a[i][0])
		t2a[aa.index(a[i][0])] = 'S'
		t2a[2*n-3-ba.index(a[i][1])] = 'P'
	if ent2==False:
		noans2 = True
# print (s1, noans1, s2, noans2)
# print (t1a, t2a)
if noans1:
	print(''.join(t2a))
else:
	print(''.join(t1a))


import sys
n = int(input())
res = ''
arr = []
prsu = []
for i in range(2 * n - 2):
    s = input()
    arr.append(s)
    if len(s) == n - 1:
        prsu.append(s)
pos_pr = 0
pos_su = 0
for x in arr:
    if x == prsu[0][:len(x)]:
        pos_pr += 1
    if x == prsu[1][n-len(x):]:
        pos_su += 1
if pos_su >= n - 1 and pos_pr >= n - 1:
    prsu.reverse()
kek = [''] * len(arr)
ab_su = [0] * len(arr)
ab_pr = [0] * len(arr)
for i in range(len(arr)):
    if arr[i] == prsu[0][:len(arr[i])] and arr[i] != prsu[1][n - len(arr[i]) - 1:]:
        kek[i] = "P"
        ab_pr[len(arr[i]) - 1] = 1
    if arr[i] != prsu[0][:len(arr[i])] and arr[i] == prsu[1][n - len(arr[i]) - 1:]:
        kek[i] = 'S'
        ab_su[len(arr[i]) - 1] = 1
for i in range(len(arr)):
    if kek[i] == '':
        if not ab_pr[len(arr[i]) - 1]:
            kek[i] = 'P'
            ab_pr[len(arr[i]) - 1] = 1
        else:
            kek[i] = 'S'
            ab_su[len(arr[i]) - 1] = 1
right = True
for i in range(len(kek)):
    if kek[i] == 'P' and prsu[0][:len(arr[i])] != arr[i]:
        right = False
    if kek[i] == 'S' and arr[i] != prsu[1][n - len(arr[i]) - 1:]:
        right = False
if right:
    print(''.join(kek))
    return


prsu.reverse()
kek = [''] * len(arr)
ab_su = [0] * len(arr)
ab_pr = [0] * len(arr)
for i in range(len(arr)):
    if arr[i] == prsu[0][:len(arr[i])] and arr[i] != prsu[1][n - len(arr[i]) - 1:]:
        kek[i] = "P"
        ab_pr[len(arr[i]) - 1] = 1
    if arr[i] != prsu[0][:len(arr[i])] and arr[i] == prsu[1][n - len(arr[i]) - 1:]:
        kek[i] = 'S'
        ab_su[len(arr[i]) - 1] = 1
for i in range(len(arr)):
    if kek[i] == '':
        if not ab_pr[len(arr[i]) - 1]:
            kek[i] = 'P'
            ab_pr[len(arr[i]) - 1] = 1
        else:
            kek[i] = 'S'
            ab_su[len(arr[i]) - 1] = 1
print(''.join(kek))


length = int(input())
num = 2*length-2
all_lst = []
longest = []
for i in range(num):
  string = input()
  all_lst.append(string)
  if(len(string) == length -1):
    longest.append(string)
cand_a = longest[0][0] + longest[1]
cand_b = longest[1][0] + longest[0]
cand_a_lst = []
for i in range(length-1):
  cand_a_lst.append(cand_a[:i+1])
  cand_a_lst.append(cand_a[i+1:])
ans = []
count = [0 for i in range(length-1)]
x, y = sorted(cand_a_lst), sorted(all_lst)
if(x == y):
  for mem in all_lst:
    if(mem == cand_a[:len(mem)] and count[len(mem)-1]==0):
      #print(mem + " " + cand_a[:len(mem)])
      ans.append("P")
      count[len(mem)-1] = 1
    else:
      #print(mem + " " + cand_a[length-len(mem):])
      ans.append("S")
else:
  for mem in all_lst:
    if(mem == cand_b[:len(mem)] and count[len(mem)-1]==0):
      #print(mem + " " + cand_a[:len(mem)])
      ans.append("P")
      count[len(mem)-1] = 1
    else:
      #print(mem + " " + cand_a[length-len(mem):])
      ans.append("S")
print("".join(ans))

def f(s):
    X = ""
    k = []
    '''for i in L:
        l = len(i)
        if s[n-l:] in k:
            X += "S"
        elif s[:l] == s[n-l:]:
            k.append(s[:l])
            X += "P"
        else:
            if s[:l] == i:
                X += "P"
                continue
            if s[n-l:] == i:
                X += "S"
                continue
            return 0
    if len(X) == 2*n-2:
        print(X)
        return 1'''
    for i in L:
        l = len(i)
        if l in k:
            if s[:l] == s[n-l:]:
                X += "S"
            else:
                if s[:l] == i:
                    X += "P"
                elif s[n-l:] == i:
                    X += "S"
                else:
                    return 0
        else:
            k.append(l)
            if s[:l] == i:
                X += "P"
            elif s[n-l:] == i:
                X += "S"
            else:
                return 0
    print(X)
    return 1

n = int(input())
L = []
for i in range(2*n-2):
    L.append(input())
P = sorted(L,key= len)
for i in [P[0],P[1]]:
    for j in [P[2*n-3],P[2*n-4]]:
        if f(i+j):
            quit()
        if f(j+i):
            quit()

n = int(input())

lst = []

for i in range((2*n)-2):
    curr = str(input())
    lst.append([i,curr])
    
lst.sort(key=lambda val: len(val[1]),reverse = True)

word1 = lst[0][1] + lst[1][1][-1]
word2 = lst[1][1] + lst[0][1][-1]
bool1 = True
bool2 = True

sp1 = [0 for i in range((2*n)-2)]
sp1[0] = 'P'
sp1[1] = 'S'
sp2 = [0 for i in range((2*n)-2)]
sp2[0] = 'S'
sp2[1] = 'P'

for i in range(2,(2*n)-2,2):
    curr1 = lst[i][1]
    curr2 = lst[i+1][1]
#    print(curr1," ",curr2,word1[:n-int(i/2)-1],word1[int(i/2)+1:])
    if curr1 == word1[:n-int(i/2)-1] and curr2 == word1[int(i/2)+1:]:
        sp1[i] = 'P'
        sp1[i+1] = 'S'
##        print("yes1\n")
##        print(sp1,sp2)
    elif curr2 == word1[:n-int(i/2)-1] and curr1 == word1[int(i/2)+1:]:
        sp1[i] = 'S'
        sp1[i+1] = 'P'
##        print("yes2\n")
    if curr1 == word2[:n-int(i/2)-1] and curr2 == word2[int(i/2)+1:]:
        sp2[i] = 'P'
        sp2[i+1] = 'S'
##        print("yes3\n")
    elif curr2 == word2[:n-int(i/2)-1] and curr1 == word2[int(i/2)+1:]:
        sp2[i] = 'S'
        sp2[i+1] = 'P'
##        print("yes4\n")

for i in sp1:
    if i == 0:
        bool1 = False
        break
for i in sp2:
    if i == 0:
        bool2 = False
##print(sp1,sp2)
if bool1:
    ans = ''
    newl = []
    for j in range(len(lst)):
        newl.append(lst[j]+[sp1[j]])
    newl.sort(key=lambda val: val[0])
    for j in newl:
        ans = ans + j[2]
    print(ans)
elif bool2:
    ans = ''
    newl = []
    for j in range(len(lst)):
        newl.append(lst[j]+[sp2[j]])
    newl.sort(key=lambda val: val[0])
    for j in newl:
        ans = ans + j[2]
    print(ans)
    


#!/usr/bin/env python
# -*- coding: utf-8 -*-

n = int(input())
sp = [[]for i in range(n)]
ns = []
for i in range(2*n-2):
    s = input()
    sp[len(s)].append(s)
    ns.append(s)
s1 = sp[n-1][0] + sp[n-1][1][-1]
s2 = sp[n-1][1][0] + sp[n-1][0]

ss = [s1, s2]
correct_s = ''
res = True
ii = 0
correct_s = ss[ii]
for i in range(1, n):
    if correct_s[:i] == sp[i][0] and correct_s[-i:] == sp[i][1]:
        continue
    if correct_s[:i] == sp[i][1] and correct_s[-i:] == sp[i][0]:
        continue
    res = False
    break
if res: pass
else: correct_s = ss[1]
ans = ''
f = [0]*n
for s in ns:
    if f[len(s)] == 0:
        if correct_s[:len(s)] == s: 
            ans += 'P'
            f[len(s)] = 1
        else: 
            ans += 'S'
            f[len(s)] = 2
    else:
        res = 'P' if f[len(s)] == 2 else 'S'
        ans += res
print(ans)
    


from collections import defaultdict

n = int(input())
tc = (2 * n) - 2

total = []
for _ in range(tc):
    string = input().strip()
    total.append((string, _))

# sort by strings
total.sort(key=lambda x: x[0])
# sort by length now
total.sort(key=lambda x: len(x[0]))

x1 = total[tc-2][0]
x2 = total[tc-1][0]

ans = x1 + x2[-1]
ans1 = x2 + x1[-1]

if x1[1:] == x2[:-1]:
    pass     
else:
    ans, ans1 = ans1, ans
    
alt = False

ans_dict = defaultdict()
for i in range(0, tc, 2):

    str1 = total[i][0]
    str2 = total[i+1][0]

    idx1 = total[i][1]
    idx2 = total[i+1][1]

    assert(len(str1) == len(str2))

    if str1 == ans[:len(str1)] and str2 == ans[-len(str1):]:
        ans_dict[idx1] = 'P'
        ans_dict[idx2] = 'S'
    elif str2 == ans[:len(str1)] and str1 == ans[-len(str1):]:
        ans_dict[idx1] = 'S'
        ans_dict[idx2] = 'P'
    else:
        alt = True

if alt == True:
    ans = ans1
    # do again
    for i in range(0, tc, 2):
        str1 = total[i][0]
        str2 = total[i+1][0]

        idx1 = total[i][1]
        idx2 = total[i+1][1]

        # assert(len(str1) == len(str2))

        if str1 == ans[:len(str1)] and str2 == ans[-len(str1):]:
            ans_dict[idx1] = 'P'
            ans_dict[idx2] = 'S'
        elif str2 == ans[:len(str1)] and str1 == ans[-len(str1):]:
            ans_dict[idx1] = 'S'
            ans_dict[idx2] = 'P'
    

for i in range(0, tc):
    print(ans_dict[i], end='')
print()