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!

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$$$.

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.

NoteThe 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.

package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	m := make([]string, 0, 2*n-2)
	var max1, max2 string
	for i := 0; i < 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		m = append(m, s)
		if len(s) > len(max1) {
			max1 = s
		} else if len(s) == len(max1) {
			max2 = s
		}
	}
	if len(max1) == 1 {
		fmt.Println("PS")
		return
	}
	var origin1, origin2 string
	origin1 = max1 + max2[len(max2)-1:]
	origin2 = max2 + max1[len(max1)-1:]
	val := check(origin1, m)
	if val == nil {
		val = check(origin2, m)
	}
	fmt.Println(string(val))
}

func check(origin string, m []string) []byte {
	p := make(map[string]struct{}, len(m)/2)
	s := make(map[string]struct{}, len(m)/2)
	for i := 0; i < len(origin)-1; i++ {
		p[origin[:i+1]] = struct{}{}
		s[origin[i+1:]] = struct{}{}
	}
    val:=make([]byte, 0, len(m))
	for _, v := range m {
		if _, ok := p[v]; ok {
			val = append(val, 'P')
			delete(p, v)
			continue
		}
		if _, ok := s[v]; ok {
			val = append(val, 'S')
			continue
		}
		val = nil
		break
	}
	return val
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	m := make([]string, 0, 2*n-2)
	var max1, max2 string
	for i := 0; i < 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		m = append(m, s)
		if len(s) > len(max1) {
			max1 = s
		} else if len(s) == len(max1) {
			max2 = s
		}
	}
	if len(max1) == 1 {
		fmt.Println("PS")
		return
	}
	var origin1, origin2 string
	// if max1[:len(max1)-1] == max2[1:] {
	// 	origin1 = max1[:len(max1)-1] + max2[len(max2)-2:]
	// }
	// if max2[:len(max2)-1] == max2[:] {
	// 	origin2 = max2[:len(max2)-1] + max1[len(max1)-2:]
	// }
	origin1 = max1 + max2[len(max2)-1:]
	origin2 = max2 + max1[len(max1)-1:]
	var val []byte
	mp := []string{}
	for _, v := range m {
		if strings.HasPrefix(origin1, v) && strings.HasSuffix(origin1, v) {
			if has(v, mp) {
				val = append(val, 'S')
			} else {
				val = append(val, 'P')
				mp = append(mp, v)
			}
			continue
		}
		if strings.HasPrefix(origin1, v) {
			val = append(val, 'P')
			continue
		}
		if strings.HasSuffix(origin1, v) {
			val = append(val, 'S')
			continue
		}
		val = nil
		break
	}

	var val2 []byte
	mp2 := []string{}
	for _, v := range m {
		if strings.HasPrefix(origin2, v) && strings.HasSuffix(origin2, v) {
			if has(v, mp2) {
				val2 = append(val2, 'S')
			} else {
				val2 = append(val2, 'P')
				mp2 = append(mp2, v)
			}
			continue
		}
		if strings.HasPrefix(origin2, v) {
			val2 = append(val2, 'P')
			continue
		}
		if strings.HasSuffix(origin2, v) {
			val2 = append(val2, 'S')
			continue
		}
		val2 = nil
		break
	}
	if val == nil {
		fmt.Println(string(val2))
	} else {
		fmt.Println(string(val))
	}

	// p, s := genMap(origin1)
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		continue

	// 	}
	// 	if _, ok := s[v]; ok {
	// 		continue
	// 	}
	// 	p, s = genMap(origin2)
	// 	break
	// }
	// var val string
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		val += "P"
	// 		delete(p, v)
	// 		continue
	// 	}
	// 	if _, ok := s[v]; ok {
	// 		val += "S"
	// 		delete(s, v)
	// 		continue
	// 	}
	// }
	// fmt.Println(val)
}

// func genMap(str string) (map[string]struct{}, map[string]struct{}) {
// 	p := make(map[string]struct{})
// 	s := make(map[string]struct{})
// 	for i := 0; i < len(str)-1; i++ {
// 		p[str[:i+1]] = struct{}{}
// 		s[str[i+1:]] = struct{}{}
// 	}
// 	return p, s
// }

func has(s string, ss []string) bool {
	for _, v := range ss {
		if v == s {
			return true
		}
	}
	return false
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	m := make([]string, 0, 2*n-2)
	var max1, max2 string
	for i := 0; i < 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		m = append(m, s)
		if len(s) > len(max1) {
			max1 = s
		} else if len(s) == len(max1) {
			max2 = s
		}
	}
	if len(max1) == 1 {
		fmt.Println("PS")
		return
	}
	var origin1, origin2 string
	origin1 = max1 + max2[len(max2)-1:]
	origin2 = max2 + max1[len(max1)-1:]
	val := check(origin1, m)
	if val == nil {
		val = check(origin2, m)
	}
	fmt.Println(string(val))
}

func check(origin string, m []string) []byte {
	p := make(map[string]struct{}, len(m)/2)
	s := make(map[string]struct{}, len(m)/2)
	for i := 0; i < len(origin)-1; i++ {
		p[origin[:i+1]] = struct{}{}
		s[origin[i+1:]] = struct{}{}
	}
	var val []byte
	for _, v := range m {
		if _, ok := p[v]; ok {
			val = append(val, 'P')
			delete(p, v)
			continue
		}
		if _, ok := s[v]; ok {
			val = append(val, 'S')
			continue
		}
		val = nil
		break
	}
	return val
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	m := make([]string, 0, 2*n-2)
	var max1, max2 string
	for i := 0; i < 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		m = append(m, s)
		if len(s) > len(max1) {
			max1 = s
		} else if len(s) == len(max1) {
			max2 = s
		}
	}
	if len(max1) == 1 {
		fmt.Println("PS")
		return
	}
	var origin1, origin2 string
	origin1 = max1 + max2[len(max2)-1:]
	origin2 = max2 + max1[len(max1)-1:]
	val := check(origin1, m)
	if val == nil {
		val = check(origin2, m)
	}
	fmt.Println(string(val))
}

func check(origin string, m []string) []byte {
	var val []byte
	mp := make(map[string]struct{})
	for _, v := range m {
		if strings.HasPrefix(origin, v) && strings.HasSuffix(origin, v) {
			if _, ok := mp[v]; ok {
				val = append(val, 'S')
			} else {
				val = append(val, 'P')
				mp[v] = struct{}{}
			}
			continue
		}
		if strings.HasPrefix(origin, v) {
			val = append(val, 'P')
			continue
		}
		if strings.HasSuffix(origin, v) {
			val = append(val, 'S')
			continue
		}
		val = nil
		break
	}
	return val
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	ss := make([]string, 0, 2*n-2)
	for i := 1; i <= 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		ss = append(ss, s)
	}
	fmt.Println(prefixesAndSuffixes(ss, n))
}

func prefixesAndSuffixes(ss []string, n int) string {
	var s1, s2 string
	for _, s := range ss {
		if len(s) == n-1 {
			switch {
			case s1 == "":
				s1 = s
			case s2 == "":
				s2 = s
			}
		}
	}
	fs := []string{
		s1 + string(s2[len(s2)-1]),
		s2 + string(s1[len(s1)-1]),
	}
	for _, f := range fs {
		if res := getRes(ss, f); res != "" {
			return res
		}
	}
	return ""
}

func getRes(ss []string, f string) string {
	var (
		m = make(map[string]struct{})
	)
	res := make([]byte, 0, len(ss))
	for _, s := range ss {
		switch {
		default:
			return ""
		case strings.HasPrefix(f, s) && strings.HasSuffix(f, s):
			if _, has := m[s]; has {
				res = append(res, 'S')
			} else {
				res = append(res, 'P')
				m[s] = struct{}{}
			}
		case strings.HasPrefix(f, s):
			res = append(res, 'P')
		case strings.HasSuffix(f, s):
			res = append(res, 'S')
		}
	}
	return string(res)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func Solve(str string, v []string, t int) (bool, string) {
//	fmt.Printf("tes=%s\n",str)
	ans := ""
	psflag := make([]int, 2*t-2)
	flag := make([]int, t)
	pos := make([]int, t)
	for i := 0; i < 2*t-2; i++ {
		p := strings.HasPrefix(str, v[i])
		s := strings.HasSuffix(str, v[i])
		lens := len(v[i])
		vf := 0
		if p {
			vf |= 1
		}
		if s {
			vf |= 2
		}
		if vf == 0{
			return false,""
			//fmt.Printf("====%s %s\n",str,v[i])
		}
		if flag[lens] == 0{
			flag[lens] = vf
			pos[lens] = i
			continue
		}
		if (vf|flag[lens]) != 3{
			return false,""
		}
		if (vf|1) == 1{
			psflag[i] = 1
			psflag[pos[lens]]= 0
		//	fmt.Printf("-->%d %d\n",i,pos[lens])
		}else{
			psflag[i] = 0
			psflag[pos[lens]]= 1
		//	fmt.Printf("----->%d %d\n",i,pos[lens])
		}

	}
	for i := 0; i < 2*t-2; i++ {
		if psflag[i] == 1 {
			ans += "P"
		} else {
			ans += "S"
		}
	}
	return true, ans
}
func merge(a, b string) string {
	lenb := len(b)
	last := string(b[lenb-1:])
	return string(a + last)
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanf(buf, "%d\n", &t)
	v := make([]string, 2*t-2)
	ls := make([]string, 2)

	f := 0
	for i := 0; i < 2*t-2; i++ {
		fmt.Fscanf(buf, "%s\n", &v[i])
		if len(v[i]) == t-1 {
			ls[f] = string(v[i])
			f++

		}
	}
	for i := 0; i < 2; i++ {
		ok, ans := Solve(merge(ls[i], ls[i^1]), v, t)
		if ok {
			fmt.Printf("%s\n", ans)
			break;
		}
	}

}
/*
5
baba
abab
a
a
ba
ab
aba
aba
*/

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	ss := make([]string, 0, 2*n-2)
	for i := 1; i <= 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		ss = append(ss, s)
	}
	fmt.Println(prefixesAndSuffixes(ss, n))
}

func prefixesAndSuffixes(ss []string, n int) string {
	var s1, s2 string
	for _, s := range ss {
		if len(s) == n-1 {
			switch {
			case s1 == "":
				s1 = s
			case s2 == "":
				s2 = s
			}
		}
	}
	fs := []string{
		s1 + string(s2[len(s2)-1]),
		s2 + string(s1[len(s1)-1]),
	}
	for _, f := range fs {
		if res := getRes(ss, f); res != "" {
			return res
		}
	}
	return ""
}

func getRes(ss []string, f string) string {
	var (
		res string
		m   = make(map[string]struct{})
	)
	for _, s := range ss {
		switch {
		default:
			return ""
		case strings.HasPrefix(f, s) && strings.HasSuffix(f, s):
			if _, has := m[s]; has {
				res += "S"
			} else {
				res += "P"
				m[s] = struct{}{}
			}
		case strings.HasPrefix(f, s):
			res += "P"
		case strings.HasSuffix(f, s):
			res += "S"
		}
	}
	return res
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

type ss struct {
	index int
	c     string
}

func sOrP(pp, ps, s string) (isP, isS bool) {
	for i := 0; i < len(s); i++ {
		isS = s[len(s)-1-i] == ps[len(ps)-1-i]
		isP = s[i] == pp[i]
		if isS != isP {
			return
		}
	}
	return
}

func match(s [][]*ss, res []rune, n int) bool {
	res[s[n-1][0].index] = rune('P')
	res[s[n-1][1].index] = rune('S')
	for i := n - 2; i > 0; i-- {
		isp0, iss0 := sOrP(s[n-1][0].c, s[n-1][1].c, s[i][0].c)
		isp1, iss1 := sOrP(s[n-1][0].c, s[n-1][1].c, s[i][1].c)
		if !(isp0 || iss0) || !(isp1 || iss1) {
			return false
		}
		if !isp0 {
			s[i][0], s[i][1] = s[i][1], s[i][0]
		}
		res[s[i][0].index] = rune('P')
		res[s[i][1].index] = rune('S')
	}
	return true
}

func main() {
	var (
		s   [][]*ss
		res []rune
	)

	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanln(reader, &n)
	s = make([][]*ss, n)
	res = make([]rune, 2*n-2)

	for i := 0; i < 2*n-2; i++ {
		line, _ := reader.ReadString('\n')
		line = line[:len(line)-2]
		s[len(line)] = append(s[len(line)], &ss{i, line})
	}

	if s[n-1][0].c[1:] != s[n-1][1].c[:len(s[n-1][1].c)-1] {
		s[n-1][0], s[n-1][1] = s[n-1][1], s[n-1][0]
	}

	cm := match(s, res, n)
	if !cm {
		s[n-1][0], s[n-1][1] = s[n-1][1], s[n-1][0]
		match(s, res, n)
	}

	fmt.Println(string(res))
}

package main

import (
    "fmt"
    "bufio"
    "os"
    "sort"
)

type elem struct {
    val string
    loc int
}

func OriginString (s, t string) (string, bool) {
    for i := 1; i < len(s); i++ {
        if s[i] != t[i - 1] {
            return "", false
        }
    }
    return s + string(t[len(t) - 1]), true
}

func IsPrefix (s, orgin string) bool {
    for i := 0; i < len(s); i++ {
        if s[i] != orgin[i] {
            return false
        }
    }
    return true
}
func IsSuffix (s, origin string) bool {
    var l int = len(origin) - 1
    for i := 0; i < len(s); i++ {
        if s[len(s) - i - 1] != origin[l - i] {
            return false
        }
    }
    return true
}

func FullTest (base string, arr []elem) ([]byte, bool) {
    var res []byte = make([]byte, len(arr))
    for i := 0; i < len(arr); i += 2 {
        if (IsPrefix(arr[i].val, base) && IsSuffix(arr[i + 1].val, base)) {
            res[arr[i].loc] = 80
            res[arr[i + 1].loc] = 83
        } else if (IsSuffix(arr[i].val, base) && IsPrefix(arr[i + 1].val, base)) {
            res[arr[i].loc] = 83
            res[arr[i + 1].loc] = 80
        } else {
            return res, false
        }
    }
    return res, true
}

func main() {
    stdin := bufio.NewReader(os.Stdin)

    var n int
    fmt.Fscanln(stdin, &n)

    var s []elem = make([]elem, 2*n - 2)
    var t1, t2 string = "", ""
    for i := 0; i < 2*n - 2; i++ {
        fmt.Fscanln(stdin, &s[i].val)
        s[i].loc = i
        if len(s[i].val) == n - 1 {
            if t1 == "" {
                t1 = s[i].val
            } else {
                t2 = s[i].val
            }
        }
    }

    sort.Slice(s[:], func (i, j int) bool {
        return len(s[i].val) < len(s[j].val)
    })

    // S - 83, P - 80
    t, status := OriginString(t1, t2)

    var res []byte
    if status {
        res, status = FullTest(t, s)
    }
    if !status {
        t, status = OriginString(t2, t1)
        res, status = FullTest(t, s)
    }

    fmt.Println(string(res))
}

package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
)

var inp *bufio.Scanner
var out *bufio.Writer
var x int

func io() {
	inp = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	inp.Split(bufio.ScanWords)
}

func main() {
	io()
	n := nextInt()
	a := make([]string, n<<1-2)
	var long string
	short := make([]string, 0)
	for i := 0; i < n<<1-2; i++ {
		a[i] = nextString()
		if len(a[i]) == n-1 {
			long = a[i]
		} else if len(a[i]) == 1 {
			short = append(short, a[i])
		}
	}

	if n == 2 {
		out.WriteString("SP")
		out.Flush()
		return
	}

	isPref := make([]bool, n<<1-2)

	for try := 0; try < 2; try++ {
		main : for pos := 0; pos < 2; pos++ {
			s := long
			if pos == 0 {
				s += short[try]
			} else {
				s = short[try] + s
			}
			used := make([]bool, n<<1-2)
			for i := 0; i < n-1; i++ {
				found := false
				for idx, sub := range a {
					if !used[idx] && sub == s[:i+1] {
						used[idx] = true;
						isPref[idx] = true
						found = true
						break;
					}
				}
				if !found {
					continue main
				}
			}

			for i := 0; i < n-1; i++ {
				found := false
				for idx, sub := range a {
					if !used[idx] && sub == s[n-i-1:] {
						used[idx] = true;
						isPref[idx] = false
						found = true
						break;
					}
				}
				if !found {
					continue main
				}
			}

			sb := strings.Builder{}
			for _, v := range isPref {
				if v {
					sb.WriteString("P")
				} else {
					sb.WriteString("S")
				}
			}
			out.WriteString(sb.String())
			out.Flush()
			return
		}
	}

}

func nextString() string {
	inp.Scan()
	return inp.Text();
}

func nextInt() int {
	v, _ := strconv.ParseInt(nextString(), 10, 64)
	return int(v)
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscan(os.Stdin, &n)

	var (
		strs = make([]string, 0, 2*n-2)
		pos  = make([]int, 0, 2)
	)
	for i := 0; i < 2*n-2; i++ {
		var s string
		fmt.Fscan(os.Stdin, &s)
		strs = append(strs, s)
		if len(s) == n-1 {
			pos = append(pos, i)
		}
	}

	ans := solve(pos[0], pos[1], strs)
	if ans == nil {
		ans = solve(pos[1], pos[0], strs)
	}
	for _, a := range ans {
		if a == prefix {
			fmt.Print("P")
		} else {
			fmt.Print("S")
		}
	}
}

const (
	unspecified = iota
	prefix
	suffix
)

func solve(pi, si int, strs []string) []int {
	ans := make([]int, len(strs))
	digits := make(map[int]int, len(strs)/2)

	ans[pi] = prefix
	ans[si] = suffix
	for i, s := range strs {
		if i == pi || i == si {
			continue
		}
		var (
			hasP = strings.HasPrefix(strs[pi], s)
			hasS = strings.HasSuffix(strs[si], s)
		)
		if !hasP && !hasS {
			return nil
		}
		if hasP && hasS {
			continue
		}
		if hasP {
			if digits[len(s)] == prefix {
				return nil
			}
			digits[len(s)] = prefix
			ans[i] = prefix
			continue
		}
		if digits[len(s)] == suffix {
			return nil
		}
		ans[i] = suffix
		digits[len(s)] = suffix
	}
	for i, g := range ans {
		if g != unspecified {
			continue
		}
		l := len(strs[i])
		if _, ok := digits[l]; !ok {
			digits[l] = prefix
			ans[i] = prefix
			continue
		}

		if digits[l] == prefix {
			ans[i] = suffix
		} else {
			ans[i] = prefix
		}
	}
	return ans
}

package main

import (
	. "fmt"
	"strings"
	"sort"
)

func main() {
	type pair struct {
		s   string
		idx int
	}

	var n int
	var s string
	Scan(&n)
	n = 2*n - 2
	arr := make([]pair, n)
	for i := range arr {
		Scan(&s)
		arr[i] = pair{s, i}
	}
	sort.Slice(arr, func(i, j int) bool { return len(arr[i].s) < len(arr[j].s) })

	p, s := arr[n-2].s, arr[n-1].s
outer:
	for _, comb := range []string{p + s[len(s)-1:], s + p[len(p)-1:]} {
		ans := make([]byte, n)
		for i := 0; i < n; i += 2 {
			p0, p1 := arr[i], arr[i+1]
			if strings.HasPrefix(comb, p0.s) && strings.HasSuffix(comb, p1.s) {
				ans[p0.idx], ans[p1.idx] = 'P', 'S'
			} else if strings.HasSuffix(comb, p0.s) && strings.HasPrefix(comb, p1.s) {
				ans[p0.idx], ans[p1.idx] = 'S', 'P'
			} else {
				continue outer
			}
		}
		Print(string(ans))
		return
	}
}

package main

import (
	"fmt"
)

func main() {
	var count int
	fmt.Scanf("%d\n", &count)
	var bss [][]byte
	for i := 0; i < 2*count-2; i++ {
		var str string
		fmt.Scanf("%s\n", &str)
		bss = append(bss, []byte(str))
	}
	dic := make(map[int][]int)
	for ix, bs := range bss {
		dic[len(bs)] = append(dic[len(bs)], ix)
	}
	a, b := bss[dic[count-1][0]], bss[dic[count-1][1]]
	all := append(a[:], b[len(b)-1:]...)
	flag := false
	preCount, suffCount := 0, 0
	for _, bs := range bss {
		isPre, isSuff := isPrefix(all, bs), isSuff(all, bs)
		if isPre {
			preCount++
		}
		if isSuff {
			suffCount++
		}
		if !isPre && !isSuff {
			flag = true
			break
		}
	}
	if flag || (preCount != suffCount) {
		a, b = b, a
	}
	ret := make([]byte, 2*count-2)
	for i := 1; i <= count-1; i++ {
		ba := dic[i]
		if isPrefix(a, bss[ba[0]]) {
			ret[ba[0]] = 'P'
			ret[ba[1]] = 'S'
		} else {
			ret[ba[1]] = 'P'
			ret[ba[0]] = 'S'
		}
	}
	fmt.Println(string(ret))
}

func isPrefix(main, branch []byte) bool {
	if len(branch) > len(main) {
		return false
	}
	for ix, char := range branch {
		if char != main[ix] {
			return false
		}
	}
	return true
}

func isSuff(main, branch []byte) bool {
	start := len(main) - len(branch)
	if start < 0 {
		return false
	}
	for ix, char := range branch {
		if char != main[start+ix] {
			return false
		}
	}
	return true
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanln(os.Stdin, &n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscanf(os.Stdin, "%s\n", &a[i])
	}
	pq := make([]string, 0, 2)
	for _, s := range a {
		if len(s) == n-1 {
			pq = append(pq, s)
		}
	}
	rs := []string{
		pq[0] + pq[1][len(pq[1])-1:],
		pq[1] + pq[0][len(pq[0])-1:],
	}
	for _, s := range rs {
		if str := solve(s, a); str != "" {
			fmt.Println(str)
			return
		}
	}
}

func solve(r string, a []string) string {
	rs := make([]byte, len(a))
	f := make(map[string]struct{})
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return ""
		}
		if ip && is {
			if _, ok := f[s]; ok {
				rs[i] = 'S'
				continue
			}
			rs[i] = 'P'
			f[s] = struct{}{}
		} else if ip {
			rs[i] = 'P'
		} else if is {
			rs[i] = 'S'
		}
	}
	return string(rs)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Scan(&n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscanf(r, "%s\n", &a[i])
	}

	// "ababa"
	// n := 5
	// a := []string{
	// 	"ba",   // S
	// 	"a",    // P or S
	// 	"abab", // P
	// 	"a",    // P or S
	// 	"aba",  // P or S
	// 	"baba", // S
	// 	"ab",   // P
	// 	"aba",  // P or S
	// }

	pair := make([]string, 0, 2)
	for i := 0; i < len(a); i++ {
		if len(a[i]) == n-1 {
			pair = append(pair, a[i])
		}
	}
	rs := make([]string, 0, 2)
	if pair[0][1:] == pair[1][0:len(pair[1])-1] {
		rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	}
	if pair[1][1:] == pair[0][0:len(pair[0])-1] {
		rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	}
	for i := range rs {
		if r := solve(rs[i], a); len(r) > 0 {
			for _, s := range r {
				fmt.Print(s)
			}
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc || pc == sc {
			rs[i] = "P"
			pc--
		} else {
			rs[i] = "S"
			sc--
		}
	}
	return rs
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanln(os.Stdin, &n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscanf(os.Stdin, "%s\n", &a[i])
	}
	pq := make([]string, 0, 2)
	for _, s := range a {
		if len(s) == n-1 {
			pq = append(pq, s)
		}
	}
	rs := []string{
		pq[0] + pq[1][len(pq[1])-1:],
		pq[1] + pq[0][len(pq[0])-1:],
	}
	for _, s := range rs {
		if str := solve(s, a); str != "" {
			fmt.Println(str)
			return
		}
	}
}

func solve(r string, a []string) string {
	var (
		rs = make([]byte, len(a))
		ti = make([]int, 0, len(a))
		pc int
		sc int
	)
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return ""
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip {
			rs[i] = 'P'
			pc++
		} else if is {
			rs[i] = 'S'
			sc++
		}
	}
	if len(ti) != len(a)-pc-sc {
		return ""
	}
	for _, i := range ti {
		if pc > sc {
			rs[i] = 'S'
			sc++
		} else {
			rs[i] = 'P'
			pc++
		}
	}
	return string(rs)
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscanf(os.Stdin, "%s\n", &a[i])
	}
	fmt.Println(a)

	// "ababa"
	// n := 5
	// a := []string{
	// 	"ba",   // S
	// 	"a",    // P or S
	// 	"abab", // P
	// 	"a",    // P or S
	// 	"aba",  // P or S
	// 	"baba", // S
	// 	"ab",   // P
	// 	"aba",  // P or S
	// }

	pair := make([]string, 0, 2)
	for i := 0; i < len(a); i++ {
		if len(a[i]) == n-1 {
			pair = append(pair, a[i])
		}
	}
	rs := make([]string, 0, 2)
	if pair[0][1:] == pair[1][0:len(pair[1])-1] {
		rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	}
	if pair[1][1:] == pair[0][0:len(pair[0])-1] {
		rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	}
	for i := range rs {
		if r := solve(rs[i], a); len(r) > 0 {
			for _, s := range r {
				fmt.Print(s)
			}
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc || pc == sc {
			rs[i] = "P"
			pc--
		} else {
			rs[i] = "S"
			sc--
		}
	}
	return rs
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Scan(&a[i])
	}
	fmt.Println(a)

	// "ababa"
	// n := 5
	// a := []string{
	// 	"ba",   // S
	// 	"a",    // P or S
	// 	"abab", // P
	// 	"a",    // P or S
	// 	"aba",  // P or S
	// 	"baba", // S
	// 	"ab",   // P
	// 	"aba",  // P or S
	// }

	pair := make([]string, 0, 2)
	for i := 0; i < len(a); i++ {
		if len(a[i]) == n-1 {
			pair = append(pair, a[i])
		}
	}
	rs := make([]string, 0, 2)
	if pair[0][1:] == pair[1][0:len(pair[1])-1] {
		rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	}
	if pair[1][1:] == pair[0][0:len(pair[0])-1] {
		rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	}
	for i := range rs {
		if r := solve(rs[i], a); len(r) > 0 {
			for _, s := range r {
				fmt.Print(s)
			}
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc || pc == sc {
			rs[i] = "P"
			pc--
		} else {
			rs[i] = "S"
			sc--
		}
	}
	return rs
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Scan(&a[i])
	}
	// "ababa"
	// n := 5
	// a := []string{
	// 	"ba",   // S
	// 	"a",    // P or S
	// 	"abab", // P
	// 	"a",    // P or S
	// 	"aba",  // P or S
	// 	"baba", // S
	// 	"ab",   // P
	// 	"aba",  // P or S
	// }
	// n := 3
	// a := []string{
	// 	"a",
	// 	"aa",
	// 	"aa",
	// 	"a",
	// }
	pair := make([]string, 0, 2)
	for i := 0; i < len(a); i++ {
		if len(a[i]) == n-1 {
			pair = append(pair, a[i])
		}
	}
	rs := make([]string, 0, 2)
	if pair[0][1:] == pair[1][0:len(pair[1])-1] {
		rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	}
	if pair[1][1:] == pair[0][0:len(pair[0])-1] {
		rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	}
	for _, t := range rs {
		if r := solve(t, a); len(r) > 0 {
			for _, s := range r {
				fmt.Print(s)
			}
			return
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc {
			rs[i] = "P"
			pc--
		} else {
			rs[i] = "S"
			sc--
		}
	}
	return rs
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Scan(&a[i])
	}
	// "ababa"
	// n := 5
	// a := []string{
	// 	"ba",   // S
	// 	"a",    // P or S
	// 	"abab", // P
	// 	"a",    // P or S
	// 	"aba",  // P or S
	// 	"baba", // S
	// 	"ab",   // P
	// 	"aba",  // P or S
	// }
	// n := 3
	// a := []string{
	// 	"a",
	// 	"aa",
	// 	"aa",
	// 	"a",
	// }
	pair := make([]string, 0, 2)
	for i := 0; i < len(a); i++ {
		if len(a[i]) == n-1 {
			pair = append(pair, a[i])
		}
	}
	rs := make([]string, 0, 2)
	if pair[0][1:] == pair[1][0:len(pair[1])-1] {
		rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	}
	if pair[1][1:] == pair[0][0:len(pair[0])-1] {
		rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	}
	for _, t := range rs {
		if r := solve(t, a); len(r) > 0 {
			for _, s := range r {
				fmt.Print(s)
			}
			return
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc {
			rs[i] = "P"
			pc--
		} else {
			rs[i] = "S"
			sc--
		}
	}
	fmt.Println(rs)
	return rs
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	// var n int
	// fmt.Fscanln(os.Stdin, &n)
	// a := make([]string, 2*n-2)
	// for i := range a {
	// 	fmt.Fscanf(os.Stdin, "%s\n", &a[i])
	// }
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	a := make([]string, 0, 2*n-2)
	for i := 1; i <= 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		a = append(a, s)
	}
	pq := make([]string, 0, 2)
	for _, s := range a {
		if len(s) == n-1 {
			pq = append(pq, s)
		}
	}
	rs := make([]string, 2)
	rs[0] = pq[0] + pq[1][len(pq[1])-1:]
	rs[1] = pq[1] + pq[0][len(pq[0])-1:]
	for _, s := range rs {
		if r := solve(s, a); len(r) > 0 {
			fmt.Println(string(r))
			return
		}
	}
}

func solve(r string, a []string) []byte {
	var (
		rs = make([]byte, len(a))
		ti = make([]int, 0, len(a))
		pc int
		sc int
	)
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = 'P'
			pc++
		} else {
			rs[i] = 'S'
			sc++
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc {
			rs[i] = 'S'
			sc++
		} else {
			rs[i] = 'P'
			pc++
		}
	}
	return rs
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	m := make([]string, 0, 2*n-2)
	var max1, max2 string
	for i := 0; i < 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		m = append(m, s)
		if len(s) > len(max1) {
			max1 = s
		} else if len(s) == len(max1) {
			max2 = s
		}
	}
	if len(max1) == 1 {
		fmt.Println("PS")
		return
	}
	var origin1, origin2 string
	if max1[:len(max1)-1] == max2[1:] {
		origin1 = max1[:len(max1)-1] + max2[len(max2)-2:]
	}
	if max2[:len(max1)-1] == max1[1:] {
		origin2 = max2[:len(max2)-1] + max1[len(max1)-2:]
	}
	var val []byte
	mp := []string{}
	for _, v := range m {
		if strings.HasPrefix(origin1, v) && strings.HasSuffix(origin1, v) {
			if has(v, mp) {
				val = append(val, 'S')
			} else {
				val = append(val, 'P')
				mp = append(mp, v)
			}
			continue
		}
		if strings.HasPrefix(origin1, v) {
			val = append(val, 'P')
			continue
		}
		if strings.HasSuffix(origin1, v) {
			val = append(val, 'S')
			continue
		}
		val = nil
		break
	}

	var val2 []byte
	mp2 := []string{}
	for _, v := range m {
		if strings.HasPrefix(origin2, v) && strings.HasSuffix(origin2, v) {
			if has(v, mp2) {
				val2 = append(val2, 'S')
			} else {
				val2 = append(val2, 'P')
				mp2 = append(mp2, v)
			}
			continue
		}
		if strings.HasPrefix(origin2, v) {
			val2 = append(val2, 'P')
			continue
		}
		if strings.HasSuffix(origin2, v) {
			val2 = append(val2, 'S')
			continue
		}
		val2 = nil
		break
	}
	if val == nil {
		fmt.Println(string(val2))
	} else {
		fmt.Println(string(val))
	}

	// p, s := genMap(origin1)
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		continue

	// 	}
	// 	if _, ok := s[v]; ok {
	// 		continue
	// 	}
	// 	p, s = genMap(origin2)
	// 	break
	// }
	// var val string
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		val += "P"
	// 		delete(p, v)
	// 		continue
	// 	}
	// 	if _, ok := s[v]; ok {
	// 		val += "S"
	// 		delete(s, v)
	// 		continue
	// 	}
	// }
	// fmt.Println(val)
}

// func genMap(str string) (map[string]struct{}, map[string]struct{}) {
// 	p := make(map[string]struct{})
// 	s := make(map[string]struct{})
// 	for i := 0; i < len(str)-1; i++ {
// 		p[str[:i+1]] = struct{}{}
// 		s[str[i+1:]] = struct{}{}
// 	}
// 	return p, s
// }

func has(s string, ss []string) bool {
	for _, v := range ss {
		if v == s {
			return true
		}
	}
	return false
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	m := make([]string, 0, 2*n-2)
	var max1, max2 string
	for i := 0; i < 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		m = append(m, s)
		if len(s) > len(max1) {
			max1 = s
		} else if len(s) == len(max1) {
			max2 = s
		}
	}
	if len(max1) == 1 {
		fmt.Println("PS")
		return
	}
	var origin1, origin2 string
	if max1[:len(max1)-1] == max2[1:] {
		origin1 = max1[:len(max1)-1] + max2[len(max2)-2:]
	}
	if max2[:len(max1)-1] == max1[1:] {
		origin2 = max2[:len(max2)-1] + max1[len(max1)-2:]
	}
	var val []byte
	mp := make(map[string]struct{})
	for _, v := range m {
		if strings.HasPrefix(origin1, v) && strings.HasSuffix(origin1, v) {
			if _, ok := mp[v]; ok {
				val = append(val, 'S')
			} else {
				val = append(val, 'P')
				mp[v] = struct{}{}
			}
			continue
		}
		if strings.HasPrefix(origin1, v) {
			val = append(val, 'P')
			continue
		}
		if strings.HasSuffix(origin1, v) {
			val = append(val, 'S')
			continue
		}
		val = nil
	}
	if val == nil {
		for _, v := range m {
			if strings.HasPrefix(origin2, v) && strings.HasSuffix(origin2, v) {
				if _, ok := mp[v]; ok {
					val = append(val, 'S')
				} else {
					val = append(val, 'P')
					mp[v] = struct{}{}
				}
				continue
			}
			if strings.HasPrefix(origin2, v) {
				val = append(val, 'P')
				continue
			}
			if strings.HasSuffix(origin2, v) {
				val = append(val, 'S')
				continue
			}
		}
	}
	fmt.Println(string(val))

	// p, s := genMap(origin1)
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		continue

	// 	}
	// 	if _, ok := s[v]; ok {
	// 		continue
	// 	}
	// 	p, s = genMap(origin2)
	// 	break
	// }
	// var val string
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		val += "P"
	// 		delete(p, v)
	// 		continue
	// 	}
	// 	if _, ok := s[v]; ok {
	// 		val += "S"
	// 		delete(s, v)
	// 		continue
	// 	}
	// }
	// fmt.Println(val)
}

func genMap(str string) (map[string]struct{}, map[string]struct{}) {
	p := make(map[string]struct{})
	s := make(map[string]struct{})
	for i := 0; i < len(str)-1; i++ {
		p[str[:i+1]] = struct{}{}
		s[str[i+1:]] = struct{}{}
	}
	return p, s
}

package main

import (
	"fmt"
	"os"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	m := make([]string, 0, 2*n-2)
	var max1, max2 string
	for i := 0; i < 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		m = append(m, s)
		if len(s) > len(max1) {
			max1 = s
		} else if len(s) == len(max1) {
			max2 = s
		}
	}
	if len(max1) == 1 {
		fmt.Println("PS")
		return
	}

	var origin1, origin2 string
	if max1[:len(max1)-1] == max2[1:] {
		origin1 = max1[:len(max1)-1] + max2[len(max2)-2:]
	}
	if max2[:len(max1)-1] == max1[1:] {
		origin2 = max2[:len(max2)-1] + max1[len(max1)-2:]
	}
	p, s := genMap(origin1)
	for _, v := range m {
		if _, ok := p[v]; ok {
			continue

		}
		if _, ok := s[v]; ok {
			continue
		}
		p, s = genMap(origin2)
		break
	}
	var val string
	for _, v := range m {
		if _, ok := p[v]; ok {
			val += "P"
			delete(p, v)
			continue
		}
		if _, ok := s[v]; ok {
			val += "S"
			delete(s, v)
			continue
		}
	}
	fmt.Println(val)
}

func genMap(str string) (map[string]struct{}, map[string]struct{}) {
	p := make(map[string]struct{})
	s := make(map[string]struct{})
	for i := 0; i < len(str)-1; i++ {
		p[str[:i+1]] = struct{}{}
		s[str[i+1:]] = struct{}{}
	}
	return p, s
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	m := make([]string, 0, 2*n-2)
	var max1, max2 string
	for i := 0; i < 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		m = append(m, s)
		if len(s) > len(max1) {
			max1 = s
		} else if len(s) == len(max1) {
			max2 = s
		}
	}
	if len(max1) == 1 {
		fmt.Println("PS")
		return
	}
	var origin1, origin2 string
	if max1[:len(max1)-1] == max2[1:] {
		origin1 = max1[:len(max1)-1] + max2[len(max2)-2:]
	}
	if max2[:len(max1)-1] == max1[1:] {
		origin2 = max2[:len(max2)-1] + max1[len(max1)-2:]
	}
	var val []byte
	mp := []string{}
	for _, v := range m {
		if strings.HasPrefix(origin1, v) && strings.HasSuffix(origin1, v) {
			if has(v, mp) {
				val = append(val, 'S')
			} else {
				val = append(val, 'P')
				mp = append(mp, v)
			}
			continue
		}
		if strings.HasPrefix(origin1, v) {
			val = append(val, 'P')
			continue
		}
		if strings.HasSuffix(origin1, v) {
			val = append(val, 'S')
			continue
		}
		val = nil
		break
	}

	var val2 []byte
	mp2 := []string{}
	for _, v := range m {
		if strings.HasPrefix(origin2, v) && strings.HasSuffix(origin2, v) {
			if has(v, mp2) {
				val2 = append(val2, 'S')
			} else {
				val2 = append(val2, 'P')
				mp2 = append(mp2, v)
			}
			continue
		}
		if strings.HasPrefix(origin2, v) {
			val2 = append(val2, 'P')
			continue
		}
		if strings.HasSuffix(origin2, v) {
			val2 = append(val2, 'S')
			continue
		}
		val2 = nil
		break
	}
	if val == nil {
		fmt.Println("ssss")
	} else {
		fmt.Println(string(val))
	}

	// p, s := genMap(origin1)
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		continue

	// 	}
	// 	if _, ok := s[v]; ok {
	// 		continue
	// 	}
	// 	p, s = genMap(origin2)
	// 	break
	// }
	// var val string
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		val += "P"
	// 		delete(p, v)
	// 		continue
	// 	}
	// 	if _, ok := s[v]; ok {
	// 		val += "S"
	// 		delete(s, v)
	// 		continue
	// 	}
	// }
	// fmt.Println(val)
}

// func genMap(str string) (map[string]struct{}, map[string]struct{}) {
// 	p := make(map[string]struct{})
// 	s := make(map[string]struct{})
// 	for i := 0; i < len(str)-1; i++ {
// 		p[str[:i+1]] = struct{}{}
// 		s[str[i+1:]] = struct{}{}
// 	}
// 	return p, s
// }

func has(s string, ss []string) bool {
	for _, v := range ss {
		if v == s {
			return true
		}
	}
	return false
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	m := make([]string, 0, 2*n-2)
	var max1, max2 string
	for i := 0; i < 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		m = append(m, s)
		if len(s) > len(max1) {
			max1 = s
		} else if len(s) == len(max1) {
			max2 = s
		}
	}
	if len(max1) == 1 {
		fmt.Println("PS")
		return
	}
	var origin1, origin2 string
	if max1[:len(max1)-1] == max2[1:] {
		origin1 = max1[:len(max1)-1] + max2[len(max2)-2:]
	}
	if max2[:len(max1)-1] == max1[1:] {
		origin2 = max2[:len(max2)-1] + max1[len(max1)-2:]
	}
	var val []byte
	mp := make(map[string]struct{})
	for _, v := range m {
		if strings.HasPrefix(origin1, v) && strings.HasSuffix(origin1, v) {
			if _, ok := mp[v]; ok {
				val = append(val, 'S')
			} else {
				val = append(val, 'P')
				mp[v] = struct{}{}
			}
			continue
		}
		if strings.HasPrefix(origin1, v) {
			val = append(val, 'P')
			continue
		}
		if strings.HasSuffix(origin1, v) {
			val = append(val, 'S')
			continue
		}
		val = nil
		break
	}
	var val2 []byte
	for _, v := range m {
		if strings.HasPrefix(origin2, v) && strings.HasSuffix(origin2, v) {
			if _, ok := mp[v]; ok {
				val2 = append(val2, 'S')
			} else {
				val2 = append(val2, 'P')
				mp[v] = struct{}{}
			}
			continue
		}
		if strings.HasPrefix(origin2, v) {
			val2 = append(val2, 'P')
			continue
		}
		if strings.HasSuffix(origin2, v) {
			val2 = append(val2, 'S')
			continue
		}
		val = nil
		break
	}
	if val == nil {
		fmt.Println(string(val2))
	} else {
		fmt.Println(string(val))
	}

	// p, s := genMap(origin1)
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		continue

	// 	}
	// 	if _, ok := s[v]; ok {
	// 		continue
	// 	}
	// 	p, s = genMap(origin2)
	// 	break
	// }
	// var val string
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		val += "P"
	// 		delete(p, v)
	// 		continue
	// 	}
	// 	if _, ok := s[v]; ok {
	// 		val += "S"
	// 		delete(s, v)
	// 		continue
	// 	}
	// }
	// fmt.Println(val)
}

// func genMap(str string) (map[string]struct{}, map[string]struct{}) {
// 	p := make(map[string]struct{})
// 	s := make(map[string]struct{})
// 	for i := 0; i < len(str)-1; i++ {
// 		p[str[:i+1]] = struct{}{}
// 		s[str[i+1:]] = struct{}{}
// 	}
// 	return p, s
// }

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	m := make([]string, 0, 2*n-2)
	var max1, max2 string
	for i := 0; i < 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		m = append(m, s)
		if len(s) > len(max1) {
			max1 = s
		} else if len(s) == len(max1) {
			max2 = s
		}
	}
	if len(max1) == 1 {
		fmt.Println("PS")
		return
	}
	var origin1, origin2 string
	origin1 = max1 + max2[len(max2)-1:]
	origin2 = max2 + max1[len(max1)-1:]
	val := check(origin1, m)
	if val == nil {
		val = check(origin2, m)
	}
	fmt.Println(string(val))
}

func check(origin string, m []string) []byte {
	var val []byte
	mp := make(map[string]struct{})
	for _, v := range m {
		if strings.HasPrefix(origin, v) && strings.HasSuffix(origin, v) {
			if _, ok := mp[v]; !ok {
				val = append(val, 'S')
			} else {
				val = append(val, 'P')
				mp[v] = struct{}{}
			}
			continue
		}
		if strings.HasPrefix(origin, v) {
			val = append(val, 'P')
			continue
		}
		if strings.HasSuffix(origin, v) {
			val = append(val, 'S')
			continue
		}
		val = nil
		break
	}
	return val
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	m := make([]string, 0, 2*n-2)
	var max1, max2 string
	for i := 0; i < 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		m = append(m, s)
		if len(s) > len(max1) {
			max1 = s
		} else if len(s) == len(max1) {
			max2 = s
		}
	}
	if len(max1) == 1 {
		fmt.Println("PS")
		return
	}
	var origin1, origin2 string
	if max1[:len(max1)-1] == max2[1:] {
		origin1 = max1[:len(max1)-1] + max2[len(max2)-2:]
	}
	if max2[:len(max1)-1] == max1[1:] {
		origin2 = max2[:len(max2)-1] + max1[len(max1)-2:]
	}
	var val []byte
	mp := make(map[string]struct{})
	for _, v := range m {
		if strings.HasPrefix(origin1, v) && strings.HasSuffix(origin1, v) {
			if _, ok := mp[v]; ok {
				val = append(val, 'S')
			} else {
				val = append(val, 'P')
				mp[v] = struct{}{}
			}
			continue
		}
		if strings.HasPrefix(origin1, v) {
			val = append(val, 'P')
			continue
		}
		if strings.HasSuffix(origin1, v) {
			val = append(val, 'S')
			continue
		}
		val = nil
		break
	}
	var val2 []byte
	mp2 := make(map[string]struct{})
	for _, v := range m {
		if strings.HasPrefix(origin2, v) && strings.HasSuffix(origin2, v) {
			if _, ok := mp2[v]; ok {
				val2 = append(val2, 'S')
			} else {
				val2 = append(val2, 'P')
				mp2[v] = struct{}{}
			}
			continue
		}
		if strings.HasPrefix(origin2, v) {
			val2 = append(val2, 'P')
			continue
		}
		if strings.HasSuffix(origin2, v) {
			val2 = append(val2, 'S')
			continue
		}
		val2 = nil
		break
	}
	if val == nil {
		fmt.Println(string(val2))
	} else {
		fmt.Println(string(val))
	}

	// p, s := genMap(origin1)
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		continue

	// 	}
	// 	if _, ok := s[v]; ok {
	// 		continue
	// 	}
	// 	p, s = genMap(origin2)
	// 	break
	// }
	// var val string
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		val += "P"
	// 		delete(p, v)
	// 		continue
	// 	}
	// 	if _, ok := s[v]; ok {
	// 		val += "S"
	// 		delete(s, v)
	// 		continue
	// 	}
	// }
	// fmt.Println(val)
}

// func genMap(str string) (map[string]struct{}, map[string]struct{}) {
// 	p := make(map[string]struct{})
// 	s := make(map[string]struct{})
// 	for i := 0; i < len(str)-1; i++ {
// 		p[str[:i+1]] = struct{}{}
// 		s[str[i+1:]] = struct{}{}
// 	}
// 	return p, s
// }

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	m := make([]string, 0, 2*n-2)
	var max1, max2 string
	for i := 0; i < 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		m = append(m, s)
		if len(s) > len(max1) {
			max1 = s
		} else if len(s) == len(max1) {
			max2 = s
		}
	}
	if len(max1) == 1 {
		fmt.Println("PS")
		return
	}
	var origin1, origin2 string
	if max1[:len(max1)-1] == max2[1:] {
		origin1 = max1[:len(max1)-1] + max2[len(max2)-2:]
	}
	if max2[:len(max1)-1] == max1[1:] {
		origin2 = max2[:len(max2)-1] + max1[len(max1)-2:]
	}
	var val []byte
	mp := []string{}
	for _, v := range m {
		if strings.HasPrefix(origin1, v) && strings.HasSuffix(origin1, v) {
			if has(v, mp) {
				val = append(val, 'S')
			} else {
				val = append(val, 'P')
				mp = append(mp, v)
			}
			continue
		}
		if strings.HasPrefix(origin1, v) {
			val = append(val, 'P')
			continue
		}
		if strings.HasSuffix(origin1, v) {
			val = append(val, 'S')
			continue
		}
		val = nil
		break
	}

	var val2 []byte
	mp2 := []string{}
	for _, v := range m {
		if strings.HasPrefix(origin2, v) && strings.HasSuffix(origin2, v) {
			if has(v, mp2) {
				val2 = append(val2, 'S')
			} else {
				val2 = append(val2, 'P')
				mp2 = append(mp2, v)
			}
			continue
		}
		if strings.HasPrefix(origin2, v) {
			val2 = append(val2, 'P')
			continue
		}
		if strings.HasSuffix(origin2, v) {
			val2 = append(val2, 'S')
			continue
		}
		val2 = nil
		break
	}
	if val == nil {
		fmt.Println(string(val2))
	} else {
		fmt.Println(string("sss"))
	}

	// p, s := genMap(origin1)
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		continue

	// 	}
	// 	if _, ok := s[v]; ok {
	// 		continue
	// 	}
	// 	p, s = genMap(origin2)
	// 	break
	// }
	// var val string
	// for _, v := range m {
	// 	if _, ok := p[v]; ok {
	// 		val += "P"
	// 		delete(p, v)
	// 		continue
	// 	}
	// 	if _, ok := s[v]; ok {
	// 		val += "S"
	// 		delete(s, v)
	// 		continue
	// 	}
	// }
	// fmt.Println(val)
}

// func genMap(str string) (map[string]struct{}, map[string]struct{}) {
// 	p := make(map[string]struct{})
// 	s := make(map[string]struct{})
// 	for i := 0; i < len(str)-1; i++ {
// 		p[str[:i+1]] = struct{}{}
// 		s[str[i+1:]] = struct{}{}
// 	}
// 	return p, s
// }

func has(s string, ss []string) bool {
	for _, v := range ss {
		if v == s {
			return true
		}
	}
	return false
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func Solve(s string, v []string, t int) (bool, string) {
	//fmt.Printf("tes=%s\n",s)
	ans := ""
	psflag := make([]int, 2*t-2)
	flag := make([]int, t)
	pos := make([]int, t)
	for i := 0; i < 2*t-2; i++ {
		p := strings.HasPrefix(s, v[i])
		s := strings.HasSuffix(s, v[i])
		lens := len(v[i])
		v := 0
		if p {
			v |= 1
		}
		if s {
			v |= 2
		}
		if flag[lens] == 0{
			flag[lens] = v
			pos[lens] = i
			continue
		}
		if (v|flag[lens]) != 3{
			return false,""
		}
		if (v|1) == 1{
			psflag[i] = 1
			psflag[pos[lens]]= 0
		}else{
			psflag[i] = 0
			psflag[pos[lens]]= 1
		}

	}
	for i := 0; i < 2*t-2; i++ {
		if psflag[i] == 1 {
			ans += "P"
		} else {
			ans += "S"
		}
	}
	return true, ans
}
func merge(a, b string) string {
	lenb := len(b)
	last := string(b[lenb-1:])
	return string(a + last)
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanf(buf, "%d\n", &t)
	v := make([]string, 2*t-2)
	ls := make([]string, 2)

	f := 0
	for i := 0; i < 2*t-2; i++ {
		fmt.Fscanf(buf, "%s\n", &v[i])
		if len(v[i]) == t-1 {
			ls[f] = string(v[i])
			f++

		}
	}
	for i := 0; i < 2; i++ {
		ok, ans := Solve(merge(ls[i], ls[i^1]), v, t)
		if ok {
			fmt.Printf("%s\n", ans)
			break;
		}
	}

}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func Solve(str string, v []string, t int) (bool, string) {
//	fmt.Printf("tes=%s\n",str)
	ans := ""
	psflag := make([]int, 2*t-2)
	flag := make([]int, t)
	pos := make([]int, t)
	for i := 0; i < 2*t-2; i++ {
		p := strings.HasPrefix(str, v[i])
		s := strings.HasSuffix(str, v[i])
		lens := len(v[i])
		vf := 0
		if p {
			vf |= 1
		}
		if s {
			vf |= 2
		}
		if vf == 0{
	//		fmt.Printf("====%s %s\n",s,v[i])
		}
		if flag[lens] == 0{
			flag[lens] = vf
			pos[lens] = i
			continue
		}
		if (vf|flag[lens]) != 3{
			return false,""
		}
		if (vf|1) == 1{
			psflag[i] = 1
			psflag[pos[lens]]= 0
	//		fmt.Printf("-->%d %d\n",i,pos[lens])
		}else{
			psflag[i] = 0
			psflag[pos[lens]]= 1
	//		fmt.Printf("----->%d %d\n",i,pos[lens])
		}

	}
	for i := 0; i < 2*t-2; i++ {
		if psflag[i] == 1 {
			ans += "P"
		} else {
			ans += "S"
		}
	}
	return true, ans
}
func merge(a, b string) string {
	lenb := len(b)
	last := string(b[lenb-1:])
	return string(a + last)
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanf(buf, "%d\n", &t)
	v := make([]string, 2*t-2)
	ls := make([]string, 2)

	f := 0
	for i := 0; i < 2*t-2; i++ {
		fmt.Fscanf(buf, "%s\n", &v[i])
		if len(v[i]) == t-1 {
			ls[f] = string(v[i])
			f++

		}
	}
	for i := 0; i < 2; i++ {
		ok, ans := Solve(merge(ls[i], ls[i^1]), v, t)
		if ok {
			fmt.Printf("%s\n", ans)
			break;
		}
	}

}
/*
5
baba
abab
a
a
ba
ab
aba
aba
*/

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	ss := make([]string, 0, 2*n-2)
	for i := 1; i <= 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		ss = append(ss, s)
	}
	fmt.Println(prefixesAndSuffixes(ss, n))
}

func prefixesAndSuffixes(ss []string, n int) string {
	fs := make([]string, 0, 2)
	for _, s := range ss {
		if len(s) == n-1 {
			fs = append(fs, s)
		}
	}
	fs[0] = fs[0] + string(fs[1][len(fs[1])-1])
	fs[1] = fs[1] + string(fs[0][len(fs[0])-1])
	if fs[0] == fs[1] {
		fs = []string{fs[0]}
	}
	var (
		res string
		m   = make(map[string]struct{})
	)
	for _, f := range fs {
		for _, s := range ss {
			switch {
			default:
				res = ""
				continue
			case strings.HasPrefix(f, s) && strings.HasSuffix(f, s):
				if _, ok := m[s]; ok {
					res += "S"
				} else {
					res += "P"
					m[s] = struct{}{}
				}
			case strings.HasPrefix(f, s):
				res += "P"
			case strings.HasSuffix(f, s):
				res += "S"
			}
		}
	}
	return res
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	ss := make([]string, 0, 2*n-2)
	for i := 1; i <= 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		ss = append(ss, s)
	}
	m := make(map[int][]string, n-1)
	for _, s := range ss {
		m[len(s)] = append(m[len(s)], s)
	}
	ns := []string{
		m[1][0] + m[n-1][0],
		m[1][0] + m[n-1][1],
		m[1][1] + m[n-1][0],
		m[1][1] + m[n-1][1],
		m[n-1][0] + m[1][0],
		m[n-1][0] + m[1][1],
		m[n-1][1] + m[1][0],
		m[n-1][1] + m[1][1],
	}
	var rs string
	for i := 1; i <= n-1; i++ {
		for _, s := range ns {
			if strings.HasPrefix(s, m[i][0]) && strings.HasSuffix(s, m[i][1]) ||
				strings.HasPrefix(s, m[i][1]) && strings.HasSuffix(s, m[i][0]) {
				rs = s
				break
			}
		}
	}
	var res string
	rm := make(map[int]int)
	for _, s := range ss {
		if strings.HasPrefix(rs, s) && strings.HasSuffix(rs, s) {
			if rm[len(s)] == 0 {
				res += "P"
				rm[len(s)]++
			} else {
				res += "S"
			}
			continue
		}
		if strings.HasPrefix(rs, s) {
			res += "P"
			continue
		}
		res += "S"
	}
	fmt.Println(res)
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanf(os.Stdin, "%d\n", &n)
	ss := make([]string, 0, 2*n-2)
	for i := 1; i <= 2*n-2; i++ {
		var s string
		fmt.Fscanf(os.Stdin, "%s\n", &s)
		ss = append(ss, s)
	}
	m := make(map[int][]string, n-1)
	for _, s := range ss {
		m[len(s)] = append(m[len(s)], s)
	}
	ns := []string{
		m[1][0] + m[n-1][0],
		m[1][0] + m[n-1][1],
		m[1][1] + m[n-1][0],
		m[1][1] + m[n-1][1],
		m[n-1][0] + m[1][0],
		m[n-1][0] + m[1][1],
		m[n-1][1] + m[1][0],
		m[n-1][1] + m[1][1],
	}
	var rs string
	for i := 1; i <= n-1; i++ {
		for _, s := range ns {
			if strings.HasPrefix(s, m[i][0]) && strings.HasSuffix(s, m[i][1]) ||
				strings.HasPrefix(s, m[i][1]) && strings.HasSuffix(s, m[i][0]) {
				rs = s
				break
			}
		}
	}
	var res string
	var isP bool
	for _, s := range ss {
		if strings.HasPrefix(rs, s) && strings.HasSuffix(rs, s) {
			if !isP {
				res += "P"
				isP = true
			} else {
				res += "S"
				isP = false
			}
			continue
		}
		if strings.HasPrefix(rs, s) {
			res += "P"
			continue
		}
		res += "S"
	}
	fmt.Println(res)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

type ss struct {
	index int
	c     string
}

func sOrP(pp, ps, s string) (isP, isS bool) {
	for i := 0; i < len(s); i++ {
		isS = s[len(s)-1-i] == ps[len(ps)-1-i]
		isP = s[i] == pp[i]
		if isS != isP {
			return
		}
	}
	return
}

func main() {
	var (
		s   [][]*ss
		res []rune
	)

	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanln(reader, &n)
	s = make([][]*ss, n)
	res = make([]rune, 2*n-2)

	for i := 0; i < 2*n-2; i++ {
		line, _ := reader.ReadString('\n')
		line = line[:len(line)-2]
		s[len(line)] = append(s[len(line)], &ss{i, line})
	}

	if s[n-1][0].c[1:] != s[n-1][1].c[:len(s[n-1][1].c)-1] {
		s[n-1][0], s[n-1][1] = s[n-1][1], s[n-1][0]
	}

	res[s[n-1][0].index] = rune('P')
	res[s[n-1][1].index] = rune('S')
	for i := n - 2; i > 0; i-- {
		if isp, _ := sOrP(s[i+1][0].c, s[i+1][1].c, s[i][0].c); !isp {
			s[i][0], s[i][1] = s[i][1], s[i][0]
		}
		res[s[i][0].index] = rune('P')
		res[s[i][1].index] = rune('S')
	}
	fmt.Println(string(res))
}

package main

import (
    "fmt"
    "bufio"
    "os"
    "sort"
)

type elem struct {
    val string
    loc int
}

func OriginString (s, t string) string {
    for i := 1; i < len(s) - 1; i++ {
        if s[i] != t[i - 1] {
            return t + string(s[len(s) - 1])
        }
    }
    return s + string(t[len(t) - 1])
}

func IsPrefix (s, orgin string) bool {
    for i := 1; i < len(s); i++ {
        if s[i] != orgin[i] {
            return false
        }
    }
    return true
}

func main() {
    stdin := bufio.NewReader(os.Stdin)

    var n int
    fmt.Fscanln(stdin, &n)

    var s []elem = make([]elem, 2*n - 2)
    var t1, t2 string = "", ""
    for i := 0; i < 2*n - 2; i++ {
        fmt.Fscanln(stdin, &s[i].val)
        s[i].loc = i
        if len(s[i].val) == n - 1 {
            if t1 == "" {
                t1 = s[i].val
            } else {
                t2 = s[i].val
            }
        }
    }

    var t string = OriginString(t1, t2)
    sort.Slice(s[:], func (i, j int) bool {
        return len(s[i].val) < len(s[j].val)
    })

    // S - 83, P - 80
    var res []byte = make([]byte, 2*n-2)
    for i := 0; i < 2*n-2; i += 2 {
        if IsPrefix(s[i].val, t) {
            res[s[i].loc] = 80
            res[s[i+1].loc] = 83
        } else {
            res[s[i].loc] = 83
            res[s[i+1].loc] = 80
        }
    }
    fmt.Println(string(res))
}

package main

import (
    "fmt"
    "bufio"
    "os"
    "sort"
)

type elem struct {
    val string
    loc int
}

func OriginString (s, t string) string {
    for i := 1; i < len(s) - 1; i++ {
        if s[i] != t[i - 1] {
            return t + string(s[len(s) - 1])
        }
    }
    return s + string(t[len(t) - 1])
}

func IsPrefix (s, orgin string) bool {
    for i := 0; i < len(s); i++ {
        if s[i] != orgin[i] {
            return false
        }
    }
    return true
}

func main() {
    stdin := bufio.NewReader(os.Stdin)

    var n int
    fmt.Fscanln(stdin, &n)

    var s []elem = make([]elem, 2*n - 2)
    var t1, t2 string = "", ""
    for i := 0; i < 2*n - 2; i++ {
        fmt.Fscanln(stdin, &s[i].val)
        s[i].loc = i
        if len(s[i].val) == n - 1 {
            if t1 == "" {
                t1 = s[i].val
            } else {
                t2 = s[i].val
            }
        }
    }

    var t string = OriginString(t1, t2)
    sort.Slice(s[:], func (i, j int) bool {
        return len(s[i].val) < len(s[j].val)
    })

    // S - 83, P - 80
    var res []byte = make([]byte, 2*n-2)
    for i := 0; i < 2*n-2; i += 2 {
        if IsPrefix(s[i].val, t) {
            res[s[i].loc] = 80
            res[s[i+1].loc] = 83
        } else {
            res[s[i].loc] = 83
            res[s[i+1].loc] = 80
        }
    }
    fmt.Println(string(res))
}

package main

import (
    "fmt"
    "bufio"
    "os"
    "sort"
)

type elem struct {
    val string
    loc int
}

func OriginString (s, t string) string {
    for i := 1; i < len(s); i++ {
        if s[i] != t[i - 1] {
            return t + string(s[len(s) - 1])
        }
    }
    return s + string(t[len(t) - 1])
}

func IsPrefix (s, orgin string) bool {
    for i := 0; i < len(s); i++ {
        if s[i] != orgin[i] {
            return false
        }
    }
    return true
}

func main() {
    stdin := bufio.NewReader(os.Stdin)

    var n int
    fmt.Fscanln(stdin, &n)

    var s []elem = make([]elem, 2*n - 2)
    var t1, t2 string = "", ""
    for i := 0; i < 2*n - 2; i++ {
        fmt.Fscanln(stdin, &s[i].val)
        s[i].loc = i
        if len(s[i].val) == n - 1 {
            if t1 == "" {
                t1 = s[i].val
            } else {
                t2 = s[i].val
            }
        }
    }

    var t string = OriginString(t1, t2)
    sort.Slice(s[:], func (i, j int) bool {
        return len(s[i].val) < len(s[j].val)
    })

    // S - 83, P - 80
    var res []byte = make([]byte, 2*n-2)
    for i := 0; i < 2*n-2; i += 2 {
        if IsPrefix(s[i].val, t) {
            res[s[i].loc] = 80
            res[s[i+1].loc] = 83
        } else {
            res[s[i].loc] = 83
            res[s[i+1].loc] = 80
        }
    }
    fmt.Println(string(res))
}

package main

import (
    "fmt"
    "bufio"
    "os"
    "sort"
)

type elem struct {
    val string
    loc int
}

func OriginString (s, t string) string {
    for i := 1; i < len(s) - 2; i++ {
        if s[i] != t[i - 1] {
            return t + string(s[len(s) - 1])
        }
    }
    return s + string(t[len(t) - 1])
}

func IsPrefix (s, orgin string) bool {
    for i := 1; i < len(s); i++ {
        if s[i] != orgin[i] {
            return false
        }
    }
    return true
}

func main() {
    stdin := bufio.NewReader(os.Stdin)

    var n int
    fmt.Fscanln(stdin, &n)

    var s []elem = make([]elem, 2*n - 2)
    var t1, t2 string = "", ""
    for i := 0; i < 2*n - 2; i++ {
        fmt.Fscanln(stdin, &s[i].val)
        s[i].loc = i
        if len(s[i].val) == n - 1 {
            if t1 == "" {
                t1 = s[i].val
            } else {
                t2 = s[i].val
            }
        }
    }

    var t string = OriginString(t1, t2)
    sort.Slice(s[:], func (i, j int) bool {
        return len(s[i].val) < len(s[j].val)
    })

    // S - 83, P - 80
    var res []byte = make([]byte, 2*n-2)
    for i := 0; i < 2*n-2; i += 2 {
        if IsPrefix(s[i].val, t) {
            res[s[i].loc] = 80
            res[s[i+1].loc] = 83
        } else {
            res[s[i].loc] = 83
            res[s[i+1].loc] = 80
        }
    }
    fmt.Println(string(res))
    //fmt.Println(s)

}

package main

import (
	"bufio"
	"os"
	"strconv"
	"strings"
)

var inp *bufio.Scanner
var out *bufio.Writer
var x int

func io() {
	inp = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
	inp.Split(bufio.ScanWords)
}

func main() {
	io()
	n := nextInt()
	a := make([]string, n<<1-2)
	var long string
	short := make([]string, 0)
	for i := 0; i < n<<1-2; i++ {
		a[i] = nextString()
		if len(a[i]) == n-1 && n != 2 {
			long = a[i]
		} else if len(a[i]) == 1 {
			short = append(short, a[i])
		}
	}

	if n == 2 {
		out.WriteString(short[0] + short[1])
		out.Flush()
		return
	}

	isPref := make([]bool, n<<1-2)

	for try := 0; try < 2; try++ {
		main : for pos := 0; pos < 2; pos++ {
			s := long
			if pos == 0 {
				s += short[try]
			} else {
				s = short[try] + s
			}
			used := make([]bool, n<<1-2)
			for i := 0; i < n-1; i++ {
				found := false
				for idx, sub := range a {
					if !used[idx] && sub == s[:i+1] {
						used[idx] = true;
						isPref[idx] = true
						found = true
						break;
					}
				}
				if !found {
					continue main
				}
			}

			for i := 0; i < n-1; i++ {
				found := false
				for idx, sub := range a {
					if !used[idx] && sub == s[n-i-1:] {
						used[idx] = true;
						isPref[idx] = false
						found = true
						break;
					}
				}
				if !found {
					continue main
				}
			}

			sb := strings.Builder{}
			for _, v := range isPref {
				if v {
					sb.WriteString("P")
				} else {
					sb.WriteString("S")
				}
			}
			out.WriteString(sb.String())
			out.Flush()
			return
		}
	}

}

func nextString() string {
	inp.Scan()
	return inp.Text();
}

func nextInt() int {
	v, _ := strconv.ParseInt(nextString(), 10, 64)
	return int(v)
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Scan(&a[i])
	}
	// "ababa"
	// n := 5
	// a := []string{
	// 	"ba",   // S
	// 	"a",    // P or S
	// 	"abab", // P
	// 	"a",    // P or S
	// 	"aba",  // P or S
	// 	"baba", // S
	// 	"ab",   // P
	// 	"aba",  // P or S
	// }
	// n := 3
	// a := []string{
	// 	"a",
	// 	"aa",
	// 	"aa",
	// 	"a",
	// }
	pair := make([]string, 0, 2)
	for i := 0; i < len(a); i++ {
		if len(a[i]) == n-1 {
			pair = append(pair, a[i])
		}
	}
	rs := make([]string, 0, 2)
	if pair[0][1:] == pair[1][0:len(pair[1])-1] {
		rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	}
	if pair[1][1:] == pair[0][0:len(pair[0])-1] {
		rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	}
	for _, t := range rs {
		if r := solve(t, a); len(r) > 0 {
			for _, s := range r {
				fmt.Print(s)
			}
			return
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc || pc == sc {
			rs[i] = "P"
			pc--
		} else {
			rs[i] = "S"
			sc--
		}
	}
	return rs
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Scan(&a[i])
	}

	// "ababa"
	// n := 5
	// a := []string{
	// 	"ba",   // S
	// 	"a",    // P or S
	// 	"abab", // P
	// 	"a",    // P or S
	// 	"aba",  // P or S
	// 	"baba", // S
	// 	"ab",   // P
	// 	"aba",  // P or S
	// }

	pair := make([]string, 0, 2)
	for i := 0; i < len(a); i++ {
		if len(a[i]) == n-1 {
			pair = append(pair, a[i])
		}
	}
	rs := make([]string, 0, 2)
	if pair[0][1:] == pair[1][0:len(pair[1])-1] {
		rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	}
	if pair[1][1:] == pair[0][0:len(pair[0])-1] {
		rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	}
	for i := range rs {
		if r := solve(rs[i], a); len(r) > 0 {
			for _, s := range r {
				fmt.Print(s)
			}
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc || pc == sc {
			rs[i] = "P"
			pc--
		} else {
			rs[i] = "S"
			sc--
		}
	}
	return rs
}

package main

import (
	"strings"
	"sort"
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]string, 2*n-2)
	for i := range a{
		fmt.Scan(&a[i])
	}
	c := make([]string, len(a))
	copy(c, a)
	r := guess(n, c)
	for _, s := range a {
		if strings.HasPrefix(r, s) {
			fmt.Print("P")
		} else {
			fmt.Print("S")
		}
	}
	fmt.Println()
}

func guess(n int, a []string) string {
	sort.Strings(a)
	g := [2][]string{}
	p := a[0]
	g[0] = append(g[0], p)
	for i:=1; i<len(a); i++ {
		if strings.HasPrefix(a[i], p) {
			g[0] = append(g[0], a[i])
		} else {
			g[1] = append(g[1], a[i])
		}
	}
	mp := g[0][len(g[0]) -  1]
	ms := g[1][len(g[1]) -  1]
	r := len(mp) + len(ms) - n
	if len(mp) <= r  || len(ms) <= r {
		return ms[:len(ms)-r] + mp
	} else if (mp[len(mp)-r:] != ms[:r]) {
		return ms[:len(ms)-r] + mp
	}
	return mp[:len(mp)-r] + ms
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Scan(&n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscanf(r, "%s\n", &a[i])
	}
	fmt.Println(a)

	// "ababa"
	// n := 5
	// a := []string{
	// 	"ba",   // S
	// 	"a",    // P or S
	// 	"abab", // P
	// 	"a",    // P or S
	// 	"aba",  // P or S
	// 	"baba", // S
	// 	"ab",   // P
	// 	"aba",  // P or S
	// }

	pair := make([]string, 0, 2)
	for i := 0; i < len(a); i++ {
		if len(a[i]) == n-1 {
			pair = append(pair, a[i])
		}
	}
	rs := make([]string, 0, 2)
	if pair[0][1:] == pair[1][0:len(pair[1])-1] {
		rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	}
	if pair[1][1:] == pair[0][0:len(pair[0])-1] {
		rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	}
	for i := range rs {
		if r := solve(rs[i], a); len(r) > 0 {
			for _, s := range r {
				fmt.Print(s)
			}
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc || pc == sc {
			rs[i] = "P"
			pc--
		} else {
			rs[i] = "S"
			sc--
		}
	}
	return rs
}

package main

import (
	"strings"
	"sort"
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]string, 2*n-2)
	for i := range a{
		fmt.Scan(&a[i])
	}
	c := make([]string, len(a))
	copy(c, a)
	r := guess(n, c)
	d := 0
	for _, s := range a {
		if strings.HasPrefix(r, s) && !strings.HasSuffix(r, s) {
			fmt.Print("P")
			d++
		} else if !strings.HasPrefix(r, s) && strings.HasSuffix(r, s) {
			fmt.Print("S")
			d--
		} else {
			if d > 0 {
				fmt.Print("S")
				d--
			} else {
				fmt.Print("P")
				d++
			}
		}
	}
	fmt.Println()
}

func guess(n int, a []string) string {
	sort.Strings(a)
	g := [2][]string{}
	p := a[0]
	g[0] = append(g[0], p)
	for i:=1; i<len(a); i++ {
		if strings.HasPrefix(a[i], p) {
			g[0] = append(g[0], a[i])
		} else {
			g[1] = append(g[1], a[i])
		}
	}
	mp := g[0][len(g[0]) -  1]
	if len(g[1]) == 0 {
		return mp
	}
	ms := g[1][len(g[1]) -  1]
	r := len(mp) + len(ms) - n
	if len(mp) <= r  || len(ms) <= r {
		return ms[:len(ms)-r] + mp
	} else if (mp[len(mp)-r:] != ms[:r]) {
		return ms[:len(ms)-r] + mp
	}
	return mp[:len(mp)-r] + ms
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanln(os.Stdin, &n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscan(os.Stdin, &a[i])
	}
	pair := make([]string, 0, 2)
	for i := 0; i < len(a); i++ {
		if len(a[i]) == n-1 {
			pair = append(pair, a[i])
		}
	}
	rs := make([]string, 0, 2)
	if pair[0][1:] == pair[1][0:len(pair[1])-1] {
		rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	}
	if pair[1][1:] == pair[0][0:len(pair[0])-1] {
		rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	}
	str := ""
	for _, t := range rs {
		if r := solve(t, a); len(r) > 0 {
			for _, s := range r {
				str += s
			}
			fmt.Println(str)
			return
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc || pc == sc {
			rs[i] = "P"
			pc--
		} else {
			rs[i] = "S"
			sc--
		}
	}
	return rs
}

package main

import (
	"os"
	"bufio"
	"strings"
	"fmt"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Scan(&n)
	a := make([]string, 2*n-2)
	for i := range a{
		fmt.Fscanf(r, "%s\n", &a[i])
	}
	c := make([]string, len(a))
	copy(c, a)
	_, g := guess(n, c)
	ps := g[0]
	for _, s := range a {
		if len(ps) <= 0 || ps[0] != s {
			fmt.Print("S")
			continue
		}
		fmt.Print("P")
		ps = ps[1:]
	}
}

func guess(n int, a []string) (string, [2][]string) {
	g := [2][]string{}
	p := a[0]
	idx := 0
	for i:=1; i<len(a); i++ {
		if len(a[i]) < len(p) {
			p = a[i]
			idx = i
		}
	}
	g[0] = append(g[0], p)
	for i, s := range a {
		if i == idx {
			continue
		}
		if isPrefix(p, s) {
			g[0] = append(g[0], s)
		} else if isSuffix(p, s) {
			g[1] = append(g[1], s)
		} else if len(g[0]) > len(g[1]) {
			g[1] = append(g[1], s)
		} else {
			g[0] = append(g[0], s)
		}
	}
	mp := g[0][len(g[0]) -  1]
	ms := g[1][len(g[1]) -  1]
	r := len(mp) + len(ms) - n
	if len(mp) <= r  || len(ms) <= r || mp[len(mp)-r:] != ms[:r] {
		g[0], g[1] = g[1], g[0]
		return ms[:len(ms)-r] + mp, g
	}
	return mp[:len(mp)-r] + ms, g
}

func isPrefix(p, q string) bool {
	if len(p) > len(q) {
		return strings.HasPrefix(p, q) && !strings.HasSuffix(p, q)
	}
	return strings.HasPrefix(q, p) && !strings.HasSuffix(q, p)
}

func isSuffix(p, q string) bool {
	if len(p) > len(q) {
		return strings.HasSuffix(p, q) && !strings.HasPrefix(p, q)
	}
	return strings.HasSuffix(q, p) && !strings.HasPrefix(q, p)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Scan(&n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscanf(r, "%s\n", &a[i])
	}

	// "ababa"
	// n := 5
	// a := []string{
	// 	"ba",   // S
	// 	"a",    // P or S
	// 	"abab", // P
	// 	"a",    // P or S
	// 	"aba",  // P or S
	// 	"baba", // S
	// 	"ab",   // P
	// 	"aba",  // P or S
	// }

	// n := 2
	// a := []string{
	// 	"a",
	// 	"c",
	// }

	// n := 3
	// a := []string{
	// 	"a",
	// 	"aa",
	// 	"aa",
	// 	"a",
	// }

	pair := make([]string, 0, 2)
	for i := 0; i < len(a); i++ {
		if len(a[i]) == n-1 {
			pair = append(pair, a[i])
		}
	}
	rs := make([]string, 0, 2)
	if pair[0][1:] == pair[1][0:len(pair[1])-1] {
		rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	}
	if pair[1][1:] == pair[0][0:len(pair[0])-1] {
		rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	}
	for i := range rs {
		if r := solve(rs[i], a); len(r) > 0 {
			for _, s := range r {
				fmt.Print(s)
			}
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc || pc == sc {
			rs[i] = "P"
			pc--
		} else {
			rs[i] = "S"
			sc--
		}
	}
	return rs
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanln(os.Stdin, &n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscan(os.Stdin, &a[i])
	}
	pair := make([]string, 0, 2)
	for _, s := range a {
		if len(s) == n-1 {
			pair = append(pair, s)
		}
	}
	rs := make([]string, 0, 2)
	rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	str := ""
	for _, t := range rs {
		if r := solve(t, a); len(r) > 0 {
			for _, s := range r {
				str += s
			}
			fmt.Println(str)
			return
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc {
			rs[i] = "S"
			pc--
		} else {
			rs[i] = "P"
			sc--
		}
	}
	return rs
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanln(os.Stdin, &n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscan(os.Stdin, &a[i])
	}
	pair := make([]string, 0, 2)
	for _, s := range a {
		if len(s) == n-1 {
			pair = append(pair, s)
		}
	}
	rs := make([]string, 2)
	rs[0] = pair[0] + pair[1][len(pair[1])-1:]
	rs[1] = pair[1] + pair[0][len(pair[0])-1:]
	for _, t := range rs {
		if r := solve(t, a); len(r) > 0 {
			fmt.Println(string(r))
			return
		}
	}
}

func solve(r string, a []string) []byte {
	rs := make([]byte, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = 'P'
			pc++
		} else {
			rs[i] = 'S'
			sc++
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc {
			rs[i] = 'S'
			sc++
		} else {
			rs[i] = 'P'
			pc++
		}
	}
	if sc != pc {
		return nil
	}
	return rs
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	stdin := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanln(stdin, &n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscanln(stdin, &a[i])
	}
	// "ababa"
	// n := 5
	// a := []string{
	// 	"ba",   // S
	// 	"a",    // P or S
	// 	"abab", // P
	// 	"a",    // P or S
	// 	"aba",  // P or S
	// 	"baba", // S
	// 	"ab",   // P
	// 	"aba",  // P or S
	// }
	// n := 3
	// a := []string{
	// 	"a",
	// 	"aa",
	// 	"aa",
	// 	"a",
	// }
	pair := make([]string, 0, 2)
	for i := 0; i < len(a); i++ {
		if len(a[i]) == n-1 {
			pair = append(pair, a[i])
		}
	}
	rs := make([]string, 0, 2)
	if pair[0][1:] == pair[1][0:len(pair[1])-1] {
		rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	}
	if pair[1][1:] == pair[0][0:len(pair[0])-1] {
		rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	}
	for _, t := range rs {
		if r := solve(t, a); len(r) > 0 {
			for _, s := range r {
				fmt.Print(s)
			}
			return
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc {
			rs[i] = "P"
			pc--
		} else {
			rs[i] = "S"
			sc--
		}
	}
	return rs
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanln(os.Stdin, &n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscan(os.Stdin, &a[i])
	}
	pair := make([]string, 0, 2)
	for _, s := range a {
		if len(s) == n-1 {
			pair = append(pair, s)
		}
	}
	rs := make([]string, 0, 2)
	rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	for _, t := range rs {
		if r := solve(t, a); len(r) > 0 {
			fmt.Println(string(r))
			return
		}
	}
}

func solve(r string, a []string) []byte {
	rs := make([]byte, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = 'P'
			pc++
		} else {
			rs[i] = 'S'
			sc++
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc {
			rs[i] = 'S'
			sc++
		} else {
			rs[i] = 'P'
			pc++
		}
	}
	if sc != pc {
		return nil
	}
	return rs
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	stdin := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanln(stdin, &n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscanln(stdin, &a[i])
	}
	// "ababa"
	// n := 5
	// a := []string{
	// 	"ba",   // S
	// 	"a",    // P or S
	// 	"abab", // P
	// 	"a",    // P or S
	// 	"aba",  // P or S
	// 	"baba", // S
	// 	"ab",   // P
	// 	"aba",  // P or S
	// }
	// n := 3
	// a := []string{
	// 	"a",
	// 	"aa",
	// 	"aa",
	// 	"a",
	// }
	pair := make([]string, 0, 2)
	for i := 0; i < len(a); i++ {
		if len(a[i]) == n-1 {
			pair = append(pair, a[i])
		}
	}
	rs := make([]string, 0, 2)
	if pair[0][1:] == pair[1][0:len(pair[1])-1] {
		rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	}
	if pair[1][1:] == pair[0][0:len(pair[0])-1] {
		rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	}
	str := ""
	for _, t := range rs {
		if r := solve(t, a); len(r) > 0 {
			for _, s := range r {
				str += s
			}
			fmt.Println(str)
			return
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc || pc == sc {
			rs[i] = "P"
			pc--
		} else {
			rs[i] = "S"
			sc--
		}
	}
	return rs
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanln(os.Stdin, &n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscan(os.Stdin, &a[i])
	}
	pair := make([]string, 0, 2)
	for _, s := range a {
		if len(s) == n-1 {
			pair = append(pair, s)
		}
	}
	rs := make([]string, 0, 2)
	rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	for _, t := range rs {
		if r := solve(t, a); len(r) > 0 {
			fmt.Println(string(r))
			return
		}
	}
}

func solve(r string, a []string) []byte {
	rs := make([]byte, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = 'P'
			pc++
		} else if is && !ip {
			rs[i] = 'S'
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc {
			rs[i] = 'S'
			sc++
		} else {
			rs[i] = 'P'
			pc++
		}
	}
	if sc != pc {
		return nil
	}
	return rs
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Scan(&a[i])
	}

	// "ababa"
	// n := 5
	// a := []string{
	// 	"ba",   // S
	// 	"a",    // P or S
	// 	"abab", // P
	// 	"a",    // P or S
	// 	"aba",  // P or S
	// 	"baba", // S
	// 	"ab",   // P
	// 	"aba",  // P or S
	// }
	// n := 3
	// a := []string{
	// 	"a",
	// 	"aa",
	// 	"aa",
	// 	"a",
	// }
	pair := make([]string, 0, 2)
	for i := 0; i < len(a); i++ {
		if len(a[i]) == n-1 {
			pair = append(pair, a[i])
		}
	}
	rs := make([]string, 0, 2)
	if pair[0][1:] == pair[1][0:len(pair[1])-1] {
		rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	}
	if pair[1][1:] == pair[0][0:len(pair[0])-1] {
		rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	}
	for i := range rs {
		if r := solve(rs[i], a); len(r) > 0 {
			for _, s := range r {
				fmt.Print(s)
			}
			return
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc || pc == sc {
			rs[i] = "P"
			pc--
		} else {
			rs[i] = "S"
			sc--
		}
	}
	return rs
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanln(os.Stdin, &n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscan(os.Stdin, &a[i])
	}
	pair := make([]string, 0, 2)
	for _, s := range a {
		if len(s) == n-1 {
			pair = append(pair, s)
		}
	}
	rs := make([]string, 0, 2)
	rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	str := ""
	for _, t := range rs {
		if r := solve(t, a); len(r) > 0 {
			for _, s := range r {
				str += s
			}
			fmt.Println(str)
			return
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc {
			rs[i] = "S"
			sc++
		} else {
			rs[i] = "P"
			pc++
		}
	}
	if sc != pc {
		return nil
	}
	return rs
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanln(os.Stdin, &n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscanf(os.Stdin, "%s\n", &a[i])
	}
	pq := make([]string, 0, 2)
	for _, s := range a {
		if len(s) == n-1 {
			pq = append(pq, s)
		}
	}
	rs := []string{
		pq[0] + pq[1][len(pq[1])-1:],
		pq[1] + pq[0][len(pq[0])-1:],
	}
	for _, s := range rs {
		if str := solve(s, a); str != "" {
			fmt.Println(str)
			return
		}
	}
}

func solve(r string, a []string) string {
	var (
		rs = make([]byte, len(a))
		ti = make([]int, 0, len(a))
		pc int
		sc int
	)
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return ""
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = 'P'
			pc++
		} else if is && !ip {
			rs[i] = 'S'
			sc++
		}
	}
	if len(ti) != len(a)-pc-sc {
		return ""
	}
	for _, i := range ti {
		if pc > sc {
			rs[i] = 'S'
			sc++
		} else {
			rs[i] = 'P'
			pc++
		}
	}
	return string(rs)
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanln(os.Stdin, &n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscanf(os.Stdin, "%s\n", &a[i])
	}
	pair := make([]string, 0, 2)
	for _, s := range a {
		if len(s) == n-1 {
			pair = append(pair, s)
		}
	}
	rs := make([]string, 2)
	rs[0] = pair[0] + pair[1][len(pair[1])-1:]
	rs[1] = pair[1] + pair[0][len(pair[0])-1:]
	for _, s := range rs {
		if r := solve(s, a); len(r) > 0 {
			fmt.Println(string(r))
			return
		}
	}
}

func solve(r string, a []string) []byte {
	rs := make([]byte, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = 'P'
			pc++
		} else {
			rs[i] = 'S'
			sc++
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc {
			rs[i] = 'S'
			sc++
		} else {
			rs[i] = 'P'
			pc++
		}
	}
	if sc != pc {
		return nil
	}
	return rs
}

package main

import (
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Fscanln(os.Stdin, &n)
	a := make([]string, 2*n-2)
	for i := range a {
		fmt.Fscan(os.Stdin, &a[i])
	}
	pair := make([]string, 0, 2)
	for _, s := range a {
		if len(s) == n-1 {
			pair = append(pair, s)
		}
	}
	rs := make([]string, 0, 2)
	rs = append(rs, pair[0]+pair[1][len(pair[1])-1:])
	rs = append(rs, pair[1]+pair[0][len(pair[0])-1:])
	str := ""
	for _, t := range rs {
		if r := solve(t, a); len(r) > 0 {
			for _, s := range r {
				str += s
			}
			fmt.Println(str)
			return
		}
	}
}

func solve(r string, a []string) []string {
	rs := make([]string, len(a))
	ti := make([]int, 0, len(a))
	pc := 0
	sc := 0
	for i, s := range a {
		ip := strings.HasPrefix(r, s)
		is := strings.HasSuffix(r, s)
		if !ip && !is {
			return nil
		}
		if ip && is {
			ti = append(ti, i)
		} else if ip && !is {
			rs[i] = "P"
			pc++
		} else if is && !ip {
			rs[i] = "S"
			sc++
		} else {
			return nil
		}
	}
	if len(ti) != len(a)-pc-sc {
		return nil
	}
	for _, i := range ti {
		if pc > sc || pc == sc {
			rs[i] = "S"
			pc--
		} else {
			rs[i] = "P"
			sc--
		}
	}
	return rs
}