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: MEDIUM_HARD

Solutions:
def check(pref, suf):
	string = pref + suf[-1]
	for (value, _) in pref_suf_list:
		lenofvalue = len(value)
		if string[:lenofvalue] != value and string[n - lenofvalue:] != value:
			return False
	return True

def printorder(pref, suf):
	string = pref + suf[-1]
	answer = [0] * (2 * n - 2)
	count = 0
	for i in range(2 * n - 2):
		if i % 2 == 1:
			answer[pref_suf_list[i][1]] = 'S' if answer[pref_suf_list[i - 1][1]] == 'P' else 'P'
			continue
		if string[:len(pref_suf_list[i][0])] == pref_suf_list[i][0]:
			answer[pref_suf_list[i][1]] = 'P'
		else:
			answer[pref_suf_list[i][1]] = 'S'
		count += 1
	print(''.join(answer))
n = int(input())
pref_suf_list = [(input(), i) for i in range(2 * n - 2)]
pref_suf_list.sort(key=lambda x: len(x[0]))
(pref, suf) = pref_suf_list[len(pref_suf_list) - 2:]
first_try = check(pref[0], suf[0])
if first_try:
	printorder(pref[0], suf[0])
else:
	printorder(suf[0], pref[0])


def is_prefix(long, short):
	return short == long[:len(short)]

def is_suffix(long, short):
	return short == long[-len(short):]

def main():
	n = int(input())
	l = []
	shorts = []
	longs = []
	if n == 2:
		_ = input()
		_ = input()
		print('PS')
		return
	for i in range(2 * n - 2):
		inp = input()
		l.append(inp)
		if len(inp) == 1:
			shorts.append(inp)
		elif len(inp) == n - 1:
			longs.append(inp)
	(s1, s2) = shorts
	(l1, l2) = longs
	d = {}
	if s1 + l1 == l2 + s2:
		d[s1 + l1] = [[], {}]
	if s1 + l2 == l1 + s2:
		d[s1 + l2] = [[], {}]
	if s2 + l1 == l2 + s1:
		d[s2 + l1] = [[], {}]
	if s2 + l2 == l1 + s1:
		d[s2 + l2] = [[], {}]
	for wo in l:
		keys = list(d.keys())
		z = 0
		while True:
			if z >= len(keys):
				break
			k = keys[z]
			if is_prefix(k, wo):
				if wo in d[k][1] and d[k][1][wo] == 0:
					if is_suffix(k, wo):
						d[k][0].append('S')
					else:
						del d[k]
				else:
					d[k][1][wo] = 0
					d[k][0].append('P')
			elif is_suffix(k, wo):
				if wo in d[k][1] and d[k][1][wo] == 1:
					del d[k]
				else:
					d[k][1][wo] = 1
					d[k][0].append('S')
			else:
				del d[k]
			z += 1
	print(''.join(d[list(d.keys())[0]][0]))
main()


n = int(input())
ar = []
for _ in range(2 * n - 2):
	kek = input()
	ar.append([kek, len(kek), _])
ar.sort(key=lambda x: -x[1])
ans = [''] * (2 * n - 2)
pref = ar[0][0]
kref = ar[1][0]
flag = 0
for i in range(0, 2 * n - 2, 2):
	if ar[i][0] == pref[0:n - i // 2 - 1]:
		ans[ar[i][2]] = 'P'
		if ar[i + 1][0] == kref[i // 2:]:
			ans[ar[i + 1][2]] = 'S'
		else:
			flag = 1
	elif ar[i][0] == kref[i // 2:]:
		ans[ar[i][2]] = 'S'
		if ar[i + 1][0] == pref[0:n - i // 2 - 1]:
			ans[ar[i + 1][2]] = 'P'
		else:
			flag = 1
	else:
		flag = 1
if flag == 0:
	print(''.join(ans))
else:
	ans = [''] * (2 * n - 2)
	pref = ar[1][0]
	kref = ar[0][0]
	flag = 0
	for i in range(0, 2 * n - 2, 2):
		if ar[i][0] == pref[0:n - i // 2 - 1]:
			ans[ar[i][2]] = 'P'
			if ar[i + 1][0] == kref[i // 2:]:
				ans[ar[i + 1][2]] = 'S'
			else:
				flag = 1
		elif ar[i][0] == kref[i // 2:]:
			ans[ar[i][2]] = 'S'
			if ar[i + 1][0] == pref[0:n - i // 2 - 1]:
				ans[ar[i + 1][2]] = 'P'
			else:
				flag = 1
		else:
			flag = 1
	print(''.join(ans))


def Prefixes_and_Suffixes():
	size_str = int(input())
	str_arr = []
	for i in range(2 * size_str - 2):
		str_arr.append(input())
	first_found = False
	for i in range(len(str_arr)):
		if len(str_arr[i]) == size_str - 1 and (not first_found):
			first_found = True
			st1 = str_arr[i]
		elif len(str_arr[i]) == size_str - 1:
			st2 = str_arr[i]
	if st1[1:] == st2[:len(st2) - 1]:
		orginal_String = st1 + st2[-1]
		output = ''
		done = [False for i in range(size_str - 1)]
		for i in range(len(str_arr)):
			if str_arr[i][0] == orginal_String[0]:
				j = 0
				is_prefix = True
				while j < len(str_arr[i]):
					if str_arr[i][j] != orginal_String[j]:
						output += 'S'
						is_prefix = False
						break
					j += 1
				if is_prefix and (not done[len(str_arr[i]) - 1]):
					output += 'P'
					done[len(str_arr[i]) - 1] = True
				elif is_prefix and done[len(str_arr[i]) - 1]:
					output += 'S'
			else:
				output += 'S'
		if output.count('P') == output.count('S'):
			return output
		else:
			orginal_String = st2 + st1[-1]
			output = ''
			done = [False for i in range(size_str - 1)]
			for i in range(len(str_arr)):
				if str_arr[i][0] == orginal_String[0]:
					j = 0
					is_prefix = True
					while j < len(str_arr[i]):
						if str_arr[i][j] != orginal_String[j]:
							output += 'S'
							is_prefix = False
							break
						j += 1
					if is_prefix and (not done[len(str_arr[i]) - 1]):
						output += 'P'
						done[len(str_arr[i]) - 1] = True
					elif is_prefix and done[len(str_arr[i]) - 1]:
						output += 'S'
				else:
					output += 'S'
			return output
	else:
		orginal_String = st2 + st1[-1]
		output = ''
		done = [False for i in range(size_str - 1)]
		for i in range(len(str_arr)):
			if str_arr[i][0] == orginal_String[0]:
				j = 0
				is_prefix = True
				while j < len(str_arr[i]):
					if str_arr[i][j] != orginal_String[j]:
						output += 'S'
						is_prefix = False
						break
					j += 1
				if is_prefix and (not done[len(str_arr[i]) - 1]):
					output += 'P'
					done[len(str_arr[i]) - 1] = True
				elif is_prefix and done[len(str_arr[i]) - 1]:
					output += 'S'
			else:
				output += 'S'
		return output
remained_test_cases = 1
while remained_test_cases > 0:
	print(Prefixes_and_Suffixes())
	remained_test_cases -= 1


def solve(origin):
	post = {origin[i:] for i in range(n)}
	pre = {origin[:i + 1] for i in range(n)}
	ans = [-1] * (2 * n - 2)
	(pre_cnt, post_cnt) = (0, 0)
	for (index, i) in enumerate(l):
		if i in pre and i not in post:
			ans[index] = 1
		elif i in post and i not in pre:
			ans[index] = 2
		elif i in post and i in pre:
			ans[index] = 0
	for i in range(2 * n - 2):
		if not ans[i]:
			(a, b) = d[l[i]]
			if a == i:
				j = b
			else:
				j = a
			ans[i] = 'P'
			ans[j] = 'S'
			pre_cnt -= 1
			post_cnt -= 1
		elif ans[i] == 1:
			ans[i] = 'P'
		elif ans[i] == 2:
			ans[i] = 'S'
	return ans
n = int(input())
max_len = 0
max_str = []
l = []
d = {}
for i in range(2 * n - 2):
	temp = input()
	l.append(temp)
	d.setdefault(temp, []).append(i)
	if len(temp) > max_len:
		max_str = [temp]
		max_len = len(temp)
	elif len(temp) == max_len:
		max_str.append(temp)
(a, b) = max_str
origins = []
if a[1:] == b[:-1]:
	origins.append(a + b[-1])
if a[:-1] == b[1:]:
	origins.append(b + a[-1])
for origin in origins:
	temp_ans = solve(origin)
	try:
		ans = ''.join(temp_ans)
		print(ans)
		break
	except TypeError:
		continue


n = int(input())
(a, b) = ('', '')
arr = []
pref = [1] * n
for i in range(2 * (n - 1)):
	x = input()
	if len(x) + 1 == n:
		if a == '':
			a = x
		else:
			b = x
	arr.append(x)
if a[1:] != b[:-1]:
	(a, b) = (b, a)
ans = ''
for i in arr:
	if i == a[:len(i)] and pref[len(i)] > 0:
		ans += 'P'
		pref[len(i)] = 0
	else:
		ans += 'S'
if ans.count('P') != n - 1:
	(a, b) = (b, a)
	ans = ''
	pref = [1] * n
	for i in arr:
		if i == a[:len(i)] and pref[len(i)] > 0:
			ans += 'P'
			pref[len(i)] = 0
		else:
			ans += 'S'
print(ans)


def f(s):
	X = ''
	k = []
	for i in L:
		l = len(i)
		if l in k:
			if s[:l] == s[n - l:]:
				X += 'S'
			elif 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()


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

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

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	n = ii()
	s = []
	for i in range(2 * n - 2):
		s.append(si())
	x = []
	for i in range(2 * n - 2):
		if len(s[i]) == n - 1:
			x.append(s[i])
	ans = [''] * (2 * n - 1)
	pre = x[0]
	suf = x[1]
	f = 0
	for i in range(n - 1):
		t = pre[:i + 1]
		f = 0
		for j in range(2 * n - 2):
			if s[j] == t and ans[j] == '':
				ans[j] = 'P'
				f = 1
				break
		if f == 0:
			break
	if f == 1:
		for i in range(n - 2, -1, -1):
			t = suf[i:]
			f = 0
			for j in range(2 * n - 2):
				if s[j] == t and ans[j] == '':
					ans[j] = 'S'
					f = 1
					break
			if f == 0:
				break
		if f == 1:
			for i in range(2 * n - 2):
				print(ans[i], end='')
			return
	ans = [''] * (2 * n - 1)
	pre = x[1]
	suf = x[0]
	f = 0
	for i in range(n - 1):
		t = pre[:i + 1]
		f = 0
		for j in range(2 * n - 2):
			if s[j] == t and ans[j] == '':
				ans[j] = 'P'
				f = 1
				break
		if f == 0:
			break
	if f == 1:
		for i in range(n - 2, -1, -1):
			t = suf[i:]
			f = 0
			for j in range(2 * n - 2):
				if s[j] == t and ans[j] == '':
					ans[j] = 'S'
					f = 1
					break
			if f == 0:
				break
		if f == 1:
			for i in range(2 * n - 2):
				print(ans[i], end='')
			return
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = [input() for i in range(2 * n - 2)]
sorted_a = sorted(a, key=len, reverse=True)
guess = sorted_a[0] + sorted_a[1][-1]
guess2 = sorted_a[1] + sorted_a[0][-1]
check = [0] * len(a)
for i in range(0, len(a), 2):
	if not (guess.startswith(sorted_a[i]) and guess.endswith(sorted_a[i + 1]) or (guess.startswith(sorted_a[1 + i]) and guess.endswith(sorted_a[i]))):
		guess = guess2
		break
for word in a:
	if guess.startswith(word):
		if check[len(word)] == 0:
			print('P', end='')
			check[len(word)] = 1
		else:
			print('S', end='')
	else:
		print('S', end='')


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
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)


from collections import namedtuple
SPos = namedtuple('SPos', 'string, pos')
n = int(input())
levels = [[] for _ in range(n)]
for i in range(2 * n - 2):
	s = input()
	levels[len(s)].append(SPos(string=s, pos=i))
checkpoint = 1
for i in range(2, n):
	if levels[i][0].string[:-1] == levels[i - 1][0].string and levels[i][1].string[1:] == levels[i - 1][1].string:
		pass
	elif levels[i][1].string[:-1] == levels[i - 1][0].string and levels[i][0].string[1:] == levels[i - 1][1].string:
		(levels[i][0], levels[i][1]) = (levels[i][1], levels[i][0])
	else:
		for j in range(i - 1, checkpoint - 1, -1):
			if not (levels[j + 1][0].string[:-1] == levels[j][0].string and levels[j + 1][1].string[1:] == levels[j][1].string):
				(levels[j][0], levels[j][1]) = (levels[j][1], levels[j][0])
		if not (levels[i][0].string[:-1] == levels[i - 1][0].string and levels[i][1].string[1:] == levels[i - 1][1].string):
			(levels[i][0], levels[i][1]) = (levels[i][1], levels[i][0])
		checkpoint = i
result = ['' for _ in range(2 * n - 2)]
for level in levels[1:]:
	result[level[0].pos] = 'P'
	result[level[1].pos] = 'S'
print(''.join(result))


import sys

def solve(io):
	N = io.read_int()
	A = io.read_string_array(2 * N - 2)
	idxs = [[] for _ in range(0, N)]
	for (i, s) in enumerate(A):
		idxs[len(s)].append(i)
	fwd = A[idxs[N - 1][0]] + A[idxs[N - 1][1]][-1]
	ps = make_ps(fwd, A, idxs)
	if ps:
		io.println(''.join(ps))
	else:
		io.println(''.join(make_ps(A[idxs[N - 1][1]] + A[idxs[N - 1][0]][-1], A, idxs)))

def make_ps(S, A, idxs):
	ans = [None] * len(A)
	for (i, (j, k)) in list(enumerate(idxs))[1:]:
		if S.startswith(A[j]) and S.endswith(A[k]):
			ans[j] = 'P'
			ans[k] = 'S'
		elif S.endswith(A[j]) and S.startswith(A[k]):
			ans[j] = 'S'
			ans[k] = 'P'
		else:
			return None
	return ans

class IO:
	in_stream = None
	out_stream = None
	raw = ''
	buf = []
	pos = 0

	def __init__(self, input_stream, output_stream):
		self.in_stream = input_stream
		self.out_stream = output_stream

	def read_to_buffer(self):
		self.raw = self.in_stream.readline().rstrip('\n')
		self.buf = self.raw.split()
		self.pos = 0

	def read_string(self):
		while self.pos == len(self.buf):
			self.read_to_buffer()
		ans = self.buf[self.pos]
		self.pos += 1
		return ans

	def read_int(self):
		return int(self.read_string())

	def read_float(self):
		return float(self.read_string())

	def read_string_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_string())
		return arr

	def read_int_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_int())
		return arr

	def read_float_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_float())
		return arr

	def read_line(self):
		while self.pos == len(self.buf):
			self.read_to_buffer()
		if self.pos > 0:
			raise ValueError('Cannot call read_line in the middle of a line.')
		self.pos = len(self.buf)
		return self.raw

	def print(self, *args):
		self.out_stream.write(' '.join([str(x) for x in args]))

	def println(self, *args):
		self.print(*args)
		self.print('\n')

	def println_array(self, arr, sep=' '):
		self.println(sep.join((str(x) for x in arr)))

	def flush_output(self):
		self.out_stream.flush()
pythonIO = IO(sys.stdin, sys.stdout)
solve(pythonIO)
pythonIO.flush_output()


import io
N = int(input())
a = []
for i in range(2 * N - 2):
	v = input()
	a.append(v)
q = w = ''
for i in a:
	if len(i) == N - 1:
		if q == '':
			q = i
		else:
			w = i
b = []
for i in range(N - 1):
	b.append([-1, -1])
for i in range(len(a)):
	val = len(a[i]) - 1
	b[val][int(b[val][0] != -1)] = i

def test(s):
	global res
	res = [0] * len(a)
	for e in b:
		(q, w) = (e[0], e[1])
		v = len(a[q])
		if a[q] == s[:v] and a[w] == s[-v:]:
			(res[q], res[w]) = ('P', 'S')
		elif a[w] == s[:v] and a[q] == s[-v:]:
			(res[q], res[w]) = ('S', 'P')
		else:
			return False
	return True

def main():
	if q[1:] == w[:-1]:
		if test(q[0] + w):
			for i in res:
				print(i, end='')
			print()
			return
	if w[1:] == q[:-1]:
		if test(w[0] + q):
			for i in res:
				print(i, end='')
			print()
			return
main()


from collections import defaultdict
n = int(input())
tc = 2 * n - 2
total = []
for _ in range(tc):
	string = input().strip()
	total.append((string, _))
total.sort(key=lambda x: x[0])
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
	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]
		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()


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())
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(''.join(rr))
else:
	(r, rr) = check(y, x, s, n)
	print(''.join(rr))


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))


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'
for i in range(1, n - 1):
	ent1 = False
	t1 = ''.join(s1)
	t2 = ''.join(s2)
	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]
		t1a[aa.index(a[i][0])] = 'P'
		t1a[2 * n - 3 - ba.index(a[i][1])] = 'S'
	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'
		t1a[2 * n - 3 - ba.index(a[i][1])] = 'P'
	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]
		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]
		t2a[aa.index(a[i][0])] = 'S'
		t2a[2 * n - 3 - ba.index(a[i][1])] = 'P'
	if ent2 == False:
		noans2 = True
if noans1:
	print(''.join(t2a))
else:
	print(''.join(t1a))


def magic(string):
	str = string
	for i in range(2 * n - 2):
		for j in range(i, 2 * n - 2):
			if len(str[i]) < len(str[j]):
				temp = string[i]
				str[i] = string[j]
				str[j] = temp
	return str
n = int(input())
string = []
for i in range(2 * n - 2):
	a = input()
	string.append(a)
str = list.copy(string)
sort_string = magic(str)
if sort_string[0][1:n - 1] != sort_string[1][0:n - 2]:
	temp = sort_string[0]
	sort_string[0] = sort_string[1]
	sort_string[1] = temp
string1 = sort_string[0] + sort_string[1][n - 2]
string2 = sort_string[1] + sort_string[0][0]
if n > 2:
	if string1[0:n - 2] == sort_string[2] and string1[2:n] == sort_string[3] or (string1[0:n - 2] == sort_string[3] and string1[2:n] == sort_string[2]):
		word = string1
	else:
		word = string2
else:
	word = string1
length = 0
value = [0 for x in range(2 * n - 2)]
for i in range(0, 2 * n - 2):
	length = len(string[i])
	for j in range(i + 1, 2 * n - 2):
		if length == len(string[j]):
			if word.find(string[i]) == 0:
				value[i] = 'P'
				value[j] = 'S'
			else:
				value[i] = 'S'
				value[j] = 'P'
print(''.join(value))


n = int(input())
l = []
a = []
z = []
for i in range(2 * n - 2):
	x = input()
	l.append(x)
	z.append(x)
	if len(x) == n - 1:
		a.append(x)
z.sort()
q = [2] * (n - 1)
e = [True] * (n - 1)
ans1 = a[0][0] + a[1]
ans2 = a[1][0] + a[0]
s_a = []
for i in range(1, n):
	s_a.append(ans1[i:])
	s_a.append(ans1[:-i])
s_a.sort()
s_b = []
for i in range(1, n):
	s_b.append(ans2[i:])
	s_b.append(ans2[:-i])
s_b.sort()
if s_a == z:
	ans = ans1
else:
	ans = ans2
sol = ''
for i in range(2 * n - 2):
	r = len(l[i])
	if q[r - 1] == 2:
		if l[i] == ans[:r]:
			sol += 'P'
			e[r - 1] = False
		else:
			sol += 'S'
	elif e[r - 1] == False:
		sol += 'S'
	else:
		sol += 'P'
	q[r - 1] -= 1
print(sol)


n = int(input())
s = []
for i in range(2 * n - 2):
	s.append(input())
a = s
l = [len(i) for i in s]
s = [j for (i, j) in sorted(zip(l, s))]
s1 = s[-2] + s[-1][-1]
s2 = s[-1] + s[-2][-1]
flag = 0
scnt = 0
pcnt = 0
j1 = 1
j2 = -1
tss = s1
for i in range(0, 2 * n - 2):
	tp = s1[:j1]
	ts = s1[j2:]
	if i % 2:
		if s[i] == tp:
			pcnt += 1
			j1 += 1
		elif s[i] == ts:
			scnt += 1
			j2 -= 1
		else:
			flag = 1
			break
	elif s[i] == ts:
		scnt += 1
		j2 -= 1
	elif s[i] == tp:
		pcnt += 1
		j1 += 1
	else:
		flag = 1
		break
j1 = 1
j2 = -1
hsh = {}
if flag or pcnt != scnt:
	s1 = s2
	for i in range(0, 2 * n - 2):
		tp = s1[:j1]
		ts = s1[j2:]
		if i % 2:
			if s[i] == tp:
				hsh[s[i]] = 'P'
				pcnt += 1
				j1 += 1
			elif s[i] == ts:
				hsh[s[i]] = 'S'
				scnt += 1
				j2 -= 1
			else:
				flag = 1
				break
		elif s[i] == ts:
			hsh[s[i]] = 'S'
			scnt += 1
			j2 -= 1
		elif s[i] == tp:
			hsh[s[i]] = 'P'
			pcnt += 1
			j1 += 1
		else:
			flag = 1
			break
else:
	s1 = tss
	for i in range(0, 2 * n - 2):
		tp = s1[:j1]
		ts = s1[j2:]
		if i % 2:
			if s[i] == tp:
				hsh[s[i]] = 'P'
				pcnt += 1
				j1 += 1
			elif s[i] == ts:
				hsh[s[i]] = 'S'
				scnt += 1
				j2 -= 1
			else:
				flag = 1
				break
		elif s[i] == ts:
			hsh[s[i]] = 'S'
			scnt += 1
			j2 -= 1
		elif s[i] == tp:
			hsh[s[i]] = 'P'
			pcnt += 1
			j1 += 1
		else:
			flag = 1
			break
hsh2 = {}
for i in range(2 * n - 2):
	hsh2[a[i]] = 0
for i in range(2 * n - 2):
	if hsh2[a[i]] == 0:
		print(hsh[a[i]], end='')
		hsh2[a[i]] += 1
	elif hsh[a[i]] == 'P':
		print('S', end='')
	else:
		print('P', end='')


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='')


n = int(input())
l = []
for i in range(2 * n - 2):
	l.append((i, input()))
l.sort(key=lambda t: len(t[1]), reverse=True)

def f(p, s):
	for i in range(2, n * 2 - 2, 2):
		if not (p.startswith(l[i + 0][1]) and s.endswith(l[i + 1][1]) or (p.startswith(l[i + 1][1]) and s.endswith(l[i + 0][1]))):
			return False
	return True
p = l[0][1] if f(l[0][1], l[1][1]) else l[1][1]
ans = []
l.sort()
v = [False] * 100
for (i, x) in l:
	if p.startswith(x) and (not v[len(x)]):
		ans.append('P')
		v[len(x)] = True
	else:
		ans.append('S')
print(''.join(ans))


prob_len = int(input())
strings = list()
for _ in range(prob_len * 2 - 2):
	strings.append(input().strip())
sorted_strings = sorted(enumerate(strings), key=lambda x: len(x[1]))
answers = [None] * len(sorted_strings)
last_p = ''
last_p_idx = None
last_s = ''
last_s_idx = None
for x in range(prob_len - 1):
	(a_idx, a) = sorted_strings[x * 2]
	(b_idx, b) = sorted_strings[x * 2 + 1]
	is_a_prefix = None
	if len(a) == 1:
		is_a_prefix = True
	elif a.startswith(last_p) and b.endswith(last_s):
		is_a_prefix = True
	elif a.endswith(last_s) and b.startswith(last_p):
		is_a_prefix = False
	else:
		for idx in range(len(answers)):
			if answers[idx] == 'S':
				answers[idx] = 'P'
			elif answers[idx] == 'P':
				answers[idx] = 'S'
		last_s = strings[last_p_idx]
		last_p = strings[last_s_idx]
		if a.startswith(last_p) and b.endswith(last_s):
			is_a_prefix = True
		elif a.endswith(last_s) and b.startswith(last_p):
			is_a_prefix = False
		else:
			raise Exception()
	if is_a_prefix:
		answers[a_idx] = 'P'
		last_p = a
		last_p_idx = a_idx
		answers[b_idx] = 'S'
		last_s = b
		last_s_idx = b_idx
	else:
		answers[a_idx] = 'S'
		last_s = a
		last_s_idx = a_idx
		answers[b_idx] = 'P'
		last_p = b
		last_p_idx = b_idx
print(''.join(answers))


import sys
from collections import defaultdict
n = int(sys.stdin.readline())
dic = defaultdict(list)
for i in range(2 * n - 2):
	s = sys.stdin.readline()[:-1]
	m = len(s)
	dic[m].append([s, i])
(a, b) = (dic[n - 1][0][0], dic[n - 1][1][0])
(c, d) = (dic[1][0][0], dic[1][1][0])
one = a + c
if one[1:] == b:
	prefix = a
	suffix = b
else:
	one = a + d
	if one[1:] == b:
		prefix = a
		suffix = b
	else:
		prefix = b
		suffix = a
ans = [0 for _ in range(2 * n - 2)]
z = True
countp = 0
for i in dic:
	boo = True
	for j in range(2):
		m = len(dic[i][j][0])
		if prefix[:m] == dic[i][j][0]:
			if boo:
				boo = False
				ans[dic[i][j][1]] = 'P'
				countp += 1
			else:
				ans[dic[i][j][1]] = 'S'
		else:
			ans[dic[i][j][1]] = 'S'
if countp == n - 1:
	print(''.join((x for x in ans)))
	sys.exit()
else:
	(prefix, suffix) = (suffix, prefix)
	for i in dic:
		boo = True
		for j in range(2):
			m = len(dic[i][j][0])
			if prefix[:m] == dic[i][j][0]:
				if boo:
					boo = False
					ans[dic[i][j][1]] = 'P'
					countp += 1
				else:
					ans[dic[i][j][1]] = 'S'
			else:
				ans[dic[i][j][1]] = 'S'
	print(''.join((x for x in ans)))


import sys
from collections import deque
import math
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
li = lambda : list(input_())
pr = lambda x: print(x)
f = lambda : sys.stdout.flush()
n = ii()
ma = []
al = []
mi = []
for i in range(2 * n - 2):
	a = ip()
	if len(a) == n - 1:
		ma.append(a)
	al.append(a)
	if len(a) <= 2:
		mi.append(a)
(x, y) = (ma[0], ma[1])
ans = ''
if x[1:] == y[:-1] and x[0] in mi and (x[0:2] in mi):
	ans = x[0] + y
else:
	ans = y[0] + x
d = {}
for i in al:
	if ans.startswith(i) and (not len(i) in d):
		print('P', end='')
		d[len(i)] = 1
	else:
		print('S', end='')


from collections import defaultdict
import sys
input = sys.stdin.readline

def solve(a, b):
	ans = ['?'] * m
	w = ['?'] * n
	ok = 1
	(s1, k1) = x[n - 1][a]
	(s2, k2) = x[n - 1][b]
	for i in range(n - 1):
		w[i] = s1[i]
	for i in range(1, n):
		if not w[i] == '?' and (not w[i] == s2[i - 1]):
			ok = 0
			break
		w[i] = s2[i - 1]
	if ok:
		for i in range(1, n):
			(s1, k1) = x[i][0]
			(s2, k2) = x[i][1]
			w0 = ['?'] * n
			ok0 = 1
			for j in range(i):
				w0[j] = s1[j]
			for j in range(n - i, n):
				if not w0[j] == '?' and (not w0[j] == s2[i + j - n]):
					ok0 = 0
					break
				w0[j] = s2[i + j - n]
			for j in range(n):
				if not w0[j] == '?' and (not w[j] == w0[j]):
					ok0 = 0
					break
			if ok0:
				(ans[k1], ans[k2]) = ('P', 'S')
				continue
			w0 = ['?'] * n
			ok0 = 1
			for j in range(i):
				w0[j] = s2[j]
			for j in range(n - i, n):
				if not w0[j] == '?' and (not w0[j] == s1[i + j - n]):
					ok0 = 0
					break
				w0[j] = s1[i + j - n]
			for j in range(n):
				if not w0[j] == '?' and (not w[j] == w0[j]):
					ok0 = 0
					break
			if ok0:
				(ans[k1], ans[k2]) = ('S', 'P')
			else:
				ok = 0
				break
	if ok:
		print(''.join(ans))
		exit()
	return
n = int(input())
m = 2 * n - 2
x = [[] for _ in range(n)]
for i in range(m):
	s = list(input().rstrip())
	l = len(s)
	x[l].append((s, i))
solve(0, 1)
solve(1, 0)


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)


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]
	if curr1 == word1[:n - int(i / 2) - 1] and curr2 == word1[int(i / 2) + 1:]:
		sp1[i] = 'P'
		sp1[i + 1] = 'S'
	elif curr2 == word1[:n - int(i / 2) - 1] and curr1 == word1[int(i / 2) + 1:]:
		sp1[i] = 'S'
		sp1[i + 1] = 'P'
	if curr1 == word2[:n - int(i / 2) - 1] and curr2 == word2[int(i / 2) + 1:]:
		sp2[i] = 'P'
		sp2[i + 1] = 'S'
	elif curr2 == word2[:n - int(i / 2) - 1] and curr1 == word2[int(i / 2) + 1:]:
		sp2[i] = 'S'
		sp2[i + 1] = 'P'
for i in sp1:
	if i == 0:
		bool1 = False
		break
for i in sp2:
	if i == 0:
		bool2 = False
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)


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)):
	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)):
		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='')


def check(mid):
	d = {}
	ans = ''
	for i in range(1, n, 1):
		pre = mid[:i]
		suf = mid[i:]
		if pre not in d:
			d[pre] = 'P'
		else:
			d[pre] = ['P', 'S']
		if suf not in d:
			d[suf] = 'S'
		else:
			d[suf] = ['P', 'S']
	for i in range(2 * n - 2):
		if a[i] in d and len(d[a[i]]) == 1:
			ans += d[a[i]]
		elif a[i] in d and len(d[a[i]]) == 2:
			if d[a[i]][0] == 'P':
				ans += 'P'
				d[a[i]][0] = 'S'
			else:
				ans += 'S'
	return [ans.count('P') == ans.count('S') and len(ans) == 2 * n - 2, ans]
n = int(input())
a = []
aa = []
for i in range(2 * n - 2):
	s = input()
	a.append(s)
	aa.append([len(s), s])
aa.sort()
a1 = aa[-1][1]
a2 = aa[-2][1]
mid = ''
if 1:
	mid = a1[1:]
	(g, h) = check(aa[0][1] + mid + aa[1][1])
	if g:
		print(h)
		exit()
	(g, h) = check(aa[1][1] + mid + aa[0][1])
	if g:
		print(h)
		exit()
	mid = a1[:-1]
	(g, h) = check(aa[0][1] + mid + aa[1][1])
	if g:
		print(h)
		exit()
	(g, h) = check(aa[1][1] + mid + aa[0][1])
	if g:
		print(h)
		exit()


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
main()


n = int(input())
a = []
s = []
final = ['N'] * (2 * n - 2)
for i in range(2 * n - 2):
	a.append(input())
	if len(a[-1]) == n - 1:
		s.append(i)
x = a[s[0]]
final[s[0]] = 'P'
x1 = a[s[1]]
final[s[1]] = 'S'
flag = 1
if a[s[0]][1:] != a[s[1]][:-1]:
	x = a[s[1]]
	x1 = a[s[0]]
	final[s[1]] = 'P'
	final[s[0]] = 'S'
	flag = 0
done = set()
for i in range(0, 2 * n - 2):
	if i in s:
		continue
	if a[i] in done:
		continue
	elif a[i] == x[:len(a[i])]:
		final[i] = 'P'
		done.add(a[i])
for i in range(0, 2 * n - 2):
	if i in s:
		continue
	if final[i] != 'N':
		continue
	else:
		final[i] = 'S'
ans = ''.join(final)
if ans.count('S') != ans.count('P'):
	final = ['N'] * (2 * n - 2)
	if flag == 0:
		x = a[s[0]]
		final[s[0]] = 'P'
		x1 = a[s[1]]
		final[s[1]] = 'S'
	else:
		x = a[s[1]]
		x1 = a[s[0]]
		final[s[1]] = 'P'
		final[s[0]] = 'S'
		flag = 0
	done = set()
	for i in range(0, 2 * n - 2):
		if i in s:
			continue
		if a[i] in done:
			continue
		elif a[i] == x[:len(a[i])]:
			final[i] = 'P'
			done.add(a[i])
	for i in range(0, 2 * n - 2):
		if i in s:
			continue
		if final[i] != 'N':
			continue
		else:
			final[i] = 'S'
	ans = ''.join(final)
print(ans)


n = int(input())
if n == 2:
	print('PS')
else:
	info = []
	for i in range(2 * n - 2):
		info.append(input())
	infot = [(index, info[index]) for index in range(2 * n - 2)]
	infot.sort(key=lambda s: len(s[1]))
	rest = []
	st = ''
	s = [' '] * n
	if infot[2][1][0] == infot[0][1][0] and infot[3][1][1] == infot[1][1][0]:
		st += infot[2][1]
		rest.append((infot[0][0], 'P'))
		rest.append((infot[1][0], 'S'))
		rest.append((infot[2][0], 'P'))
		rest.append((infot[3][0], 'S'))
		s[0] = infot[0][1][0]
		s[1] = infot[2][1][1]
		s[n - 2] = infot[3][1][0]
		s[n - 1] = infot[1][1][0]
	elif infot[3][1][0] == infot[0][1][0] and infot[2][1][1] == infot[1][1][0]:
		st += infot[3][1]
		rest.append((infot[0][0], 'P'))
		rest.append((infot[1][0], 'S'))
		rest.append((infot[3][0], 'P'))
		rest.append((infot[2][0], 'S'))
		s[0] = infot[0][1][0]
		s[1] = infot[3][1][1]
		s[n - 2] = infot[2][1][0]
		s[n - 1] = infot[1][1][0]
	elif infot[2][1][0] == infot[1][1][0] and infot[3][1][1] == infot[0][1][0]:
		st += infot[2][1]
		rest.append((infot[1][0], 'P'))
		rest.append((infot[0][0], 'S'))
		rest.append((infot[2][0], 'P'))
		rest.append((infot[3][0], 'S'))
		s[0] = infot[1][1][0]
		s[1] = infot[2][1][1]
		s[n - 2] = infot[3][1][0]
		s[n - 1] = infot[0][1][0]
	elif infot[3][1][0] == infot[1][1][0] and infot[2][1][1] == infot[0][1][0]:
		st += infot[3][1]
		rest.append((infot[1][0], 'P'))
		rest.append((infot[0][0], 'S'))
		rest.append((infot[3][0], 'P'))
		rest.append((infot[2][0], 'S'))
		s[0] = infot[1][1][0]
		s[1] = infot[3][1][1]
		s[n - 2] = infot[2][1][0]
		s[n - 1] = infot[0][1][0]
	else:
		print('going to the else')
		st += infot[1][1][0]
		rest.append((infot[0][0], 'P'))
		rest.append((infot[1][0], 'S'))
		s[0] = infot[1][1][0]
		s[1] = infot[3][1][1]
		s[n - 2] = infot[2][1][0]
		s[n - 1] = infot[0][1][0]
	for i in range(2, n - 1):
		if ''.join(s[:i]) == infot[2 * i][1][:i] and ''.join(s[n - i:n]) == infot[2 * i + 1][1][1:]:
			rest.append((infot[2 * i][0], 'P'))
			rest.append((infot[2 * i + 1][0], 'S'))
			st += infot[2 * i][1][i]
			s[i] = infot[2 * i][1][i]
			s[n - i - 1] = infot[2 * i + 1][1][0]
		elif ''.join(s[:i]) == infot[2 * i + 1][1][:i] and ''.join(s[n - i:n]) == infot[2 * i][1][1:]:
			rest.append((infot[2 * i][0], 'S'))
			rest.append((infot[2 * i + 1][0], 'P'))
			st += infot[2 * i + 1][1][i]
			s[i] = infot[2 * i + 1][1][i]
			s[n - i - 1] = infot[2 * i][1][0]
		else:
			print('should not come here')
	rest.sort(key=lambda s: s[0])
	for i in range(2 * n - 2):
		print(rest[i][1], end='', flush=True)


n = int(input())
a = [[] for i in [0] * n]
for i in range(2 * n - 2):
	b = input()
	a[len(b)].append([i, b])
(p, s) = (a[-1][0][-1], a[-1][1][-1])
if p[1:] != s[:-1]:
	(s, p) = (p, s)
b = [0 for _ in [0] * (2 * n - 2)]
for r in a[1:]:
	if r[0][-1] == p[:len(r[0][-1])]:
		b[r[0][0]] = 'P'
		b[r[1][0]] = 'S'
	elif r[1][-1] == p[:len(r[0][-1])]:
		b[r[0][0]] = 'S'
		b[r[1][0]] = 'P'
	else:
		(s, p) = (p, s)
		for r in a[1:]:
			if r[0][-1] == p[:len(r[0][-1])]:
				b[r[0][0]] = 'P'
				b[r[1][0]] = 'S'
			elif r[1][-1] == p[:len(r[0][-1])]:
				b[r[0][0]] = 'S'
				b[r[1][0]] = 'P'
		break
print(''.join(b))


n = int(input())
s = [[] for i in range(n - 1)]
st = []
for i in range(2 * n - 2):
	t = input()
	if len(t) == n - 1:
		st.append([t, i])
	else:
		s[len(t)].append([t, i])
if n == 2:
	print('PS')
	exit()
for v in range(2):
	if v == 0:
		top = st[0][0]
		bot = st[-1][0]
		m1 = st[0][1]
		m2 = st[-1][1]
	else:
		top = st[-1][0]
		bot = st[0][0]
		m1 = st[-1][1]
		m2 = st[0][1]
	ans = ['' for i in range(2 * n - 2)]
	f2 = 0
	ans[m1] = 'P'
	ans[m2] = 'S'
	for i in range(1, n - 1):
		f1 = 0
		for j in range(2):
			if j == 0:
				val1 = s[i][0][0]
				m1 = s[i][0][1]
				val2 = s[i][1][0]
				m2 = s[i][1][1]
				if top[:i] == val1 and bot[n - i - 1:] == val2:
					ans[m1] = 'P'
					ans[m2] = 'S'
					f1 = 1
			else:
				if f1:
					continue
				val1 = s[i][1][0]
				m1 = s[i][1][1]
				val2 = s[i][0][0]
				m2 = s[i][0][1]
				if top[:i] == val1 and bot[n - i - 1:] == val2:
					ans[m1] = 'P'
					ans[m2] = 'S'
				else:
					f2 = 1
	if f2 == 0:
		break
out = ''.join(ans)
print(out)


n = int(input())
string = []
ans = [0] * (2 * n - 2)
for i in range(2 * n - 2):
	string.append([input(), i, 0])
string = sorted(string, key=lambda x: (len(x[0]), x[0]))
(string[2 * n - 4][2], string[2 * n - 3][2]) = (1, 0)
s = string[2 * n - 4][0] + string[2 * n - 3][0][-1:]
flag = False
for i in range(n - 1):
	if string[2 * i][0] == s[:i + 1] and string[2 * i + 1][0] == s[n - i - 1:]:
		string[2 * i][2] = 1
	elif string[2 * i + 1][0] == s[:i + 1] and string[2 * i][0] == s[n - i - 1:]:
		string[2 * i + 1][2] = 1
	else:
		flag = True
		break
if flag:
	for i in range(2 * n - 2):
		string[i][2] = 0
	(string[2 * n - 4][2], string[2 * n - 3][2]) = (0, 1)
	s = string[2 * n - 3][0] + string[2 * n - 4][0][-1:]
	for i in range(n - 1):
		if string[2 * i][0] == s[:i + 1] and string[2 * i + 1][0] == s[n - i - 1:]:
			string[2 * i][2] = 1
		elif string[2 * i + 1][0] == s[:i + 1] and string[2 * i][0] == s[n - i - 1:]:
			string[2 * i + 1][2] = 1
		else:
			assert False
string.sort(key=lambda x: x[1])
for s in string:
	if s[2] == 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]
	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]
		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]))


n = int(input())
strings = [input() for _ in range(2 * n - 2)]
(l1, l2) = (s for s in strings if len(s) == n - 1)

def f(a, b, strings):
	if a[1:] != b[:-1]:
		return
	full = a + b[-1]
	prev = [None] * n
	result = [None] * len(strings)
	for (i, s) in enumerate(strings):
		is_prefix = s == full[:len(s)]
		is_suffix = s == full[-len(s):]
		if is_prefix:
			if is_suffix:
				if prev[len(s)] is None:
					result[i] = 'P'
					prev[len(s)] = 'P'
				elif prev[len(s)] == 'P':
					result[i] = 'S'
				else:
					result[i] = 'P'
			else:
				result[i] = 'P'
				prev[len(s)] = 'P'
		elif is_suffix:
			result[i] = 'S'
			prev[len(s)] = 'S'
		else:
			return
	return result
for (a, b) in [(l1, l2), (l2, l1)]:
	result = f(a, b, strings)
	if result is not None:
		print(''.join(result))
		break


n = int(input())
words = []
for i in range(2 * n - 2):
	temp = input()
	words.append([-len(temp), temp, i])
words.sort()
flag = True
curr = words[0][1]
for i in range(2, len(words), 2):
	if words[i][1] == curr[:n - i // 2 - 1] or words[i + 1][1] == curr[:n - i // 2 - 1]:
		continue
	else:
		flag = False
		break
if flag and words[0][1][1:] == words[1][1][:-1]:
	word = words[0][1] + words[1][1][-1]
	words[0].append('P')
	words[1].append('S')
else:
	word = words[1][1] + words[0][1][-1]
	words[0].append('S')
	words[1].append('P')
for i in range(2, len(words), 2):
	if words[i][1] == word[:n - i // 2 - 1]:
		words[i].append('P')
		words[i + 1].append('S')
	else:
		words[i].append('S')
		words[i + 1].append('P')
answer = ['' for _ in range(2 * n - 2)]
for i in words:
	answer[i[2]] = i[3]
print(''.join(answer))


n = int(input())
a = []
for i in range(2 * n - 2):
	a.append(input())
S = ''
P = ''
Lnm1 = []
Lnm2 = []
ans = []
for i in a:
	if len(i) == n - 1:
		Lnm1.append(i)
	elif len(i) == n - 2:
		Lnm2.append(i)
flag = 0
if n == 2:
	print('PS')
elif n == 1:
	print('P')
else:
	S = Lnm2[0]
	P = Lnm2[1]
	if Lnm2[0] == Lnm1[0][:n - 2] and Lnm2[1] == Lnm1[1][1:]:
		S = Lnm1[0]
		P = Lnm1[1]
	elif Lnm2[1] == Lnm1[0][:n - 2] and Lnm2[0] == Lnm1[1][1:]:
		S = Lnm1[0]
		P = Lnm1[1]
	else:
		S = Lnm1[1]
		P = Lnm1[0]
	flag = [0 for i in range(n)]
	for i in a:
		if flag[len(i)] == 0:
			if len(i) <= len(P):
				if i == S[:len(i)]:
					ans.append('P')
					flag[len(i)] = 'S'
				else:
					ans.append('S')
					flag[len(i)] = 'P'
		else:
			ans.append(flag[len(i)])
	print(*ans, sep='')


n = int(input())
s = [input().strip() for i in range(n + n - 2)]
a = sorted(list(range(n + n - 2)), key=lambda x: len(s[x]))
for _ in range(2):
	(a[-1], a[-2]) = (a[-2], a[-1])
	ans = [0 for i in range(n + n - 2)]
	if s[a[-1]][1:] != s[a[-2]][:-1]:
		continue
	o = s[a[-1]] + s[a[-2]][-1]
	ans[a[-1]] = 'P'
	ans[a[-2]] = 'S'
	tkp = [False for i in range(n)]
	tks = [False for i in range(n)]
	gg = False
	for i in range(n + n - 4):
		l = len(s[a[i]])
		if s[a[i]] == o[:l] and (not tkp[l]):
			tkp[l] = True
			ans[a[i]] = 'P'
			continue
		if s[a[i]] == o[-l:] and (not tks[l]):
			tks[l] = True
			ans[a[i]] = 'S'
			continue
		gg = True
		break
	if gg:
		continue
	print(''.join((x for x in ans)))
	break


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()


import os
import sys
from io import BytesIO, IOBase
import math
from queue import Queue
import collections
import itertools
import bisect
import heapq
import random

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def lis(arr):
	n = len(arr)
	lis = [1] * n
	for i in range(1, n):
		for j in range(0, i):
			if arr[i] > arr[j] and lis[i] < lis[j] + 1:
				lis[i] = lis[j] + 1
	maximum = 0
	for i in range(n):
		maximum = max(maximum, lis[i])
	return maximum

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def maxfac(n):
	root = int(n ** 0.5)
	for i in range(2, root + 1):
		if n % i == 0:
			return n // i
	return n

def p2(n):
	c = 0
	while n % 2 == 0:
		n //= 2
		c += 1
	return c

def seive(n):
	primes = [True] * (n + 1)
	primes[1] = primes[0] = False
	i = 2
	while i * i <= n:
		if primes[i] == True:
			for j in range(i * i, n + 1, i):
				primes[j] = False
		i += 1
	pr = []
	for i in range(0, n + 1):
		if primes[i]:
			pr.append(i)
	return pr

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def denofactinverse(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return pow(fac, m - 2, m)

def numofact(n, m):
	fac = 1
	for i in range(1, n + 1):
		fac = fac * i % m
	return fac

def sod(n):
	s = 0
	while n > 0:
		s += n % 10
		n //= 10
	return s

def sat(s):
	ans = [0] * (2 * n - 2)
	for i in range(0, n - 1):
		(s1, s2) = (l[i * 2][1], l[i * 2 + 1][1])
		if s1 == s[:i + 1] and s2 == s[n - i - 1:]:
			(ind1, ind2) = (l[i * 2][2], l[i * 2 + 1][2])
			(ans[ind1], ans[ind2]) = ('P', 'S')
		elif s2 == s[:i + 1] and s1 == s[n - i - 1:]:
			(ind2, ind1) = (l[i * 2][2], l[i * 2 + 1][2])
			(ans[ind1], ans[ind2]) = ('P', 'S')
		else:
			return -1
	return ans
n = int(input())
l = []
for i in range(0, 2 * n - 2):
	s = input()
	l.append([len(s), s, i])
l.sort()
a1 = l[-2][-2] + l[-1][-2][-1]
a2 = l[-1][-2] + l[-2][-2][-1]
t1 = sat(a1)
t2 = sat(a2)
if t1 != -1:
	print(''.join(t1))
else:
	print(''.join(t2))


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)


try:
	n = int(input())
	a = []
	(pref, suf) = (None, None)
	for i in range(2 * n - 2):
		a.append(input())
		if len(a[-1]) == n - 1:
			if pref is None:
				pref = a[-1]
			else:
				suf = a[-1]
	c = a[:]
	(ppref, ssuf) = (pref, suf)
	s = pref + suf[-1]
	ans = [None] * (2 * n - 2)
	pref = ''
	for i in s:
		pref += i
		if len(pref) == len(s):
			break
		ind = a.index(pref)
		ans[ind] = 'P'
		a[ind] = None
	s = s[::-1]
	pref = ''
	for i in s:
		pref = i + pref
		if len(pref) == len(s):
			break
		ind = a.index(pref)
		ans[ind] = 'S'
		a[ind] = None
	print(''.join(ans))
except Exception as e:
	a = c[:]
	s = ssuf + ppref[-1]
	ans = [None] * (2 * n - 2)
	pref = ''
	for i in s:
		pref += i
		if len(pref) == len(s):
			break
		ind = a.index(pref)
		ans[ind] = 'P'
		a[ind] = None
	s = s[::-1]
	pref = ''
	for i in s:
		pref = i + pref
		if len(pref) == len(s):
			break
		ind = a.index(pref)
		ans[ind] = 'S'
		a[ind] = None
	print(''.join(ans))


n = int(input())
k = 2 * (n - 1)
a = []
c = []
f = []
for j in range(k):
	s = input()
	if len(s) == 1:
		f.append(s)
	if len(s) == n - 1:
		c.append(s)
	a.append(s)
m = f[0]
e = f[1]
r = c[0]
s = c[1]
x = ''
g = ''
if n == 2:
	x = r + s
else:
	q = s[::-1]
	x = r + q[0]
	q = r[::-1]
	g = s + q[0]
	fl = 0
	for j in range(len(a)):
		k = len(a[j])
		if x[:k] == a[j]:
			pass
		elif x[n - k:n] == a[j]:
			pass
		else:
			fl = 1
			break
	if fl == 1:
		x = g
z = ''
b = dict()
for j in range(len(a)):
	b[a[j]] = 0
for j in range(len(a)):
	k = len(a[j])
	if x[:k] == a[j]:
		if b[a[j]] == 1:
			z += 'S'
		else:
			z += 'P'
		b[a[j]] = 1
	else:
		z += 'S'
print(z)


n = int(input())
a = []
d = {}
for _ in range(2 * n - 2):
	a.append(input())
for i in range(len(a)):
	if len(a[i]) in d:
		d[len(a[i])].append(i)
	else:
		d[len(a[i])] = [i]
(x, y) = (a[d[max(d)][0]], a[d[max(d)][1]])
(pref, suff) = (x, y)
if pref[1:] != suff[:-1]:
	(pref, suff) = (y, x)
b = [''] * len(a)
w = ''
flag = 0
flagx = 0
for i in pref:
	w += i
	flag = 0
	for j in range(len(a)):
		if a[j] == w and b[j] == '':
			b[j] = 'P'
			flag = 1
			break
	if flag == 0:
		flagx = 1
		b = [''] * len(a)
		break
if flagx == 1:
	w = ''
	for i in suff:
		w += i
		flag = 0
		for j in range(len(a)):
			if a[j] == w and b[j] == '':
				b[j] = 'P'
				break
for i in range(len(b)):
	if b[i] == '':
		b[i] = 'S'
print(''.join(b))


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()


n = int(input())
p = 2 * n - 2
s = []
save1 = ''
save2 = ''
for i in range(p):
	a = input()
	s.append(a)
	if len(a) == n - 1 and save1 == '':
		save1 = a[:]
	elif len(a) == n - 1:
		save2 = a[:]
first = save1 + save2[n - 2]
sec = save2 + save1[n - 2]
mark = {}
for i in range(1, n):
	mark[i] = 0
cntp = 0
cnts = 0
res = ''
for i in range(p):
	l = len(s[i])
	if first[:l] == s[i] and mark[l] == 0:
		res += 'P'
		cntp += 1
		mark[len(s[i])] = 1
	elif first[n - l:n] == s[i]:
		cnts += 1
		res += 'S'
if cnts == cntp and len(res) == p:
	print(res)
else:
	mark = {}
	for i in range(1, n):
		mark[i] = 0
	cntp = 0
	cnts = 0
	res = ''
	for i in range(p):
		l = len(s[i])
		if sec[:l] == s[i] and mark[l] == 0:
			res += 'P'
			cntp += 1
			mark[l] = 1
		else:
			cnts += 1
			res += 'S'
	print(res)


n = int(input())
s1 = []
k = []
for item in range(2 * n - 2):
	y = input()
	s1.append((len(y), y))
	k.append(y)
s = sorted(s1)
k1 = k[:]
d = s[0][1] + s[2 * n - 3][1]
l = ''
p = 0

def op(a, b):
	l = ''
	p = 1
	d = s[a][1] + s[b][1]
	for item in range(n - 1):
		l += d[item]
		if l not in k:
			return [d, 'NO']
			break
		else:
			k.remove(l)
		if d[-(item + 1):] not in k:
			return [d, 'NO']
			break
		else:
			k.remove(d[-(item + 1):])
	if p == 1:
		return [d, 'YES']
if op(0, 2 * n - 3)[1] == 'NO':
	k = k1[:]
	if op(0, 2 * n - 4)[1] == 'NO':
		k = k1[:]
		if op(1, 2 * n - 3)[1] == 'NO':
			k = k1[:]
			d = op(1, 2 * n - 4)[0]
		else:
			d = op(1, 2 * n - 3)[0]
	else:
		d = op(0, 2 * n - 4)[0]
else:
	d = op(0, 2 * n - 3)[0]
tot = ''
prot = {}
for item in s1:
	if item[1] not in prot:
		u = 0
		for i in range(len(item[1])):
			if item[1][i] != d[i]:
				tot += 'S'
				u = 1
				prot[item[1]] = 'S'
				break
		if u == 0:
			tot += 'P'
			prot[item[1]] = 'P'
	elif prot[item[1]] == 'S':
		tot += 'P'
	else:
		tot += 'S'
print(tot)


def calculate(mainstr, length, subs):
	dowehavepreforthis = [0] * length
	answer = ''
	for var in subs:
		if mainstr[:len(var)] == var and dowehavepreforthis[len(var)] == 0:
			dowehavepreforthis[len(var)] = 1
			answer = answer + 'P'
		else:
			answer = answer + 'S'
	return answer

def solve(subs, length):
	sorted_subs = sorted(subs, key=len)
	lasts = sorted_subs[len(sorted_subs) - 1]
	lastf = sorted_subs[len(sorted_subs) - 2]
	if lastf[1:] == lasts[:-1] and lasts[1:] == lastf[:-1]:
		answer1 = calculate(lastf[0] + lasts[0:], length, subs)
		answer2 = calculate(lasts[0] + lastf[0:], length, subs)
		if answer1.count('S') == answer1.count('P'):
			return answer1
		else:
			return answer2
	elif lastf[1:] == lasts[:-1]:
		return calculate(lastf[0] + lasts[0:], length, subs)
	else:
		return calculate(lasts[0] + lastf[0:], length, subs)
	return 'Error'

def load():
	length = int(input())
	subs = []
	for i in range(2 * length - 2):
		subs.append(input())
	print(solve(subs, length))
load()


def solve(e):
	g = [0 for i in range(2 * n - 2)]
	check = [0 for i in range(2 * n - 2)]
	for i in range(n):
		f = e[0:i + 1]
		for j in range(2 * n - 2):
			if a[j] == f and check[j] == 0:
				g[j] = 1
				check[j] = 1
				break
	for i in range(2 * n - 2):
		if g[i] == 1:
			print('P', end='')
		else:
			print('S', end='')
n = int(input())
a = []
for i in range(2 * n - 2):
	b = input()
	a.append(b)
if n == 2:
	print('PS')
else:
	c = []
	d = []
	for i in range(2 * n - 2):
		if len(a[i]) == 1:
			c.append(a[i])
		elif len(a[i]) == n - 1:
			d.append(a[i])
	e1 = c[0] + d[0]
	b1 = []
	for i in range(len(e1) - 1):
		f = e1[0:i + 1]
		g = e1[i + 1:n]
		b1.append(f)
		b1.append(g)
	e2 = c[0] + d[1]
	b2 = []
	for i in range(len(e2) - 1):
		f = e2[0:i + 1]
		g = e2[i + 1:n]
		b2.append(f)
		b2.append(g)
	e3 = c[1] + d[1]
	b3 = []
	for i in range(len(e3) - 1):
		f = e3[0:i + 1]
		g = e3[i + 1:n]
		b3.append(f)
		b3.append(g)
	e4 = c[1] + d[0]
	b4 = []
	for i in range(len(e4) - 1):
		f = e4[0:i + 1]
		g = e4[i + 1:n]
		b4.append(f)
		b4.append(g)
	e5 = d[0] + c[0]
	b5 = []
	for i in range(len(e5) - 1):
		f = e5[0:i + 1]
		g = e5[i + 1:n]
		b5.append(f)
		b5.append(g)
	e6 = d[0] + c[1]
	b6 = []
	for i in range(len(e6) - 1):
		f = e6[0:i + 1]
		g = e6[i + 1:n]
		b6.append(f)
		b6.append(g)
	e7 = d[1] + c[1]
	b7 = []
	for i in range(len(e7) - 1):
		f = e7[0:i + 1]
		g = e7[i + 1:n]
		b7.append(f)
		b7.append(g)
	e8 = d[1] + c[0]
	b8 = []
	for i in range(len(e8) - 1):
		f = e8[0:i + 1]
		g = e8[i + 1:n]
		b8.append(f)
		b8.append(g)
	c1 = []
	for i in range(2 * n - 2):
		c1.append(a[i])
	c1.sort()
	b1.sort()
	b2.sort()
	b3.sort()
	b4.sort()
	b5.sort()
	b6.sort()
	b7.sort()
	b8.sort()
	if c1 == b1:
		solve(e1)
	elif c1 == b2:
		solve(e2)
	elif c1 == b3:
		solve(e3)
	elif c1 == b4:
		solve(e4)
	elif c1 == b5:
		solve(e5)
	elif c1 == b6:
		solve(e6)
	elif c1 == b7:
		solve(e7)
	else:
		solve(e8)


n = int(input())
sort_entry = []
pos = []
res = []
for i in range(0, 2 * n - 2):
	sort_entry.append(' ')
	res.append(' ')
	pos.append(0)
for i in range(0, 2 * n - 2):
	temp = input()
	l = len(temp)
	if sort_entry[2 * l - 2] == ' ':
		sort_entry[2 * l - 2] = temp
		pos[2 * l - 2] = i
	else:
		sort_entry[2 * l - 1] = temp
		pos[2 * l - 1] = i
word = sort_entry[2 * n - 4] + sort_entry[2 * n - 3][n - 2]
i = 0
while i < 2 * n - 3:
	if sort_entry[i] == word[0:len(sort_entry[i])] and sort_entry[i + 1] == word[n - len(sort_entry[i + 1]):n]:
		res[pos[i]] = 'P'
		res[pos[i + 1]] = 'S'
	elif sort_entry[i + 1] == word[0:len(sort_entry[i + 1])] and sort_entry[i] == word[n - len(sort_entry[i]):n]:
		res[pos[i]] = 'S'
		res[pos[i + 1]] = 'P'
	else:
		i = -2
		word = sort_entry[2 * n - 3] + sort_entry[2 * n - 4][n - 2]
	i = i + 2
result = ''
for i in range(0, 2 * n - 2):
	result = result + res[i]
print(result)


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:
			ans.append('P')
			count[len(mem) - 1] = 1
		else:
			ans.append('S')
else:
	for mem in all_lst:
		if mem == cand_b[:len(mem)] and count[len(mem) - 1] == 0:
			ans.append('P')
			count[len(mem) - 1] = 1
		else:
			ans.append('S')
print(''.join(ans))


n = int(input())
arr = []
a = []

def isAtStart(string, finddata):
	return string[:len(finddata)] == finddata

def isAtEnd(string, finddata):
	return string[len(string) - len(finddata):] == finddata

def f1(el):
	return len(el)

def solvesec(s):
	s = s
	wasS = [False] * n
	wasP = [False] * n
	ans = ''
	for i in range(len(arr)):
		if isAtStart(s, arr[i]) and (not wasS[len(arr[i]) - 1]):
			wasS[len(arr[i]) - 1] = True
			ans += 'P'
		elif isAtEnd(s, arr[i]) and (not wasP[len(arr[i]) - 1]):
			wasP[len(arr[i]) - 1] = True
			ans += 'S'
		else:
			return False
	print(ans)
	return True

def solve():
	for i in range(2 * n - 2):
		arr.append(list(input()))
	a = sorted(arr, key=f1)
	isOkay = solvesec(a[-2] + [a[-1][-1]])
	if not isOkay:
		solvesec(a[-1] + [a[-2][-1]])
solve()


import sys
import bisect
from random import randint
input = lambda : sys.stdin.readline().strip('\r\n')
from math import gcd
sa = lambda : input()
sb = lambda : int(input())
sc = lambda : input().split()
sd = lambda : list(map(int, input().split()))
se = lambda : float(input())
sf = lambda : list(input())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7

def hnbhai():
	n = sb()
	a = [0] * (2 * n - 2)
	d = {}
	for i in range(2 * n - 2):
		s = input()
		if d.get(len(s)) is not None:
			d[len(s)].append([s, i])
		else:
			d[len(s)] = [[s, i]]
	(ans1, ans2) = (d[n - 1][0][0], d[n - 1][1][0])
	l = [d[1][0][0], d[1][1][0]]
	l = l + [d[2][0][0], d[2][1][0]] if n - 1 >= 2 else l
	ans = ''
	if ans1[1:] == ans2[:-1] and ans1[0] in l and (ans1[:2] in l):
		ans = ans1[0] + ans2
	else:
		ans = ans2[0] + ans1
	for i in range(1, n):
		(q1, q2) = (d[i][0], d[i][1])
		if q1[0] == ans[:i]:
			a[q1[1]] = 'P'
			a[q2[1]] = 'S'
		else:
			a[q1[1]] = 'S'
			a[q2[1]] = 'P'
	print(''.join(a))
for _ in range(1):
	hnbhai()


import math
n = int(input())
fixes = []
for i in range(2 * n - 2):
	fixes.append(input())
fixessorted = [[] for i in range(n - 1)]
for i in fixes:
	fixessorted[len(i) - 1].append(i)
prefixes = {}
suffixes = {}
pslist = [0 for i in range(2 * n - 2)]
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):
	if testsuffix[i:] in fixessorted[n - 2 - i]:
		suffixes[testsuffix[i + 1:]] = 1
	else:
		test = 1
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
for i in range(2 * n - 2):
	if fixes[i] in prefixes:
		pslist[i] = 'P'
		del prefixes[fixes[i]]
	else:
		pslist[i] = 'S'
print(''.join(pslist))


from collections import defaultdict, Counter
n = int(input())
k = 2 * n - 2
a = []
for i in range(k):
	a.append([input(), i])
a.sort(key=lambda x: len(x[0]))
ss = [a[0][0] + a[-1][0], a[1][0] + a[-1][0], a[0][0] + a[-2][0], a[1][0] + a[-2][0]]
a.sort(key=lambda x: x[1])
for s in ss:
	ans = []
	d = defaultdict(lambda : False)
	breaker = False
	for j in a:
		i = j[0]
		if s[:len(i)] == i and (not d[i]):
			ans.append('P')
		elif s[len(s) - len(i):len(s)] == i:
			ans.append('S')
		else:
			breaker = True
			break
		d[i] = True
	if breaker:
		continue
	c = Counter(ans)
	if c['P'] == c['S']:
		print(''.join(ans))
		exit()


N = int(input())
sN = [input() for i in range(2 * N - 2)]
ans_s = ''
ans_ps = ''
done = set()

def dfs(s, ps, depth):
	global ans_s
	global ans_ps
	if ans_s != '':
		return
	if depth == len(sN):
		ans_s = s
		ans_ps = ps
		return
	s2 = list(s)
	pref = sN[depth] + '*' * (N - len(sN[depth]))
	ok = True
	for i in range(len(pref)):
		if s[i] != pref[i] and s[i] != '*' and (pref[i] != '*'):
			ok = False
			break
		if s[i] == '*' and pref[i] != '*':
			s2[i] = pref[i]
	if ok and sN[depth] not in done:
		done.add(sN[depth])
		dfs(''.join(s2), ps + 'P', depth + 1)
		if sN[depth] in done:
			done.remove(sN[depth])
	s2 = list(s)
	suff = '*' * (N - len(sN[depth])) + sN[depth]
	ok = True
	for i in range(len(suff)):
		if s[i] != suff[i] and s[i] != '*' and (suff[i] != '*'):
			ok = False
			break
		if s[i] == '*' and suff[i] != '*':
			s2[i] = suff[i]
	if ok:
		done.add(sN[depth])
		dfs(''.join(s2), ps + 'S', depth + 1)
		if sN[depth] in done:
			done.remove(sN[depth])
dfs('*' * N, '', 0)
print(ans_ps)


n = int(input())
ml = -1
s = []
ms = []
mist = []
for i in range(2 * n - 2):
	temp = input()
	s.append(temp)
	if len(temp) == n - 1:
		ms.append(temp)
	if len(temp) <= 2:
		mist.append(temp)
if n == 2:
	pref = ms[0]
	suff = ms[1]
else:
	(a, b) = ms
	if a[1:] == b[:-1] and a[0] in mist and (a[0:2] in mist):
		pref = a
		suff = b
	else:
		pref = b
		suff = a
io = [-1] * 101
last = False
for i in range(2 * n - 2):
	tl = len(s[i])
	f = True
	if io[tl] == 0:
		print('P', end='')
		continue
	elif io[tl] == 1:
		print('S', end='')
		continue
	for j in range(tl):
		if s[i][j] != pref[j]:
			print('S', end='')
			io[tl] = 0
			f = False
			break
	if f:
		print('P', end='')
		io[tl] = 1


n = int(input())
a = []
for i in range(2 * n - 2):
	a.append(input())
b = a[:]
h = [0] * (2 * n - 2)
a.sort(key=len, reverse=True)
x = a[0] + a[1][-1]
y = a[1] + a[0][-1]
for i in range(0, len(a), 2):
	if not (x.startswith(a[i]) and x.endswith(a[i + 1]) or (x.startswith(a[1 + i]) and x.endswith(a[i]))):
		x = y
		break
for i in b:
	if x.startswith(i):
		if h[len(i)] == 1:
			print('S', end='')
		else:
			h[len(i)] = 1
			print('P', end='')
	else:
		print('S', end='')


def solve(c):
	d = ''
	s = set()
	for e in a:
		if c.startswith(e) and len(e) not in s:
			d += 'P'
			s.add(len(e))
		elif c.endswith(e) and -len(e) not in s:
			d += 'S'
			s.add(-len(e))
		else:
			return True
	print(d)
	return False
n = int(input())
(a, b) = ([], [])
for i in range(n + n - 2):
	a.append(input())
	if len(a[-1]) == n - 1:
		b.append(a[-1])
if solve(b[0] + b[1][-1]):
	solve(b[1] + b[0][-1])


n = int(input())
k = 2 * n - 2
a = []
b = []
c = []
for i in range(k):
	s = input()
	a.append(s)
	c.append(s)
a.sort()
for i in range(k):
	if len(a[i]) == n - 1:
		b.append(a[i])
s1 = b[0][1:n - 1]
s2 = b[1][0:n - 2]
if s1 == s2:
	x = b[0][0]
	p = b[0]
	su = b[1]
else:
	x = b[1][0]
	p = b[1]
	su = b[0]
cnt = [1] * n
p1 = 0
res = []
rest = []
for i in range(k):
	l = len(c[i])
	if cnt[l] == 1 and c[i] == p[0:l]:
		cnt[l] = 0
		res.append('P')
		p1 += 1
	else:
		cnt[l] = 1
		res.append('S')
if p1 == n - 1:
	print(''.join(res))
else:
	cnt = [1] * n
	for i in range(k):
		l = len(c[i])
		if cnt[l] == 1 and c[i] == su[0:l]:
			cnt[l] = 0
			rest.append('P')
			p1 += 1
		else:
			cnt[l] = 1
			rest.append('S')
print(''.join(rest))


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))