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
Tags: String algorithms

Starter code:

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


n = int(input())
arr = [[] for _ in range(n)]
t = []
for _ in range(2 * n - 2):
	x = input()
	t.append(x)
	arr[len(x)].append(x)
words = {arr[1][0] + arr[n - 1][0], arr[1][1] + arr[n - 1][0], arr[1][0] + arr[n - 1][1], arr[1][1] + arr[n - 1][1]}
wrong_words = set()
for x in words:
	for i in range(1, n):
		if not (arr[i][0] == x[:i] and arr[i][1] == x[-i:] or (arr[i][1] == x[:i] and arr[i][0] == x[-i:])):
			wrong_words.add(x)
			break
words = words - wrong_words
s = words.pop()
ans = []
check = [[True, True] for _ in range(n)]
for x in t:
	if s[:len(x)] == x and check[len(x)][0]:
		check[len(x)][0] = False
		ans.append('P')
	else:
		ans.append('S')
		check[len(x)][1] = False
print(*ans, sep='')


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, b) = ([], [])
for i in range(2 * n - 2):
	a.append(input())
	if len(a[-1]) == n - 1:
		b.append(a[-1])
(var1, var2) = (b[0] + b[1][-1], b[1] + b[0][-1])
(t, ans, ks, kp) = ([], '', 0, 0)
for s in a:
	if s not in t and var1.endswith(s):
		ans += 'S'
		ks += 1
		t.append(s)
	else:
		ans += 'P'
		kp += 1
if ks == kp:
	print(ans)
else:
	(t, ans) = ([], '')
	for s in a:
		if s not in t and var2.endswith(s):
			ans += 'S'
			t.append(s)
		else:
			ans += 'P'
	print(ans)


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


n = int(input())
(l, w, s) = ([], [], [])
for i in range(2 * n - 2):
	tmp = input()
	l.append(tmp)
	if len(tmp) == n - 1:
		w.append(tmp)
	if len(tmp) <= 2:
		s.append(tmp)
if w[0][:-1] == w[1][1:] and w[1][0] in s and (w[1][:2] in s):
	string = w[1][0] + w[0]
else:
	string = w[0][0] + w[1]
d = []
for i in l:
	if string.startswith(i) and (not len(i) in d):
		print('P', end='')
		d += [len(i)]
	else:
		print('S', end='')


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


n = int(input())
m = 2 * n - 2
arr = []
for i in range(m):
	s = input()
	arr.append(s)
prefix = ''
suffix = ''
s = ''
ans = [0] * m
for i in range(m):
	if len(arr[i]) == n - 1 and len(prefix) != n - 1:
		prefix = arr[i]
		ans[i] = 1
	elif len(arr[i]) == n - 1:
		suffix = arr[i]
countp = 1
for i in range(1, n - 1):
	for j in range(m):
		if len(arr[j]) == i and prefix[:i] == arr[j]:
			countp += 1
			ans[j] = 1
			break
if countp * 2 == m and prefix[1:] == suffix[:-1]:
	for i in range(m):
		if ans[i] == 0:
			s += 'S'
		else:
			s += 'P'
else:
	ans = [0] * m
	suffix = prefix
	counts = 0
	for i in range(1, n):
		for j in range(m):
			if len(arr[j]) == i and suffix[-i:] == arr[j]:
				counts += 1
				ans[j] = 1
				break
	if counts * 2 == m:
		for i in range(m):
			if ans[i] == 1:
				s += 'S'
			else:
				s += 'P'
	else:
		s = 'hello'
print(s)


n = int(input())
l = [input() for i in range(2 * n - 2)]
m = [i + j for i in l for j in l if len(i + j) == n]
for j in set(m):
	p = [j[:i] for i in range(1, n)]
	s = [j[i:] for i in range(1, n)]
	if set(p + s) == set(l):
		for i in l:
			if i in p:
				print('P', end='')
				p.remove(i)
			else:
				print('S', end='')
				s.remove(i)
		exit()


def solve(n, b):
	result = [''] * len(b)
	s = [x[0] for x in b]
	if s[-1][1:] == s[-2][:-1]:
		raw = s[-1] + s[-2][-1]
		for i in range(n - 1):
			if raw[:i + 1] not in s or raw[n - 1 - i:] not in s:
				flag = False
				raw = s[-2] + s[-1][-1]
				break
	else:
		raw = s[-2] + s[-1][-1]
	pros = [raw[:i + 1] for i in range(n - 1)]
	sufs = [raw[n - 1 - i:] for i in range(n - 1)]
	for i in range(0, 2 * n - 2, 2):
		if b[i][0] in pros and b[i + 1][0] in sufs:
			result[b[i][1]] = 'P'
			result[b[i + 1][1]] = 'S'
		else:
			result[b[i][1]] = 'S'
			result[b[i + 1][1]] = 'P'
	return ''.join(result)
n = int(input())
x = 2 * n - 2
s = list()
while x > 0:
	s.append(input())
	x -= 1
b = [(s[i], i) for i in range(len(s))]
b.sort(key=lambda x: len(x[0]))
print(solve(n, b))


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


from sys import stdin

def check(final, string_set):
	mydict = create_map(final)
	string = []
	for i in string_set:
		string.append(mydict[i])
		if mydict[i] == 'P':
			mydict[i] = 'S'
		else:
			mydict[i] = 'P'
	return string

def get_string(store_small, store_big, string_set):
	temp = store_big[0] + store_small[0]
	aux = []
	if temp[1:] == store_big[1]:
		aux.append(temp)
	temp = store_small[0] + store_big[0]
	if temp[:len(temp) - 1] == store_big[1]:
		aux.append(temp)
	temp = store_big[0] + store_small[1]
	if temp[1:] == store_big[1]:
		aux.append(temp)
	temp = store_small[1] + store_big[0]
	if temp[:len(temp) - 1] == store_big[1]:
		aux.append(temp)
	if len(aux) == 1:
		string = check(aux[0], string_set)
		for i in string:
			print(i, end='')
	else:
		try:
			string = check(aux[0], string_set)
			for i in string:
				print(i, end='')
		except:
			string = check(aux[1], string_set)
			for i in string:
				print(i, end='')

def create_map(final):
	mydict = dict()
	for i in range(1, len(final)):
		mydict[final[:i]] = 'P'
	for i in range(1, len(final)):
		mydict[final[i:]] = 'S'
	return mydict
n = int(stdin.readline().strip())
store_big = []
store_small = []
string_set = []
for i in range(2 * n - 2):
	temp = stdin.readline().strip()
	if len(temp) == n - 1:
		store_big.append(temp)
	elif len(temp) == 1:
		store_small.append(temp)
	string_set.append(temp)
if n - 1 == 1:
	store_small = store_big[:]
get_string(store_small, store_big, string_set)


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


def check(string):
	global listps
	listpr = []
	listsu = []
	checker = checkin = 0
	for i in range(1, len(string)):
		listpr.append(string[0:i])
	for i in range(1, len(string)):
		listsu.append(string[i:len(string)])
	for (i, j) in zip(listsu, listpr):
		if i in listps and j in listps:
			checker += 1
	for i in listps:
		if i in listsu or (i in listpr and checker == max(len(listsu), len(listpr))):
			checkin += 1
	if checkin == len(listps):
		return True
	return False
ans = ''
n = int(input())
listps = []
for i in range(2 * n - 2):
	listps.append(input())
listlen = []
listmaxi = []
listmini = []
listset = list(set(listps))
listset.reverse()
string = ''
for i in listset:
	listlen.append(len(i))
for i in listset:
	if len(i) == max(listlen):
		listmaxi.append(i)
	if len(i) == min(listlen):
		listmini.append(i)
for i in listmini:
	for j in listmaxi:
		if check(i + j):
			string = i + j
		elif check(j + i):
			string = j + i
checklist = []
for i in range(len(listps)):
	for j in range(len(string) + 1):
		listt = listps[:]
		if listps[i] == string[0:j] and [listps[i], 'P'] not in checklist:
			ans += 'P'
			checklist.append([listps[i], 'P'])
			break
		elif listps[i] == string[j:len(string)] and [listps[i], 'S'] not in checklist:
			ans += 'S'
			checklist.append([listps[i], 'S'])
			break
print(ans)


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())
s = []
t = []
ans1 = ''
vis1 = []
vis2 = []
ans2 = ''
for i in range(2 * n - 2):
	s1 = input()
	t.append(s1)
	if len(s1) == n - 1:
		s.append(s1)
m = s[1] + s[0][-1]
q = s[0] + s[1][-1]
for i in t:
	if i not in vis1 and m.endswith(i):
		ans1 += 'S'
		vis1.append(i)
	else:
		ans1 += 'P'
if ans1.count('P') == ans1.count('S'):
	print(ans1)
else:
	for i in t:
		if i not in vis2 and q.endswith(i):
			ans2 += 'S'
			vis2.append(i)
		else:
			ans2 += 'P'
	print(ans2)


n = int(input())
m = [input() for _ in range(2 * n - 2)]
c1 = max(m, key=len)
j = m.index(c1)
c2 = m[[i for i in range(2 * n - 2) if len(m[i]) == len(c1) and i != j][0]]
cand = [c1[:n - len(c2)] + c2, c2[:n - len(c1)] + c1]
sol = ['', '']
chk = [{}, {}]
for i in m:
	for j in range(2):
		if sol[j] != '-1':
			if cand[j].startswith(i) and cand[j].endswith(i):
				if len(i) not in chk[j]:
					sol[j] += 'S'
					chk[j][len(i)] = 1
				else:
					sol[j] += 'P'
			elif cand[j].startswith(i):
				sol[j] += 'P'
			elif cand[j].endswith(i):
				sol[j] += 'S'
			else:
				sol[j] = '-1'
for i in range(2):
	if len(sol[i]) == 2 * n - 2 and sol[i].count('S') == sol[i].count('P'):
		print(sol[i])
		break


n = int(input())
list1 = []
for i in range(0, 2 * n - 2):
	str = input()
	list1.append(str)
condition = False
condition1 = False
first = 'a'
first1 = 'a'
second = 'a'
second1 = 'a'
k = 0
u = 0
for i in range(0, 2 * n - 2):
	if len(list1[i]) == 1 and condition == False:
		first = list1[i]
		k = i
		condition = True
	elif len(list1[i]) == 1 and condition == True:
		first1 = list1[i]
	if len(list1[i]) == n - 1 and condition1 == False:
		second = list1[i]
		u = i
		condition1 = True
	elif len(list1[i]) == n - 1 and condition1 == True:
		second1 = list1[i]
Word = []
Word.append(first + second)
Word.append(second + first)
Word.append(first1 + second)
Word.append(second + first1)
Word.append(first + second1)
Word.append(first1 + second1)
Word.append(second1 + first)
Word.append(second1 + first1)
count = 0
finalWord = 'a'
for i in range(0, 8):
	count = 0
	for j in range(0, 2 * n - 2):
		if Word[i].find(list1[j]) == 0 or Word[i].rfind(list1[j]) == n - len(list1[j]):
			count += 1
		else:
			break
	if count == 2 * n - 2 and len(Word[i]) == n:
		finalWord = Word[i]
		break
for i in range(0, 2 * n - 2):
	if finalWord.find(list1[i]) == 0:
		found = False
		for j in range(0, i):
			if list1[i] == list1[j]:
				found = True
		if found == True:
			print('S', end='')
		else:
			print('P', end='')
	else:
		print('S', end='')


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


import sys
import collections as cc
I = lambda : list(map(int, input().split()))
(n,) = I()
ar = []
f = cc.defaultdict(list)
ans = cc.defaultdict(str)
for i in range(2 * n - 2):
	ar.append(input())
	f[len(ar[-1])].append(ar[-1])
	ans[ar[-1]] = ''
(a, b) = f[n - 1]
(c, d) = f[1]
tot = [a + c, a + d, c + a, d + a, b + c, b + d, c + b, d + b]
for i in tot:
	now = i
	tf = 1
	for i in range(1, n):
		temp = {now[:i], now[-i:]}
		if temp != set(f[i]):
			tf = 0
			break
	if tf:
		for i in range(1, n):
			x = now[:i]
			y = now[-i:]
			ans[x] = 'P'
			ans[y] = 'S'
		break
visi = cc.defaultdict(int)
for i in ar:
	if not visi[i]:
		print(ans[i], end='')
		visi[i] = 1
	else:
		print('P', end='')


t = int(input())
n = 2 * t - 2
palas = [(input().strip(), i) for i in range(n)]
res = ['x' for _ in range(n)]
s = ''
p = ''
for ta in palas:
	w = ta[0]
	if len(w) > len(s):
		s = w
	elif len(w) == len(s):
		p = w
sopas = sorted(palas, key=lambda x: len(x[0]))
for wa in range(0, len(sopas), 2):
	u = sopas[wa][0]
	o = sopas[wa + 1][0]
	if not s.endswith(u) and (not s.endswith(o)):
		(s, p) = (p, s)
		break
	elif not p.startswith(u) and (not p.startswith(o)):
		(s, p) = (p, s)
		break
if p[1:] != s[:-1]:
	(s, p) = (p, s)
for wa in range(0, len(sopas), 2):
	u = sopas[wa][0]
	o = sopas[wa + 1][0]
	if p.startswith(u) and s.endswith(o):
		res[sopas[wa][1]] = 'P'
		res[sopas[wa + 1][1]] = 'S'
	else:
		res[sopas[wa][1]] = 'S'
		res[sopas[wa + 1][1]] = 'P'
print(''.join(res))


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())
max_str = []
all_str = []
min_str = []
for i in range(2 * n - 2):
	a = input()
	if len(a) == n - 1:
		max_str.append(a)
	all_str.append(a)
	if len(a) <= 2:
		min_str.append(a)
(a, b) = max_str
string = ''
if a[:-1] == b[1:] and b[0] in min_str and (b[0:2] in min_str):
	string = b[0] + a
else:
	string = a[0] + b
d = {}
for i in all_str:
	if string.startswith(i) and (not len(i) in d):
		print('P', end='')
		d[len(i)] = 0
	else:
		print('S', 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))


n = int(input())
a = []
b = []
for i in range(2 * n - 2):
	f = input()
	b.append([len(f), [f, i]])
	a.append([len(f), f])
a.sort()
b.sort()
for i in range(len(a)):
	a[i] = a[i][1]
	b[i] = b[i][1]
s = ''
x = [''] * (2 * n - 2)
k = 1
if a[-2][:-1] != a[-1][1:]:
	s = a[-2][0] + a[-1]
elif a[-1][:-1] != a[-2][1:]:
	s = a[-1][0] + a[-2]
else:
	s = a[-1][0] + a[-2]
	k = 0
	for i in range(1, 2 * n - 2, 2):
		if a[i] == s[:len(a[i])] and a[i - 1] == s[-len(a[i]):]:
			x[b[i][1]] = 'P'
			x[b[i - 1][1]] = 'S'
		elif a[i - 1] == s[:len(a[i])] and a[i] == s[-len(a[i]):]:
			x[b[i - 1][1]] = 'P'
			x[b[i][1]] = 'S'
		else:
			k = 1
			s = a[-2][0] + a[-1]
			x = [''] * (2 * n - 2)
if k == 1:
	for i in range(1, 2 * n - 2, 2):
		if a[i] == s[:len(a[i])] and a[i - 1] == s[-len(a[i]):]:
			x[b[i][1]] = 'P'
			x[b[i - 1][1]] = 'S'
		elif a[i - 1] == s[:len(a[i])] and a[i] == s[-len(a[i]):]:
			x[b[i - 1][1]] = 'P'
			x[b[i][1]] = 'S'
print(*x, sep='')


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())
a = [None] * (2 * n - 2)
ans = [None] * (2 * n - 2)
mp = [[0] * 2 for i in range(2 * n - 2)]
for i in range(2 * n - 2):
	a[i] = input()
	mp[i] = [len(a[i]), i]
if n == 2:
	print('SP')
	exit()
mp.sort()
sx = None
px = None
if a[mp[0][1]] == a[mp[2][1]][0] and a[mp[1][1]] == a[mp[3][1]][1] or (a[mp[0][1]] == a[mp[3][1]][0] and a[mp[1][1]] == a[mp[2][1]][1]):
	sx = a[mp[1][1]]
	px = a[mp[0][1]]
	ans[mp[1][1]] = 'S'
	ans[mp[0][1]] = 'P'
else:
	px = a[mp[1][1]]
	sx = a[mp[0][1]]
	ans[mp[1][1]] = 'P'
	ans[mp[0][1]] = 'S'
for i in range(2, 2 * n - 2, 2):
	if sx == a[mp[i][1]][1:] and px == a[mp[i + 1][1]][:-1]:
		sx = a[mp[i][1]]
		px = a[mp[i + 1][1]]
		ans[mp[i][1]] = 'S'
		ans[mp[i + 1][1]] = 'P'
	else:
		sx = a[mp[i + 1][1]]
		px = a[mp[i][1]]
		ans[mp[i + 1][1]] = 'S'
		ans[mp[i][1]] = 'P'
print(''.join(ans))


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())
ps = []
s = []
for i in range(2 * n - 2):
	ss = input()
	if len(ss) == 1:
		s.append(ss)
	ps.append(ss)
c1 = 0
c2 = 0
c3 = 0
c4 = 0
pre = []
suf = []
for i in range(2 * n - 2):
	if ps[i][0] == s[0]:
		c1 += 1
	if ps[i][0] == s[1]:
		c2 += 1
	if ps[i][-1] == s[0]:
		c3 += 1
	if ps[i][-1] == s[1]:
		c4 += 1
if c1 > c2:
	pre.append(s[0])
	suf.append(s[1])
elif c1 == c2:
	if c3 >= c4:
		pre.append(s[1])
		suf.append(s[0])
	else:
		pre.append(s[0])
		suf.append(s[1])
else:
	pre.append(s[1])
	suf.append(s[0])
d = dict()
for k in ps:
	if len(k) not in d:
		d[len(k)] = []
	d[len(k)].append(k)
for i in range(2, n):
	prec = []
	if d[i][0][:-1] == pre[-1]:
		prec.append(d[i][0])
	if d[i][1][:-1] == pre[-1]:
		prec.append(d[i][1])
	sufc = []
	if d[i][0][1:] == suf[-1]:
		sufc.append(d[i][0])
	if d[i][1][1:] == suf[-1]:
		sufc.append(d[i][1])
	if len(prec) == 1 and len(sufc) == 1:
		pre.append(prec[0])
		suf.append(sufc[0])
	elif len(prec) == 1 and len(sufc) == 2:
		pre.append(prec[0])
		if sufc[0] not in prec:
			suf.append(sufc[0])
		else:
			suf.append(sufc[1])
	elif len(prec) == 2 and len(sufc) == 1:
		suf.append(sufc[0])
		if prec[0] not in sufc:
			pre.append(prec[0])
		else:
			pre.append(prec[1])
	else:
		pre.append(prec[0])
		suf.append(prec[1])
ans = dict()
for k in ps:
	ans[k] = []
for k in pre:
	ans[k].append('P')
for k in suf:
	ans[k].append('S')
fans = ''
for k in ps:
	fans = fans + ans[k][-1]
	ans[k].pop()
print(fans)


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())
m = 2 * n - 2
r = [0] * m
a = [input() for _ in r]
v = [()] * n
for i in range(m):
	v[len(a[i])] += (i,)
(i, j) = v[-1]
(k, l) = v[1 - min(3, n)]
if a[i][1:] != a[j][:-1] or a[k] != a[i][:-1] != a[l]:
	i = j
for l in range(1, n):
	(j, k) = v[l]
	(r[j], r[k]) = ('SP', 'PS')[a[j] == a[i][:l]]
print(''.join(r))


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())
l = [input() for i in range(2 * n - 2)]
m = [i + j for i in l for j in l if len(i + j) == n]
for j in set(m):
	p = [j[:i] for i in range(1, n)]
	s = [j[i:] for i in range(1, n)]
	if set(p + s) == set(l):
		a = j
		break
for i in l:
	if i in p:
		print('P', end='')
		p.remove(i)
	elif i in s:
		print('S', end='')
		s.remove(i)


n = int(input())
a = []
b = []
s1 = ''
s2 = ''
a1 = ''
a2 = ''
for i in range(2 * n - 2):
	s = input()
	b.append(s)
	a.append((len(s), s))
	if len(s) == n - 1:
		if s1 == '':
			s1 = s
		elif s2 == '':
			s2 = s
	if len(s) == 1:
		if a1 == '':
			a1 = s
		elif a2 == '':
			a2 = s
string = ''
string = s1[0] + s2
a.sort()
x = 1
for i in range(0, 2 * n - 2, 2):
	if (string[:x] != a[i][1] or string[-x:] != a[i + 1][1]) and (string[:x] != a[i + 1][1] or string[-x:] != a[i][1]):
		string = s2[0] + s1
		break
	x += 1
suf = [str(string[i:]) for i in range(n)]
pref = [str(string[:i + 1]) for i in range(n)]
l = [1 for i in range(n - 1)]
for cur in b:
	if cur in suf and l[len(cur) - 1] > 0:
		print('S', end='')
		l[len(cur) - 1] -= 1
	else:
		print('P', end='')


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 1119 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def ok(s):
	ans = ['?'] * (2 * n - 2)
	for i in range(1, n):
		pref = s[:i]
		suff = s[::-1][:i][::-1]
		if sorted([pref, suff]) != sorted([a[i][0][0], a[i][1][0]]):
			return False
		if pref == a[i][0][0]:
			ans[a[i][0][1]] = 'P'
			ans[a[i][1][1]] = 'S'
		else:
			ans[a[i][0][1]] = 'S'
			ans[a[i][1][1]] = 'P'
	return ''.join(ans)
n = Int()
a = defaultdict(list)
for i in range(2 * n - 2):
	s = input()
	a[len(s)].append((s, i))
s1 = a[n - 1][0][0] + a[1][0][0]
s2 = a[n - 1][1][0] + a[1][0][0]
s3 = a[n - 1][0][0] + a[1][1][0]
s4 = a[n - 1][1][0] + a[1][1][0]
if ok(s1):
	print(ok(s1))
elif ok(s2):
	print(ok(s2))
elif ok(s3):
	print(ok(s3))
elif ok(s4):
	print(ok(s4))
else:
	print('failed')


def is_suffix(par, child):
	l = len(child)
	if par[n - l - 1:] == child:
		return 1
	return 0

def is_prefix(par, child):
	l = len(child)
	if par[:l] == child:
		return 1
	return 0

def make(pri_par, sec_par, f, s):
	ans = [0 for i in range(2 * n - 2)]
	ans[f] = 'P'
	ans[s] = 'S'
	for i in range(2, 2 * n - 2, 2):
		if is_prefix(pri_par, arr[i][1]) and is_suffix(sec_par, arr[i + 1][1]):
			ans[arr[i][2]] = 'P'
			ans[arr[i + 1][2]] = 'S'
			continue
		if is_prefix(pri_par, arr[i + 1][1]) and is_suffix(sec_par, arr[i][1]):
			ans[arr[i][2]] = 'S'
			ans[arr[i + 1][2]] = 'P'
	return ans
for _ in range(1):
	n = int(input())
	arr = []
	for i in range(2 * n - 2):
		rt = input()
		arr.append([len(rt), rt, i])
	arr.sort(reverse=True)
	a = make(arr[1][1], arr[0][1], arr[1][2], arr[0][2])
	if a.count(0) == 0 and a.count('S') == a.count('P'):
		for i in a:
			print(i, end='')
		continue
	b = make(arr[0][1], arr[1][1], arr[0][2], arr[1][2])
	for i in b:
		print(i, end='')


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)


for _ in range(1):
	n = int(input())
	limit = 2 * n - 2
	ind = {}
	e = {}
	d = {}
	for i in range(1, limit + 1):
		s = input()
		if len(s) in d:
			d[len(s)].append(s)
		else:
			d[len(s)] = [s]
		if s in ind:
			ind[s].append(i)
		else:
			ind[s] = [i]
		if s in e:
			e[s] += 1
		else:
			e[s] = 1
	candidates = [d[n - 1][0] + d[1][0], d[n - 1][0] + d[1][1], d[n - 1][1] + d[1][0], d[n - 1][1] + d[1][1], d[1][0] + d[n - 1][0], d[1][1] + d[n - 1][0], d[1][0] + d[n - 1][1], d[1][1] + d[n - 1][1]]
	for i in candidates:
		te = {}
		tind = {}
		for j in e:
			te[j] = e[j]
		for j in ind:
			tind[j] = ind[j].copy()
		flag = 1
		ans = ['Z'] * (limit + 1)
		for j in range(n - 1):
			w = i[0:j + 1]
			if w not in tind:
				flag = 0
				break
			if len(tind[w]) == 0:
				flag = 0
				break
			ans[tind[w].pop()] = 'P'
			if w in te:
				te[w] -= 1
				if te[w] == 0:
					del te[w]
			else:
				flag = 0
				break
		i = i[::-1]
		for j in range(n - 1):
			w = i[0:j + 1][::-1]
			if w not in tind:
				flag = 0
				break
			if len(tind[w]) == 0:
				flag = 0
				break
			ans[tind[w].pop()] = 'S'
			if w in te:
				te[w] -= 1
				if te[w] == 0:
					del te[w]
			else:
				flag = 0
				break
		if flag:
			print(''.join(ans[1:]))
			exit()


gi = lambda : list(map(int, input().split()))
(n,) = gi()
l = [input() for e in range(2 * n - 2)]
if n == 2:
	print('SP')
	exit()
ans = {(l[k], k): [k, 'S'] for k in range(2 * n - 2)}
l = [(len(e), e) for e in l]
l.sort(reverse=True)
l = [e[1] for e in l]
P = set()
s = ''
s = l[0] + l[1][-1]
P.add(l[0])
L = l[:]
l = l[2:]
rep = 0
while l:
	if s[:len(l[0])] == l[0] and s[-1:-len(l[0]) - 1:-1] == l[1][::-1]:
		P.add(l[0])
	elif s[:len(l[0])] == l[1] and s[-1:-len(l[0]) - 1:-1] == l[0][::-1]:
		P.add(l[1])
	else:
		rep = 1
		break
	l = l[2:]
if rep:
	l = L[:]
	s = l[1] + l[0][-1]
	P = set()
	P.add(l[1])
	l = l[2:]
	while l:
		if s[:len(l[0])] == l[0]:
			P.add(l[0])
		elif s[:len(l[0])] == l[1]:
			P.add(l[1])
		l = l[2:]
for e in ans:
	if e[0] in P:
		ans[e][1] = 'P'
		P.remove(e[0])
rez = []
for e in ans:
	rez.append(ans[e])
rez.sort()
print(''.join([e[1] for e in rez]))


n = int(input())
strs = []
for i in range(2 * n - 2):
	strs.append(input())
strd = sorted(strs, key=len, reverse=True)
poss1 = strd[0] + strd[1][-1]
poss2 = strd[1] + strd[0][-1]
real = poss1
for guy in strd:
	a = len(guy)
	if guy != poss1[:a] and guy != poss1[-a:]:
		real = poss2
		break
	if guy != poss2[:a] and guy != poss2[-a:]:
		break
out = ''
for guy in strs:
	a = len(guy)
	(x, y) = (guy == real[:a], guy == real[-a:])
	if x:
		if y:
			out += 'B'
		else:
			out += 'P'
	else:
		out += 'S'
stuff = [0] * (n - 1)
for i in range(2 * n - 2):
	if out[i] == 'B':
		stuff[len(strs[i]) - 1] += 10
	elif out[i] == 'P':
		stuff[len(strs[i]) - 1] += 1
	else:
		stuff[len(strs[i]) - 1] -= 1
for i in range(2 * n - 2):
	if out[i] == 'B':
		if stuff[len(strs[i]) - 1] == 9:
			out = out[:i] + 'P' + out[i + 1:]
		else:
			out = out[:i] + 'S' + out[i + 1:]
			stuff[len(strs[i]) - 1] -= 11
print(out)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
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')
n = int(input())
(l, w, s) = ([], [], [])
for i in range(2 * n - 2):
	tmp = input()
	l.append(tmp)
	if len(tmp) == n - 1:
		w.append(tmp)
	if len(tmp) <= 2:
		s.append(tmp)
if w[0][:-1] == w[1][1:] and w[1][0] in s and (w[1][:2] in s):
	string = w[1][0] + w[0]
else:
	string = w[0][0] + w[1]
d = []
for i in l:
	if string.startswith(i) and (not len(i) in d):
		print('P', end='')
		d += [len(i)]
	else:
		print('S', end='')


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())
b = [i for i in a if len(i) == n - 1]
c = b[0]
d = b[1]
word1 = c + d[-1]
word2 = d + c[-1]
s = 0
p = 0
r = ''
q = ''
n1 = []
n2 = []
for i in a:
	if i not in n1 and word1.endswith(i):
		q += 'S'
		s += 1
		n1.append(i)
	else:
		q += 'P'
		p += 1
if p != s:
	for i in a:
		if i not in n2 and word2.endswith(i):
			r += 'S'
			n2.append(i)
		else:
			r += 'P'
	print(r)
else:
	print(q)


n = int(input())
one_a = ''
one_b = ''
n_minus_one = ''
l = []
for i in range(2 * n - 2):
	l.append(input())
	if len(l[-1]) == 1:
		if one_a == '':
			one_a = l[-1]
		else:
			one_b = l[-1]
	elif len(l[-1]) == n - 1:
		n_minus_one = l[-1]

def good(s):
	check = []
	for i in range(1, n):
		check.append(s[:i])
		check.append(s[i:])
	return sorted(check) == sorted(l)
s = ''
if good(one_a + n_minus_one):
	s = one_a + n_minus_one
elif good(n_minus_one + one_a):
	s = n_minus_one + one_a
elif good(one_b + n_minus_one):
	s = one_b + n_minus_one
else:
	s = n_minus_one + one_b
ans = []
taken = [False for _ in range(n)]
for string in l:
	length = len(string)
	if s[:length] == string and (not taken[length]):
		ans.append('P')
		taken[length] = True
	else:
		ans.append('S')
[print(c, end='') for c in ans]


n = int(input())
k = []
sry = True
s = 0
p = 0
b = 0
for i in range(n * 2 - 2):
	presuf = input()
	k.append([presuf, len(presuf), i, ''])
k.sort(key=lambda x: x[1], reverse=True)
temp1 = ['' for i in range(n)]
temp2 = ['' for i in range(n)]
for t in k:
	if temp1[0] == '':
		for o in range(t[1]):
			temp1[o] = t[0][o]
		t[3] = 'P'
	elif list(t[0]) == temp1[:t[1]]:
		if temp1[-1] == '':
			t[3] = 'L'
		elif list(t[0]) == temp1[n - t[1]:]:
			t[3] = 'B'
		else:
			t[3] = 'P'
	elif temp1[-1] == '':
		for o in range(n - t[1], n):
			if temp1[o] not in (t[0][o - (n - t[1])], ''):
				sry = False
				break
		for o in range(n - t[1], n):
			temp1[o] = t[0][o - (n - t[1])]
		t[3] = 'S'
	elif list(t[0]) != temp1[n - t[1]:]:
		sry = False
		break
	else:
		t[3] = 'S'
if sry:
	for item in k:
		if item[3] == 'S':
			s += 1
		elif item[3] == 'P':
			p += 1
		elif item[3] == 'B':
			b += 1
		else:
			check = True
			for o in range(n - item[1], n):
				if temp1[o] not in (item[0][o - (n - item[1])], ''):
					check = False
					break
			if check:
				item[3] = 'B'
				b += 1
			else:
				p += 1
				item[3] = 'P'
	if max(s, p) - min(s, p) > b:
		sry = False
	else:
		to = 'P' if min(s, p) == p else 'S'
		num = max(s, p) - min(s, p)
		change = False
		for item in k:
			if item[3] == 'B':
				if num != 0:
					item[3] = to
					num -= 1
				else:
					item[3] = 'P' if change else 'S'
					change = True if not change else False
if not sry:
	for t in k:
		if temp2[-1] == '':
			for o in range(n - t[1], n):
				temp2[o] = t[0][o - (n - t[1])]
			t[3] = 'S'
		elif list(t[0]) == temp2[n - t[1]:]:
			if temp2[0] == '':
				t[3] = 'L'
			elif list(t[0]) == temp2[:t[1]]:
				t[3] = 'B'
			else:
				t[3] = 'S'
		else:
			if temp2[0] == '':
				for o in range(t[1]):
					temp2[o] = t[0][o]
			t[3] = 'P'
s = 0
p = 0
b = 0
if not sry:
	for item in k:
		if item[3] == 'S':
			s += 1
		elif item[3] == 'P':
			p += 1
		elif item[3] == 'B':
			b += 1
		else:
			check = True
			for o in range(item[1]):
				if temp2[o] not in (item[0][o], ''):
					check = False
					break
			if check:
				item[3] = 'B'
				b += 1
			else:
				p += 1
				item[3] = 'S'
	to = 'P' if min(s, p) == p else 'S'
	num = max(s, p) - min(s, p)
	change = False
	for item in k:
		if item[3] == 'B':
			if num != 0:
				item[3] = to
				num -= 1
			else:
				item[3] = 'P' if change else 'S'
				change = True if not change else False
k.sort(key=lambda x: x[2])
[print(l[3], end='') for l in k]


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)


import sys
n = int(sys.stdin.readline())
PS = []
main = []
posByLen = [[] for i in range(n - 1)]
for i in range(2 * (n - 1)):
	PS.append(sys.stdin.readline().strip())
	posByLen[len(PS[-1]) - 1].append(i)
	if len(PS[-1]) == n - 1:
		main.append(PS[-1])
maybeHide = []
ans = ['S' for i in range(len(PS))]
if main[1].find(main[0][:-1]) == 1 or main[1].find(main[0][:-1]) == 0:
	maybeHide.append(main[1][0] + main[0])
if main[0].find(main[1][:-1]) == 1 or main[0].find(main[1][:-1]) == 0:
	maybeHide.append(main[0][0] + main[1])

def PorS(subS, s):
	ps = 'S'
	found = s.find(subS)
	if found == 0:
		ps = 'P'
	return ps

def isS(subS, s):
	S = False
	if s.rfind(subS) == len(s) - len(subS):
		S = True
	return S

def isP(subS, s):
	P = False
	if s.find(subS) == 0:
		P = True
	return P
l = len(posByLen)
for hided in maybeHide:
	end = True
	for i in range(l):
		if isP(PS[posByLen[i][0]], hided) and isS(PS[posByLen[i][1]], hided):
			ans[posByLen[i][0]] = 'P'
			ans[posByLen[i][1]] = 'S'
		elif isP(PS[posByLen[i][1]], hided) and isS(PS[posByLen[i][0]], hided):
			ans[posByLen[i][1]] = 'P'
			ans[posByLen[i][0]] = 'S'
		else:
			end = False
			break
	if end:
		break
for i in range(len(ans)):
	print(ans[i], end='')


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 = eval(input())
mother = ''
arr = {}
allstr = []
sj = []
flag = 0
ans = ''
for i in range(2 * n - 2):
	tmp = input()
	arr[tmp] = 0
	allstr.append(tmp)
	if len(tmp) == n - 1:
		sj.append(tmp)
if n == 1:
	print('SP')
if sj[0][1:] == sj[1][0:-1]:
	arr[sj[0]] = 'P'
	arr[sj[1]] = 'S'
	mother = sj[0] + sj[1][-1]
else:
	arr[sj[0]] = 'S'
	arr[sj[1]] = 'P'
	mother = sj[1] + sj[0][-1]
for each in arr:
	if arr[each] != 0:
		continue
	if each == mother[:len(each)]:
		arr[each] = 'P'
	else:
		arr[each] = 'S'
for each in allstr:
	ans += arr[each]
	if arr[each] == 'P' and mother[:len(each)] != each or (arr[each] == 'S' and mother[-len(each):] != each):
		flag = 1
		break
	if arr[each] == 'P':
		arr[each] = 'S'
	else:
		arr[each] = 'P'
if flag:
	for each in allstr:
		arr[each] = 0
	if sj[0][1:] == sj[1][0:-1]:
		arr[sj[0]] = 'S'
		arr[sj[1]] = 'P'
		mother = sj[1] + sj[0][-1]
	else:
		arr[sj[0]] = 'P'
		arr[sj[1]] = 'S'
		mother = sj[0] + sj[1][-1]
	for each in arr:
		if arr[each] != 0:
			continue
		if each == mother[:len(each)]:
			arr[each] = 'P'
		else:
			arr[each] = 'S'
	for each in allstr:
		print(arr[each], end='')
		if arr[each] == 'P':
			arr[each] = 'S'
		else:
			arr[each] = 'P'
else:
	for each in ans:
		print(each, 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)


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
d = defaultdict(int)
n = I()
l = []
x = []
for i in range(2 * n - 2):
	s = input().strip()
	x.append(s)
	if len(s) == n - 1:
		l.append(s)
if len(l[0]) == 1:
	w = l[0] + l[1]
	print('SP')
else:
	f = 0
	g = l[1] + l[0][-1]
	y = l[0] + l[1][-1]
	w = g[:]
	for i in range(1, n):
		d[w[:i]] += 1
	for i in range(1, n):
		d[w[i:n]] += 2
	ans = ''
	for i in range(2 * n - 2):
		if d[x[i]] >= 2:
			d[x[i]] -= 2
			ans += 'S'
		elif d[x[i]] >= 1:
			d[x[i]] -= 1
			ans += 'P'
		else:
			break
	if len(ans) != 2 * n - 2:
		w = y[:]
		f = defaultdict(int)
		for i in range(1, n):
			f[w[:i]] += 1
		for i in range(1, n):
			f[w[i:n]] += 2
		ans = ''
		for i in range(2 * n - 2):
			if f[x[i]] >= 2:
				f[x[i]] -= 2
				ans += 'S'
			elif f[x[i]] >= 1:
				f[x[i]] -= 1
				ans += 'P'
		print(ans)
	else:
		print(ans)


import sys
n = int(input())
A = []
for _ in range(2 * n - 2):
	A += [input()]
	if len(A[-1]) == n - 1:
		longest = A[-1]
letters = 'abcdefghijklmnopqrstuvwxyz'
C = ''
for i in range(2):
	for x in letters:
		(pre, suf) = (0, 0)
		if i == 0:
			B = longest + x
		else:
			B = x + longest
		all_have = True
		for w in A:
			(a, b) = (False, False)
			if B[:len(w)] == w:
				a = True
				pre += 1
			if B[-len(w):] == w:
				b = True
				suf += 1
			if not (a or b):
				all_have = False
		if pre >= n - 1 and suf >= n - 1 and all_have:
			C = B
if C == '':
	print(-1)
	sys.exit(0)
(pre, suf) = (0, 0)
(PRE, SUF) = (set(), set())
BOTH = {}
result = ['X'] * (2 * n - 2)
for (i, w) in enumerate(A):
	a = w == C[:len(w)] and w not in PRE
	b = w == C[-len(w):] and w not in SUF
	if w in BOTH:
		PRE.add(w)
		SUF.add(w)
		result[i] = 'P'
		result[BOTH[w]] = 'S'
	elif a and b:
		BOTH[w] = i
		pre += 1
		suf += 1
	elif a:
		pre += 1
		PRE.add(w)
		result[i] = 'P'
	else:
		suf += 1
		SUF.add(w)
		result[i] = 'S'
for i in range(len(result)):
	if result[i] == 'X':
		if suf < n - 1:
			suf += 1
			SUF.add(w)
			result[i] = 'S'
		else:
			pre
			PRE.add(w)
			result[i] = 'P'
print(''.join(result))


n = int(input())
s = []
for i in range(n + n - 2):
	s.append(input())
(pre, suf) = filter(lambda x: len(x) == n - 1, s)

def trystr(st):
	r = ''
	preh = [False] * len(st)
	sufh = [False] * len(st)
	for x in s:
		if st.startswith(x) and (not preh[len(x)]):
			r += 'P'
			preh[len(x)] = True
		elif st.endswith(x) and (not sufh[len(x)]):
			r += 'S'
			sufh[len(x)] = True
		else:
			return
	print(r)
	exit(0)
if pre[:-1] == suf[1:]:
	trystr(suf[0] + pre)
if pre[1:] == suf[:-1]:
	trystr(pre + suf[-1])


def f(x):
	global a
	(b, c) = (a[-1][0], a[-2][0])
	if x:
		(b, c) = (c, b)
	if b[1:] == c[:-1]:
		s = b + c[-1]
		for i in range(n - 1):
			if a[2 * i][0] == s[:i + 1] and a[2 * i + 1][0] == s[n - i - 1:]:
				(ans[a[2 * i][1]], ans[a[2 * i + 1][1]]) = ('P', 'S')
			elif a[2 * i][0] == s[n - i - 1:] and a[2 * i + 1][0] == s[:i + 1]:
				(ans[a[2 * i][1]], ans[a[2 * i + 1][1]]) = ('S', 'P')
			else:
				return 0
	else:
		return 0
	return ''.join(ans)
n = int(input())
a = sorted([[input(), i] for i in range(2 * n - 2)], key=lambda x: len(x[0]))
ans = [0] * (2 * n - 2)
(x, y) = (f(0), f(1))
if x:
	print(x)
elif y:
	print(y)
else:
	print(-1)


import sys
input = sys.stdin.readline
from collections import *
n = int(input())
l = []
for i in range(2 * n - 2):
	s = input()[:-1]
	l.append((i, s))
l.sort(key=lambda t: len(t[1]))
S1 = l[-1][1] + l[0][1]
S2 = l[-1][1] + l[1][1]
S3 = l[0][1] + l[-1][1]
S4 = l[1][1] + l[-1][1]
l.sort(key=lambda t: t[1])
for S in [S1, S2, S3, S4]:
	presuf = []
	for i in range(n - 1):
		presuf.append(('P', S[:i + 1]))
	for i in range(1, n):
		presuf.append(('S', S[i:]))
	presuf.sort(key=lambda t: t[1])
	flag = True
	for i in range(2 * n - 2):
		if l[i][1] != presuf[i][1]:
			flag = False
	if flag:
		ans = [''] * (2 * n - 2)
		for i in range(2 * n - 2):
			ans[l[i][0]] = presuf[i][0]
		print(''.join(ans))
		exit()


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())
v = []
ss = ''
mi = -1

def inv(a):
	if a == 'P':
		return 'S'
	return 'P'
for i in range(2 * n - 2):
	s = input()
	v.append([s, i])
v.sort(key=lambda x: -len(x[0]))
(ss, mi) = v[0]
ans = [-1 for i in range(2 * n - 2)]
bs = list('abcdefghijklmnopqrstuvwxyz')
for b in bs:
	s = ss + b
	ans[mi] = 'P'
	flag = True
	(cnt1, cnt2) = (1, 0)
	for j in range(2 * n - 2):
		(si, i) = v[j]
		if i == mi:
			continue
		if s[:len(si)] == si and s[len(s) - len(si):] == si:
			if j and len(v[j - 1][0]) == len(si):
				ans[i] = inv(ans[v[j - 1][1]])
				continue
			if cnt1 <= cnt2:
				cnt1 += 1
				ans[i] = 'P'
			else:
				cnt2 += 1
				ans[i] = 'S'
		elif s[:len(si)] == si:
			ans[i] = 'P'
			if j and len(v[j - 1][0]) == len(si):
				ans[i] = inv(ans[v[j - 1][1]])
				continue
			cnt1 += 1
		elif s[len(s) - len(si):] == si:
			if j and len(v[j - 1][0]) == len(si):
				ans[i] = inv(ans[v[j - 1][1]])
				continue
			ans[i] = 'S'
			cnt2 += 1
		else:
			flag = False
			break
	if flag:
		print(''.join(ans))
		exit()
	s = b + ss
	ans[mi] = 'S'
	flag = True
	(cnt1, cnt2) = (0, 1)
	for j in range(2 * n - 2):
		(si, i) = v[j]
		if i == mi:
			continue
		if s[:len(si)] == si and s[len(s) - len(si):] == si:
			if j and len(v[j - 1][0]) == len(si):
				ans[i] = inv(ans[v[j - 1][1]])
				continue
			if cnt1 <= cnt2:
				cnt1 += 1
				ans[i] = 'P'
			else:
				cnt2 += 1
				ans[i] = 'S'
		elif s[:len(si)] == si:
			if j and len(v[j - 1][0]) == len(si):
				ans[i] = inv(ans[v[j - 1][1]])
				continue
			ans[i] = 'P'
			cnt1 += 1
		elif s[len(s) - len(si):] == si:
			if j and len(v[j - 1][0]) == len(si):
				ans[i] = inv(ans[v[j - 1][1]])
				continue
			ans[i] = 'S'
			cnt2 += 1
		else:
			flag = False
			break
	if flag:
		print(''.join(ans))
		exit()


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