Edo has got a collection of n refrigerator magnets!He decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door must be rectangle, and both the length and the width of the door must be positive integers.Edo figured out how he wants to place the magnets on the refrigerator. He introduced a system of coordinates on the plane, where each magnet is represented as a rectangle with sides parallel to the coordinate axes.Now he wants to remove no more than k magnets (he may choose to keep all of them) and attach all remaining magnets to the refrigerator door, and the area of the door should be as small as possible. A magnet is considered to be attached to the refrigerator door if its center lies on the door or on its boundary. The relative positions of all the remaining magnets must correspond to the plan.Let us explain the last two sentences. Let's suppose we want to hang two magnets on the refrigerator. If the magnet in the plan has coordinates of the lower left corner (x1, y1) and the upper right corner (x2, y2), then its center is located at (, ) (may not be integers). By saying the relative position should correspond to the plan we mean that the only available operation is translation, i.e. the vector connecting the centers of two magnets in the original plan, must be equal to the vector connecting the centers of these two magnets on the refrigerator.The sides of the refrigerator door must also be parallel to coordinate axes.

The first line contains two integers n and k (1 ≤ n ≤ 100 000, 0 ≤ k ≤ min(10, n - 1)) — the number of magnets that Edo has and the maximum number of magnets Edo may not place on the refrigerator. Next n lines describe the initial plan of placing magnets. Each line contains four integers x1, y1, x2, y2 (1 ≤ x1 < x2 ≤ 109, 1 ≤ y1 < y2 ≤ 109) — the coordinates of the lower left and upper right corners of the current magnet. The magnets can partially overlap or even fully coincide.

Print a single integer — the minimum area of the door of refrigerator, which can be used to place at least n - k magnets, preserving the relative positions.

NoteIn the first test sample it is optimal to remove either the first or the third magnet. If we remove the first magnet, the centers of two others will lie at points (2.5, 2.5) and (3.5, 3.5). Thus, it is enough to buy a fridge with door width 1 and door height 1, the area of the door also equals one, correspondingly.In the second test sample it doesn't matter which magnet to remove, the answer will not change — we need a fridge with door width 8 and door height 8.In the third sample you cannot remove anything as k = 0.

open Printf
open Scanf

let rec fold i j f init = if i>j then init else fold (i+1) j f (f i init)
let minf i j f = fold (i+1) j (fun k a -> min (f k) a) (f i)
let maxf i j f = fold (i+1) j (fun k a -> max (f k) a) (f i)

let ( ** ) a b = Int64.mul a b
let long x = Int64.of_int x

let read_int () = bscanf Scanning.stdib " %d " (fun x -> x)
let read4 () = bscanf Scanning.stdib " %f %f %f %f " (fun a b c d -> (a,b,c,d))

let () =
  let n = read_int () in
  let k = read_int () in
  let center = Array.make n (0.0, 0.0) in

  for i=0 to n-1 do
    let (x1,y1,x2,y2) = read4() in
    center.(i) <- ((x1+.x2)/.2.0, (y1+.y2)/.2.0)
  done;

  let x1 = Array.init n (fun i -> i) in
  let y1 = Array.copy x1 in

  Array.sort (fun i j -> compare (fst center.(i)) (fst center.(j))) x1;
  Array.sort (fun i j -> compare (snd center.(i)) (snd center.(j))) y1;
  let x2 = Array.init n (fun i -> x1.(n-1-i)) in
  let y2 = Array.init n (fun i -> y1.(n-1-i)) in

  (* partition k into four parts in all possible ways *)

  let c = Array.make 4 0 in

  let inset i s = List.exists (( = ) i) s in

  let rec score c =
    let rec buildused a j c used = if c=0 then used else
	if inset a.(j) used then (
	  buildused a (j+1) c used
	) else (
	  buildused a (j+1) (c-1) (a.(j)::used)
	)
    in
    let rec fu a used i =  (* first unused *)
      if not (inset a.(i) used) then a.(i)
      else fu a used (i+1)
    in
    let u = buildused x1 0 c.(0) [] in
    let u = buildused y1 0 c.(1) u in
    let u = buildused x2 0 c.(2) u in
    let u = buildused y2 0 c.(3) u in
    let ind = [|fu x1 u 0; fu y1 u 0; fu x2 u 0; fu y2 u 0|] in
    let maxx = maxf 0 3 (fun i -> fst center.(ind.(i))) in
    let minx = minf 0 3 (fun i -> fst center.(ind.(i))) in
    let maxy = maxf 0 3 (fun i -> snd center.(ind.(i))) in
    let miny = minf 0 3 (fun i -> snd center.(ind.(i))) in
    let round z = if z=0.0 then 1L else Int64.of_float (ceil z) in
    (round (maxx -. minx)) ** (round (maxy -. miny))
  in

  let rec part4 i n = if i=3 then (
    c.(3) <- n;
    score c
  ) else (
    minf 0 n (fun v -> c.(i) <- v; part4 (i+1) (n-v))
  )
  in

  printf "%Ld\n" (part4 0 k)


Iahub and Iahubina went to a date at a luxury restaurant. Everything went fine until paying for the food. Instead of money, the waiter wants Iahub to write a Hungry sequence consisting of n integers. A sequence a1, a2, ..., an, consisting of n integers, is Hungry if and only if:   Its elements are in increasing order. That is an inequality ai < aj holds for any two indices i, j (i < j).  For any two indices i and j (i < j), aj must not be divisible by ai. Iahub is in trouble, so he asks you for help. Find a Hungry sequence with n elements.

The input contains a single integer: n (1 ≤ n ≤ 105).

Output a line that contains n space-separated integers a1 a2, ..., an (1 ≤ ai ≤ 107), representing a possible Hungry sequence. Note, that each ai must not be greater than 10000000 (107) and less than 1. If there are multiple solutions you can output any one.

let trim (line: string) =
	(* trim leading white space *)
	let line = Str.replace_first (Str.regexp "^[ \t\n\r]+") "" line in
	(* trim trailing white space *)
	let line = Str.replace_first (Str.regexp "[ \t\n\r]+$") "" line in
	line
;;

let ints_of_string (line: string) =
	Array.of_list (List.map int_of_string (Str.split (Str.regexp " ") (trim line)))
;;

let solve (a: int array) =
	let n = Array.length a in
	let b = Array.create (1+n) 0 in
	b.(1) <- a.(0);
	for i=2 to n do
		b.(i) <- b.(i-1) + a.(i-1)
	done;
	let sum i j = b.(j) - b.(i-1) in
	(*Printf.printf "n = %d\n" n;
	for i=0 to n do
		Printf.printf "%d " b.(i)
	done;
*)
	let best = ref 0 in
	for i=1 to n do
		for j=i to n do
			let tmp =
				b.(i-1) +
				(j-i+1) - (b.(j) - b.(i-1)) +
				b.(n)-b.(j)
			in
			if tmp > !best then
				best := !best + 1
		done;
	done;
	Printf.printf "%d\n" !best
;;

let _ =
	let n = int_of_string (read_line()) in
	for i=n to n+n-1 do
		Printf.printf "%d " i
	done;

(* Codeforces contest 327B - hungry seq *)

open Filename;;

(* you can use either gr or rdln but not both *)
let use_input_txt = false;;
let fn = (Filename.dirname Filename.current_dir_name);;
let filename = Filename.concat "." "input.txt";;
let cin = if use_input_txt then Scanf.Scanning.open_in filename
	else Scanf.Scanning.stdin;;

let cout = open_out "output.txt";;
let gr () = Scanf.bscanf cin " %d" (fun i -> i);;
let grf () = Scanf.scanf " %f" (fun i -> i);;
let grl () = Scanf.scanf " %Ld" (fun i -> i);;
let rdln() = input_line Pervasives.stdin;;
(* let spli s = Str.split (Str.regexp " ") s;; *)
let printlisti li = List.iter (fun i -> (print_int i; print_string " ")) li;;
let printlisti64 li = List.iter (fun i -> (print_string (Int64.to_string i); print_string " ")) li;;
let printarri ai = Array.iter (fun i -> (print_int i; print_string " ")) ai;;
let rec readlist n acc = match n with | 0 -> List.rev acc | _ -> readlist (n -1) (gr() :: acc);;
let rec readpairs n acc = match n with
	| 0 -> List.rev acc
	| _ -> readpairs
				(n -1)
				(
					let a = gr() in
					let b = gr() in
					(* let _ = Printf.printf "a,b = %d %d\n" a b in *)
					(a, b) :: acc
				);;
let debug = false;;

let n = gr();;  (* number of test data *)

let printseq n =
	for i = n +5 to n + 4 + n do
		( print_int i; print_string " " )
	done;;

let main() =
	printseq n;;

main();;


Max wants to buy a new skateboard. He has calculated the amount of money that is needed to buy a new skateboard. He left a calculator on the floor and went to ask some money from his parents. Meanwhile his little brother Yusuf came and started to press the keys randomly. Unfortunately Max has forgotten the number which he had calculated. The only thing he knows is that the number is divisible by 4.You are given a string s consisting of digits (the number on the display of the calculator after Yusuf randomly pressed the keys). Your task is to find the number of substrings which are divisible by 4. A substring can start with a zero.A substring of a string is a nonempty sequence of consecutive characters.For example if string s is 124 then we have four substrings that are divisible by 4: 12, 4, 24 and 124. For the string 04 the answer is three: 0, 4, 04.As input/output can reach huge size it is recommended to use fast input/output methods: for example, prefer to use gets/scanf/printf instead of getline/cin/cout in C++, prefer to use BufferedReader/PrintWriter instead of Scanner/System.out in Java.

The only line contains string s (1 ≤ |s| ≤ 3·105). The string s contains only digits from 0 to 9.

Print integer a — the number of substrings of the string s that are divisible by 4. Note that the answer can be huge, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.

let (+|) = Int64.add
let (-|) = Int64.sub
let ( *| ) = Int64.mul
let ( /| ) = Int64.div

let _ =
  let sb = Scanf.Scanning.stdib in
  let s = Scanf.bscanf sb "%s " (fun s -> s) in
  let n = String.length s in
  let c2i c = Char.code c - Char.code '0' in
  let res = ref 0L in
    for i = 1 to n - 1 do
      if (c2i s.[i - 1] * 10 + c2i s.[i]) mod 4 = 0
      then res := !res +| Int64.of_int i;
    done;
    for i = 0 to n - 1 do
      if c2i s.[i] mod 4 = 0
      then res := !res +| 1L;
    done;
    Printf.printf "%Ld\n" !res


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.

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module Int64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  let pow n k =
    let rec f a n = function
    | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)
    in f 1L n k
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let iia = input_i64_array
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let gi = get_i64
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let g2 = get_2_i64
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let g3 = get_3_i64
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let g4 = get_4_i64
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let slen = String.length
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array
let prefix s t =
  let f = ref true in
  repi 0 (String.length t-$1) (fun j ->
    (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
    if s.[j] <> t.[j] then f:=false
  ); !f
let suffix s t =
  let f = ref true in
  let d = String.length t-$1 in
  repi 0 d (fun j ->
    (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
    if s.[String.length s-$1-$d+$j] <> t.[j] then f:=false
  ); !f
let () =
  let n = gi 0 in let n = i32 n in let m = 2*$n-$2 in
  let a = init m (fun _ -> scanf " %s" @@ id) in
  let len = make n [] in
  let unz = make n [] in
  iteri (fun i v ->
    len.(slen v) <- v :: len.(slen v);
    unz.(slen v) <- i :: unz.(slen v)
  ) a;
  let res = make m '_' in
  let p0,q0 = match len.(n-$1) with [p;q] -> p,q | _ -> fail 0 in
  let gen_str p q =
    p ^ (String.make 1 q.[n-$2])
  in
  let solve str =
    (* printf "%s::\n" str; *)
    let f = ref true in
    repi_rev (n-$1) 1 (fun i ->
      let p,q = match len.(i) with [p;q] -> p,q | _ -> fail 0 in
      let u,v = match unz.(i) with [p;q] -> p,q | _ -> fail 0 in
      (* printf "  %s:%d; %s:%d\n" p u q v; *)
      if prefix str p && suffix str q then (
        res.(u) <- 'P';
        res.(v) <- 'S';
      ) else if suffix str p && prefix str q then (
        res.(u) <- 'S';
        res.(v) <- 'P';
      ) else f := false
    );
    if !f then (
      iter print_char res; exit 0
    )
  in
  solve (gen_str p0 q0);
  solve (gen_str q0 p0);

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module Int64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  let pow n k =
    let rec f a n = function
    | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)
    in f 1L n k
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let iia = input_i64_array
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let gi = get_i64
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let g2 = get_2_i64
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let g3 = get_3_i64
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let g4 = get_4_i64
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let slen = String.length
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array
let prefix s t =
  String.(sub s 0 (length t)) = t
  (* let f = ref true in
  repi 0 (String.length t-$1) (fun j ->
    (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
    if s.[j] <> t.[j] then f:=false
  ); !f *)
let suffix s t =
  String.(sub s ((length s -$ 1) -$ (length t -$ 1)) (length t)) = t
  (* let f = ref true in
  let d = String.length t-$1 in
  repi 0 d (fun j ->
    (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
    if s.[String.length s-$1-$d+$j] <> t.[j] then f:=false
  ); !f *)
let () =
  let n = gi 0 in let n = i32 n in let m = 2*$n-$2 in
  let a = init m (fun _ -> scanf " %s" @@ id) in
  let len = make n [] in
  let unz = make n [] in
  iteri (fun i v ->
    len.(slen v) <- v :: len.(slen v);
    unz.(slen v) <- i :: unz.(slen v)
  ) a;
  let res = make m '_' in
  let p0,q0 = match len.(n-$1) with [p;q] -> p,q | _ -> fail 0 in
  let gen_str p q =
    p ^ (String.make 1 q.[n-$2])
  in
  let solve str =
    (* printf "%s::\n" str; *)
    let f = ref true in
    repi_rev (n-$1) 1 (fun i ->
      let p,q = match len.(i) with [p;q] -> p,q | _ -> fail 0 in
      let u,v = match unz.(i) with [p;q] -> p,q | _ -> fail 0 in
      (* printf "  %s:%d; %s:%d\n" p u q v; *)
      if prefix str p && suffix str q then (
        res.(u) <- 'P';
        res.(v) <- 'S';
      ) else if suffix str p && prefix str q then (
        res.(u) <- 'S';
        res.(v) <- 'P';
      ) else f := false
    );
    if !f then (
      iter print_char res; exit 0
    )
  in
  solve (gen_str p0 q0);
  solve (gen_str q0 p0);

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module Int64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  let pow n k =
    let rec f a n = function
    | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)
    in f 1L n k
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let iia = input_i64_array
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let gi = get_i64
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let g2 = get_2_i64
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let g3 = get_3_i64
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let g4 = get_4_i64
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let n = gi 0 in
  let a = init (i32 @@ 2L*n-2L) (fun _ -> scanf " %s" @@ id) in
  let aa = init (i32 @@ 2L*n-2L) (fun i -> a.(i)) in
  sort (fun u v -> -compare (String.length u) (String.length v)) aa;
  let str = aa.(0) ^ (String.make 1 aa.(1).[i32 n-$2]) in
  let ff = ref true in
  repi 1 (i32 n-$2) (fun i ->
    if aa.(0).[i] <> aa.(1).[i-$1] then ff := false
  );
  let res = make (i32 @@ 2L*n-2L) '_' in
  (* print_endline str; *)
  if !ff then (
    repi 0 (i32 @@ 2L*n-3L) (fun i ->
      let f = ref true in
      (* P *)
      (* printf "  %d\n" i; *)
      repi 0 (String.length a.(i)-$1) (fun j ->
        (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
        if str.[j] <> a.(i).[j] then f:=false
      );
      if !f then (
        res.(i) <- 'P'
      ) else (
        let f = ref true in
        let d = String.length a.(i)-$1 in
        repi 0 d (fun j ->
          (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
          if str.[i32 n-$d+$j-$1] <> a.(i).[j] then f:=false
        );
        (* printf "  -> %b\n" !f; *)
        if !f then (
          res.(i) <- 'S'
        ) else ff := false
      )
    );
    if !ff then (
      (* print_array (String.make 1) res; *)
      iter (fun c -> printf "%c" c) res;
      exit 0
    )
  );
  (* let str = (String.make 1 a.(0).[0]) ^ a.(1) in *)
  let str = aa.(1) ^ (String.make 1 aa.(0).[i32 n-$2]) in
  let ff = ref true in
  repi 1 (i32 n-$2) (fun i ->
    if aa.(1).[i] <> aa.(0).[i-$1] then ff := false
  );
  (* print_endline str; *)
  if !ff then (
    repi 0 (i32 @@ 2L*n-3L) (fun i ->
      let f = ref true in
      (* P *)
      (* printf "  %d\n" i; *)
      repi 0 (String.length a.(i)-$1) (fun j ->
        (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
        if str.[j] <> a.(i).[j] then f:=false
      );
      if !f then (
        res.(i) <- 'P'
      ) else (
        let f = ref true in
        let d = String.length a.(i)-$1 in
        repi 0 d (fun j ->
          (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
          if str.[i32 n-$d+$j-$1] <> a.(i).[j] then f:=false
        );
        (* printf "  -> %b\n" !f; *)
        if !f then (
          res.(i) <- 'S'
        ) else ff := false
      )
    );
    if !ff then (
      (* print_array (String.make 1) res; *)
      iter (fun c -> printf "%c" c) res;
      exit 0
    )
  );
  raise Not_found

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module Int64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  let pow n k =
    let rec f a n = function
    | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)
    in f 1L n k
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let iia = input_i64_array
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let gi = get_i64
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let g2 = get_2_i64
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let g3 = get_3_i64
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let g4 = get_4_i64
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let prefix s t =
  let f = ref true in
  repi 0 (String.length t-$1) (fun j ->
    (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
    if s.[j] <> t.[j] then f:=false
  ); !f
let suffix s t =
  let f = ref true in
  let d = String.length t-$1 in
  repi 0 d (fun j ->
    (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
    if s.[String.length s-$1-$d+$j] <> t.[j] then f:=false
  ); !f

let () =
  let n = gi 0 in
  let a = init (i32 @@ 2L*n-2L) (fun _ -> scanf " %s" @@ id) in
  let aa = init (i32 @@ 2L*n-2L) (fun i -> a.(i),i) in
  sort (fun (u,i) (v,j) -> -compare (String.length u) (String.length v)) aa;
  let m = i32 @@ 2L*n -2L in
  (* print_array (fun (c,i) -> sprintf "%s#%d" c i) aa; *)
  let zip = make m 0 in
  let unzip = make (m) 0 in
  iteri (fun i (_,j) -> zip.(i) <- j; unzip.(j) <- i) aa;
  let a0,a1 = fst aa.(0),fst aa.(1) in
  let arr0 = a in
  let a = map (fun (v,i) -> v) aa in
  let res = make (i32 @@ 2L*n-2L) ('_',0) in
  (* print_array id a; *)

  let str = a0 ^ (String.make 1 a1.[i32 n-$2]) in
  let ff = ref true in
  repi 1 (i32 n-$2) (fun i ->
    if a0.[i] <> a1.[i-$1] then ff := false
  );
  (* print_endline str; *)
  rep 0L (i64 m/2L-1L) (fun i ->
    let i = i32 @@ i * 2L in
    let u,v = a.(i),a.(i+$1) in
    (* printf "  %s %s\n" u v; *)
    let p,q,r,s = prefix str u,prefix str v,suffix str u,suffix str v in
    if p && s then (
      res.(i) <- ('P',i);
      res.(i+$1) <- ('S',i+$1);
    ) else if q && r then (
      res.(i) <- ('S',i);
      res.(i+$1) <- ('P',i+$1);
    ) else ff := false
  );
  if !ff then (
    let ress = make m 'x' in
    iter (fun (c,i) -> ress.(zip.(i)) <- c) res;
    iter (fun c -> printf "%c" c) ress;
    exit 0;
  );
  let a0,a1 = a1,a0 in
  let str = a0 ^ (String.make 1 a1.[i32 n-$2]) in
  let ff = ref true in
  repi 1 (i32 n-$2) (fun i ->
    if a0.[i] <> a1.[i-$1] then ff := false
  );
  (* print_endline str; *)
  rep 0L (i64 m/2L) (fun i ->
    let i = i32 i in
    let u,v = a.(i),a.(i+$1) in
    let p,q,r,s = prefix str u,prefix str v,suffix str u,suffix str v in
    if p && s then (
      res.(i) <- ('P',i);
      res.(i+$1) <- ('S',i+$1);
    ) else if q && r then (
      res.(i) <- ('S',i);
      res.(i+$1) <- ('P',i+$1);
    ) else ff := false
  );
  if !ff then (
    let ress = make m 'x' in
    iter (fun (c,i) -> ress.(zip.(i)) <- c) res;
    iter (fun c -> printf "%c" c) ress;
    exit 0;
  );

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module Int64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  let pow n k =
    let rec f a n = function
    | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)
    in f 1L n k
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let iia = input_i64_array
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let gi = get_i64
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let g2 = get_2_i64
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let g3 = get_3_i64
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let g4 = get_4_i64
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let n = gi 0 in
  let a = init (i32 @@ 2L*n-2L) (fun _ -> scanf " %s" @@ id) in
  let aa = init (i32 @@ 2L*n-2L) (fun i -> a.(i),i) in
  sort (fun (u,i) (v,j) -> -compare (String.length u) (String.length v)) aa;
  let m = i32 @@ 2L*n -2L in
  let zip = make m 0 in
  let unz = make (m) 0 in
  iteri (fun i (_,j) -> zip.(i) <- j; unz.(j) <- i) aa;
  let a0,a1 = fst aa.(0),fst aa.(1) in
  let arr0 = a in
  let a = map (fun (v,i) -> v) aa in
  let ffff = ref false in
  let res = make (i32 @@ 2L*n-2L) '_' in

  let str = a0 ^ (String.make 1 a1.[i32 n-$2]) in
  let ff = ref true in
  repi 1 (i32 n-$2) (fun i ->
    if a0.[i] <> a1.[i-$1] then ff := false
  );
  (* print_endline str; *)
  let s,p = ref (i32 n-$1),ref (i32 n-$1) in
  if !ff then (
    repi 0 (i32 @@ 2L*n-3L) (fun i ->
      let f = ref true in
      (* P *)
      (* printf "  %d\n" i; *)
      repi 0 (String.length a.(i)-$1) (fun j ->
        (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
        if str.[j] <> a.(i).[j] then f:=false
      );
      if !p > 0 && !f then (
        res.(i) <- 'P'; p:=!p-$1
      ) else (
        let f = ref true in
        let d = String.length a.(i)-$1 in
        repi 0 d (fun j ->
          (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
          if str.[i32 n-$d+$j-$1] <> a.(i).[j] then f:=false
        );
        (* printf "  -> %b\n" !f; *)
        if !f then (
          res.(i) <- 'S'; s := !s -$ 1
        ) else ff := false
      )
    );
    if !ff then (
      (* print_array (String.make 1) res; *)
      iter (fun c -> printf "%c" c) res;
      print_newline ();
      (* exit 0 *)
      ffff := true;
    )
  );
  if not !ffff then (
  (* let str = (String.make 1 a.(0).[0]) ^ a.(1) in *)
    let str = a1 ^ (String.make 1 a0.[i32 n-$2]) in
    let ff = ref true in
    repi 1 (i32 n-$2) (fun i ->
      if a1.[i] <> a0.[i-$1] then ff := false
    );
    (* print_endline str; *)
    let s,p = ref (i32 n-$1),ref (i32 n-$1) in
    if !ff then (
      repi 0 (i32 @@ 2L*n-3L) (fun i ->
        let f = ref true in
        (* P *)
        (* printf "  %d\n" i; *)
        repi 0 (String.length a.(i)-$1) (fun j ->
          (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
          if str.[j] <> a.(i).[j] then f:=false
        );
        if !p>0 && !f then (
          res.(i) <- 'P'
        ) else (
          let f = ref true in
          let d = String.length a.(i)-$1 in
          repi 0 d (fun j ->
            (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
            if str.[i32 n-$d+$j-$1] <> a.(i).[j] then f:=false
          );
          (* printf "  -> %b\n" !f; *)
          if !f then (
            res.(i) <- 'S'
          ) else ff := false
        )
      );
      if !ff then (
        (* print_array (String.make 1) res; *)
        iter (fun c -> printf "%c" c) res;
        (* exit 0 *)
        ffff := true;
      )
    );
  );
  (* raise Not_found *)

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module Int64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  let pow n k =
    let rec f a n = function
    | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)
    in f 1L n k
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let iia = input_i64_array
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let gi = get_i64
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let g2 = get_2_i64
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let g3 = get_3_i64
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let g4 = get_4_i64
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let prefix s t =
  let f = ref true in
  repi 0 (String.length t-$1) (fun j ->
    (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
    if s.[j] <> t.[j] then f:=false
  ); !f
let suffix s t =
  let f = ref true in
  let d = String.length t-$1 in
  repi 0 d (fun j ->
    (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
    if s.[String.length s-$1-$d+$j] <> t.[j] then f:=false
  ); !f

let () =
  let n = gi 0 in
  let a = init (i32 @@ 2L*n-2L) (fun _ -> scanf " %s" @@ id) in
  let aa = init (i32 @@ 2L*n-2L) (fun i -> a.(i),i) in
  sort (fun (u,i) (v,j) -> -compare (String.length u) (String.length v)) aa;
  let m = i32 @@ 2L*n -2L in
  (* print_array (fun (c,i) -> sprintf "%s#%d" c i) aa; *)
  let zip = make m 0 in
  let unzip = make (m) 0 in
  iteri (fun i (_,j) -> zip.(i) <- j; unzip.(j) <- i) aa;
  let a0,a1 = fst aa.(0),fst aa.(1) in
  let arr0 = a in
  let a = map (fun (v,i) -> v) aa in
  let res = make (i32 @@ 2L*n-2L) ('_',0) in
  (* print_array id a; *)

  let str = a0 ^ (String.make 1 a1.[i32 n-$2]) in
  let ff = ref true in
  repi 1 (i32 n-$2) (fun i ->
    if a0.[i] <> a1.[i-$1] then ff := false
  );
  (* print_endline str; *)
  let ns,np = ref (i32 n-$1),ref (i32 n-$1) in
  rep 0L (i64 m/2L-1L) (fun i ->
    let i = i32 @@ i * 2L in
    let u,v = a.(i),a.(i+$1) in
    (* printf "  %s %s\n" u v; *)
    let p,q,r,s = prefix str u,prefix str v,suffix str u,suffix str v in
    (* if not p && r && q then (

    ) else if p && not q && then (

    ) else if not r && s then (

    ) else if r && not s then (

    ) else () *)
    if p && s then (
      res.(i) <- ('P',i);
      res.(i+$1) <- ('S',i+$1);
    ) else if q && r then (
      res.(i) <- ('S',i);
      res.(i+$1) <- ('P',i+$1);
    ) else ff := false
  );
  if !ff then (
    let ress = make m 'x' in
    iter (fun (c,i) -> ress.(zip.(i)) <- c) res;
    iter (fun c -> printf "%c" c) ress;
    exit 0;
  );
  let a0,a1 = a1,a0 in
  let str = a0 ^ (String.make 1 a1.[i32 n-$2]) in
  let ff = ref true in
  repi 1 (i32 n-$2) (fun i ->
    if a0.[i] <> a1.[i-$1] then ff := false
  );
  (* print_endline str; *)
  let ns,np = ref (i32 n-$1),ref (i32 n-$1) in
  rep 0L (i64 m/2L) (fun i ->
    let i = i32 i in
    let u,v = a.(i),a.(i+$1) in
    let p,q,r,s = prefix str u,prefix str v,suffix str u,suffix str v in
    (* if not p && r && q then (

    ) else if p && not q && then (

    ) else if not r && s then (

    ) else if r && not s then (

    ) else () *)
    if p && s then (
      res.(i) <- ('P',i);
      res.(i+$1) <- ('S',i+$1);
    ) else if q && r then (
      res.(i) <- ('S',i);
      res.(i+$1) <- ('P',i+$1);
    ) else ff := false
  );
  if !ff then (
    let ress = make m 'x' in
    iter (fun (c,i) -> ress.(zip.(i)) <- c) res;
    iter (fun c -> printf "%c" c) ress;
    exit 0;
  );

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module Int64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  let pow n k =
    let rec f a n = function
    | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)
    in f 1L n k
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let iia = input_i64_array
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let gi = get_i64
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let g2 = get_2_i64
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let g3 = get_3_i64
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let g4 = get_4_i64
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let n = gi 0 in
  let a = init (i32 @@ 2L*n-2L) (fun _ -> scanf " %s" @@ id) in
  let aa = init (i32 @@ 2L*n-2L) (fun i -> a.(i),i) in
  sort (fun (u,i) (v,j) -> -compare (String.length u) (String.length v)) aa;
  let m = i32 @@ 2L*n -2L in
  (* print_array (fun (c,i) -> sprintf "%s#%d" c i) aa; *)
  let zip = make m 0 in
  let unz = make (m) 0 in
  iteri (fun i (_,j) -> zip.(i) <- j; unz.(j) <- i) aa;
  let a0,a1 = fst aa.(0),fst aa.(1) in
  let arr0 = a in
  let a = map (fun (v,i) -> v) aa in
  let ffff = ref false in
  let res = make (i32 @@ 2L*n-2L) ('_',0) in

  let str = a0 ^ (String.make 1 a1.[i32 n-$2]) in
  let ff = ref true in
  repi 1 (i32 n-$2) (fun i ->
    if a0.[i] <> a1.[i-$1] then ff := false
  );
  (* print_endline str; *)
  let s,p = ref (i32 n-$1),ref (i32 n-$1) in
  if !ff then (
    repi 0 (i32 @@ 2L*n-3L) (fun i ->
      let f = ref true in
      (* P *)
      (* printf "  %d\n" i; *)
      repi 0 (String.length a.(i)-$1) (fun j ->
        (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
        if str.[j] <> a.(i).[j] then f:=false
      );
      if !p > 0 && !f then (
        res.(i) <- ('P',i); p:=!p-$1
      ) else (
        let f = ref true in
        let d = String.length a.(i)-$1 in
        repi 0 d (fun j ->
          (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
          if str.[i32 n-$d+$j-$1] <> a.(i).[j] then f:=false
        );
        (* printf "  -> %b\n" !f; *)
        if !f then (
          res.(i) <- ('S',i); s := !s -$ 1
        ) else ff := false
      )
    );
    if !ff then (
      (* print_array (String.make 1) res; *)
      let ress = make m 'x' in
      iter (fun (c,i) -> ress.(zip.(i)) <- c) res;
      iter (fun c -> printf "%c" c) ress;
      print_newline ();
      (* exit 0 *)
      ffff := true;
    )
  );
  if not !ffff then (
  (* let str = (String.make 1 a.(0).[0]) ^ a.(1) in *)
    let str = a1 ^ (String.make 1 a0.[i32 n-$2]) in
    let ff = ref true in
    repi 1 (i32 n-$2) (fun i ->
      if a1.[i] <> a0.[i-$1] then ff := false
    );
    (* print_endline str; *)

    let s,p = ref (i32 n-$1),ref (i32 n-$1) in
    if !ff then (
    repi 0 (i32 @@ 2L*n-3L) (fun i ->
      let f = ref true in
      (* P *)
      (* printf "  %d\n" i; *)
      repi 0 (String.length a.(i)-$1) (fun j ->
        (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
        if str.[j] <> a.(i).[j] then f:=false
      );
      if !p > 0 && !f then (
        res.(i) <- ('P',i); p:=!p-$1
      ) else (
        let f = ref true in
        let d = String.length a.(i)-$1 in
        repi 0 d (fun j ->
          (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
          if str.[i32 n-$d+$j-$1] <> a.(i).[j] then f:=false
        );
        (* printf "  -> %b\n" !f; *)
        if !f then (
          res.(i) <- ('S',i); s := !s -$ 1
        ) else ff := false
      )
    );
    if !ff then (
      (* print_array (String.make 1) res; *)
      let ress = make m 'x' in
      iter (fun (c,i) -> ress.(zip.(i)) <- c) res;
      iter (fun c -> printf "%c" c) ress;
      print_newline ();
      (* exit 0 *)
      ffff := true;
    )
  );
  );
  (* raise Not_found *)

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module Int64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  let pow n k =
    let rec f a n = function
    | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)
    in f 1L n k
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let iia = input_i64_array
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let gi = get_i64
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let g2 = get_2_i64
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let g3 = get_3_i64
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let g4 = get_4_i64
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let n = gi 0 in
  let a = init (i32 @@ 2L*n-2L) (fun _ -> scanf " %s" @@ id) in
  let aa = init (i32 @@ 2L*n-2L) (fun i -> a.(i)) in
  sort (fun u v -> -compare (String.length u) (String.length v)) aa;
  let str = aa.(0) ^ (String.make 1 aa.(1).[i32 n-$2]) in
  let ff = ref true in
  repi 1 (i32 n-$2) (fun i ->
    if aa.(0).[i] <> aa.(1).[i-$1] then ff := false
  );
  let res = make (i32 @@ 2L*n-2L) '_' in
  print_endline str;
  if !ff then (
    repi 0 (i32 @@ 2L*n-3L) (fun i ->
      let f = ref true in
      (* P *)
      (* printf "  %d\n" i; *)
      repi 0 (String.length a.(i)-$1) (fun j ->
        (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
        if str.[j] <> a.(i).[j] then f:=false
      );
      if !f then (
        res.(i) <- 'P'
      ) else (
        let f = ref true in
        let d = String.length a.(i)-$1 in
        repi 0 d (fun j ->
          (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
          if str.[i32 n-$d+$j-$1] <> a.(i).[j] then f:=false
        );
        (* printf "  -> %b\n" !f; *)
        if !f then (
          res.(i) <- 'S'
        ) else ff := false
      )
    );
    if !ff then (
      (* print_array (String.make 1) res; *)
      iter (fun c -> printf "%c" c) res;
      exit 0
    )
  );
  (* let str = (String.make 1 a.(0).[0]) ^ a.(1) in *)
  let str = aa.(1) ^ (String.make 1 aa.(0).[i32 n-$2]) in
  let ff = ref true in
  repi 1 (i32 n-$2) (fun i ->
    if aa.(1).[i] <> aa.(0).[i-$1] then ff := false
  );
  print_endline str;
  if !ff then (
    repi 0 (i32 @@ 2L*n-3L) (fun i ->
      let f = ref true in
      (* P *)
      (* printf "  %d\n" i; *)
      repi 0 (String.length a.(i)-$1) (fun j ->
        (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
        if str.[j] <> a.(i).[j] then f:=false
      );
      if !f then (
        res.(i) <- 'P'
      ) else (
        let f = ref true in
        let d = String.length a.(i)-$1 in
        repi 0 d (fun j ->
          (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
          if str.[i32 n-$d+$j-$1] <> a.(i).[j] then f:=false
        );
        (* printf "  -> %b\n" !f; *)
        if !f then (
          res.(i) <- 'S'
        ) else ff := false
      )
    );
    if !ff then (
      (* print_array (String.make 1) res; *)
      iter (fun c -> printf "%c" c) res;
      exit 0
    )
  );
  raise Not_found

open Printf open Scanf
module Lib = struct
  let i32,i64,ist = Int64.(to_int,of_int,to_string)
  let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (%$) = (mod)
  let labs = Int64.abs
  let (+),(-),( * ),(/),(mod),(%) = Int64.(add,sub,mul,div,rem,rem)
  let (+=) r v = r := !r + v
  let (-=) r v = r := !r - v
  let ( *= ) r v = r := !r * v
  let (/=) r v = r := !r / v
  let (%=) r v = r := !r % v
  let max_i64,min_i64 = Int64.(max_int,min_int)
  (* math *)
  let ceildiv p q = (p+q-1L) / q
  let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n)
  let lcm m n = m / gcd m n * n
  module Int64_infix = struct
    let (land),(lor),(lxor),lnot,(lsl),(lsr),(asr) =
      let open Int64 in
      (logand),(logor),(logxor),lognot,
      (fun u v -> shift_left u (i32 v)),
      (fun u v -> shift_right u (i32 v)),
      (fun u v -> shift_right_logical u (i32 v))
  end
  let pow n k =
    let rec f a n = function
    | 0L -> a | 1L -> n*a | k when k mod 2L = 0L -> f a (n*n) (k/2L) | k -> f (a*n) (n*n) (k/2L)
    in f 1L n k
  (* input *)
  let input_i64_array n = Array.init (i32 n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let iia = input_i64_array
  let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let gi = get_i64
  let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let g2 = get_2_i64
  let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let g3 = get_3_i64
  let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let g4 = get_4_i64
  let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let g5 = get_5_i64
  let i32_get_int _ = Scanf.scanf " %d" (fun v -> v) let i32_get_2_ints _ = Scanf.scanf " %d %d" (fun u v -> u,v) let i32_get_3_ints _ = Scanf.scanf " %d %d %d" (fun u v w -> u,v,w) let i32_get_4_ints _ = Scanf.scanf " %d %d %d %d" (fun u v w x -> u,v,w,x) let i32_get_5_ints _ = Scanf.scanf " %d %d %d %d %d" (fun u v w x y -> u,v,w,x,y)
  (* utils *)
  external id : 'a -> 'a = "%identity"
  let ( *< ) f g x = f (g x)
  let ( *> ) f g x = g (f x)
  let rv f p q = f q p (* ex. 24 |> rv (/) 6 *)
  let alen a = i64 @@ Array.length a
  let llen l = i64 @@  List.length l
  let string_of_list ?(separator=" ") f ls = ls |> List.map f |> String.concat separator
  let string_of_array ?(separator=" ") f a = a |> Array.to_list |> string_of_list ~separator f
  let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) []
  let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
  let fail _ = failwith "fail"
  let dx,dy = [|1;0;-1;0|],[|0;1;0;-1|]
  let range l r = let ls = ref [] in for i=i32 l to i32 r do ls := i :: !ls done;!ls |> List.rev
  let cartesian_product u v = u |> List.map (fun p -> List.map (fun q -> p,q) v) |> List.flatten
  let shuffle a = Array.sort (fun _ _ -> (Random.int 3) -$ 1) a
  let binary_search ng ok f = let d = if ng < ok then 1L else -1L in
    let rec f0 ng ok =
      if labs (ok - ng) <= 1L then ok
      else let mid = ng + (ok - ng) / 2L in if f mid then f0 ng mid else f0 mid ok
    in f0 (ng-1L*d) (ok+1L*d)
  let lower_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >= v)
  let upper_bound a v = binary_search 0L (alen a - 1L) (fun i -> a.(i32 i) >  v)
  let equal_range a v = lower_bound a v, upper_bound a v (* #=snd-fst *)
  let rec fix f x = f (fix f) x
  let fix_memo ?(size=10000) f x =
    let tb = Hashtbl.create ~random:true size in
    let rec f0 x =
      try Hashtbl.find tb x with
      | Not_found -> (let v = f f0 x in Hashtbl.add tb x v; v)
    in f0 x
  (* imperative *)
  let rep f t ?(stride=1L) fbod = let i = ref f in while !i <= t do fbod !i; i := !i + stride done
  let repb f t ?(stride=1L) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i + stride done
  let repm f t ?(stride=1L) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i + stride done; !m
  let repi f t ?(stride=1) fbod = let i = ref f in while !i <= t do fbod !i; i := !i +$ stride done
  let repib f t ?(stride=1) fbod = let i,c = ref f,ref true in while !i <= t && !c do
    match fbod !i with | `Break -> c := false | `Ok -> i := !i +$ stride done
  let repim f t ?(stride=1) m0 fbod =
    let i,c,m = ref f,ref true,ref m0 in
    while !i<=t && !c do match fbod !m !i with
    | `Break -> c := false | `Break_m m' -> (c := false; m := m') | `Ok m' -> m := m'; i := !i +$ stride done; !m
  let rep_rev f t ?(stride=1L) fbod = rep t f ~stride @@ fun v -> fbod @@ f + t - v
  let repb_rev f t ?(stride=1L) fbod = repb t f ~stride @@ fun v -> fbod @@ f + t - v
  let repm_rev f t ?(stride=1L) m0 fbod = repm f t ~stride m0 @@ fun u v -> fbod u @@ f + t - v
  let repi_rev f t ?(stride=1) fbod = repi t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repib_rev f t ?(stride=1) fbod = repib t f ~stride @@ fun v -> fbod @@ f +$ t -$ v
  let repim_rev f t ?(stride=1) m0 fbod = repim f t ~stride m0 @@ fun u v -> fbod u @@ f +$ t -$ v
  (* output *)
  let print_list_mle f ls = string_of_list f ls |> print_endline
  let print_array_mle f a = string_of_array f a |> print_endline
  let print_list f ls = ls |> List.iter (fun v -> printf "%s " @@ f v); print_newline ()
  let print_array f a = a |> Array.iter (fun v -> printf "%s " @@ f v); print_newline ()
  (* debug *)
  let dump_2darr f a = a |> Array.iter (fun b -> print_array f b)
  let dump_i64_list ls = print_list ist ls
  let dump_i64_array a = print_array ist a
end open Lib open Array

let () =
  let n = gi 0 in
  let a = init (i32 @@ 2L*n-2L) (fun _ -> scanf " %s" @@ id) in
  let aa = init (i32 @@ 2L*n-2L) (fun i -> a.(i)) in
  sort (fun u v -> -compare (String.length u) (String.length v)) aa;
  let str = aa.(0) ^ (String.make 1 aa.(1).[i32 n-$2]) in
  let ff = ref true in
  repi 1 (i32 n-$2) (fun i ->
    if aa.(0).[i] <> aa.(1).[i-$1] then ff := false
  );
  let res = make (i32 @@ 2L*n-2L) '_' in
  (* print_endline str; *)
  let ffff = ref false in
  if !ff then (
    repi 0 (i32 @@ 2L*n-3L) (fun i ->
      let f = ref true in
      (* P *)
      (* printf "  %d\n" i; *)
      repi 0 (String.length a.(i)-$1) (fun j ->
        (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
        if str.[j] <> a.(i).[j] then f:=false
      );
      if !f then (
        res.(i) <- 'P'
      ) else (
        let f = ref true in
        let d = String.length a.(i)-$1 in
        repi 0 d (fun j ->
          (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
          if str.[i32 n-$d+$j-$1] <> a.(i).[j] then f:=false
        );
        (* printf "  -> %b\n" !f; *)
        if !f then (
          res.(i) <- 'S'
        ) else ff := false
      )
    );
    if !ff then (
      (* print_array (String.make 1) res; *)
      iter (fun c -> printf "%c" c) res;
      print_newline ();
      (* exit 0 *)
      ffff := true;
    )
  );
  if not !ffff then (
  (* let str = (String.make 1 a.(0).[0]) ^ a.(1) in *)
    let str = aa.(1) ^ (String.make 1 aa.(0).[i32 n-$2]) in
    let ff = ref true in
    repi 1 (i32 n-$2) (fun i ->
      if aa.(1).[i] <> aa.(0).[i-$1] then ff := false
    );
    (* print_endline str; *)
    if !ff then (
      repi 0 (i32 @@ 2L*n-3L) (fun i ->
        let f = ref true in
        (* P *)
        (* printf "  %d\n" i; *)
        repi 0 (String.length a.(i)-$1) (fun j ->
          (* printf "    %d %d :: %c %c --> %b\n" i j str.[j] a.(i).[j] (str.[j] = a.(i).[j]); *)
          if str.[j] <> a.(i).[j] then f:=false
        );
        if !f then (
          res.(i) <- 'P'
        ) else (
          let f = ref true in
          let d = String.length a.(i)-$1 in
          repi 0 d (fun j ->
            (* printf "    %d %d :: %c %c --> %b\n" i j str.[i32 n-$d+$j-$1] a.(i).[j] (str.[i32 n-$d+$j-$1] = a.(i).[j]); *)
            if str.[i32 n-$d+$j-$1] <> a.(i).[j] then f:=false
          );
          (* printf "  -> %b\n" !f; *)
          if !f then (
            res.(i) <- 'S'
          ) else ff := false
        )
      );
      if !ff then (
        (* print_array (String.make 1) res; *)
        iter (fun c -> printf "%c" c) res;
        (* exit 0 *)
        ffff := true;
      )
    );
  );
  (* raise Not_found *)


Amugae has a hotel consisting of $$$10$$$ rooms. The rooms are numbered from $$$0$$$ to $$$9$$$ from left to right.The hotel has two entrances — one from the left end, and another from the right end. When a customer arrives to the hotel through the left entrance, they are assigned to an empty room closest to the left entrance. Similarly, when a customer arrives at the hotel through the right entrance, they are assigned to an empty room closest to the right entrance.One day, Amugae lost the room assignment list. Thankfully Amugae's memory is perfect, and he remembers all of the customers: when a customer arrived, from which entrance, and when they left the hotel. Initially the hotel was empty. Write a program that recovers the room assignment list from Amugae's memory.

The first line consists of an integer $$$n$$$ ($$$1 \le n \le 10^5$$$), the number of events in Amugae's memory. The second line consists of a string of length $$$n$$$ describing the events in chronological order. Each character represents:    'L': A customer arrives from the left entrance.  'R': A customer arrives from the right entrance.  '0', '1', ..., '9': The customer in room $$$x$$$ ($$$0$$$, $$$1$$$, ..., $$$9$$$ respectively) leaves.  It is guaranteed that there is at least one empty room when a customer arrives, and there is a customer in the room $$$x$$$ when $$$x$$$ ($$$0$$$, $$$1$$$, ..., $$$9$$$) is given. Also, all the rooms are initially empty.

In the only line, output the hotel room's assignment status, from room $$$0$$$ to room $$$9$$$. Represent an empty room as '0', and an occupied room as '1', without spaces.

NoteIn the first example, hotel room's assignment status after each action is as follows.   First of all, all rooms are empty. Assignment status is 0000000000.  L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000.  L: one more customer from the left entrance. Assignment status is 1100000000.  R: one more customer from the right entrance. Assignment status is 1100000001.  L: one more customer from the left entrance. Assignment status is 1110000001.  1: the customer in room $$$1$$$ leaves. Assignment status is 1010000001.  R: one more customer from the right entrance. Assignment status is 1010000011.  L: one more customer from the left entrance. Assignment status is 1110000011.  1: the customer in room $$$1$$$ leaves. Assignment status is 1010000011. So after all, hotel room's final assignment status is 1010000011.In the second example, hotel room's assignment status after each action is as follows.   L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000.  0: the customer in room $$$0$$$ leaves. Assignment status is 0000000000.  L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000 again.  0: the customer in room $$$0$$$ leaves. Assignment status is 0000000000.  L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000.  L: one more customer from the left entrance. Assignment status is 1100000000.  R: one more customer from the right entrance. Assignment status is 1100000001.  R: one more customer from the right entrance. Assignment status is 1100000011.  9: the customer in room $$$9$$$ leaves. Assignment status is 1100000010. So after all, hotel room's final assignment status is 1100000010.

let assign_left hotel =
	let rec iter prev next =
		match next with
		| 0::res 	-> prev @ [1] @ res
		| 1::res 	-> iter (prev @ [1]) res
		| [] 		-> prev
		| _ 		-> failwith "The Hotel is empty !"
	in
	iter [] hotel

let assign_right hotel =
	let reverted = List.rev hotel in
	let new_hotel = assign_left reverted in
	List.rev new_hotel

let leave i hotel =
	let rec iter j prev next =
		match next with
		| 1::res when j = i -> prev @ [0] @ res
		| c::res -> iter (j+1) (prev @ [c]) res
		| _ -> failwith "error"
	in
	iter 0 [] hotel

let handle client hotel =
	match client with
	| 'L' 		-> assign_left hotel
	| 'R' 		-> assign_right hotel
	| '0'..'9' 	-> leave (int_of_string (String.make 1 client)) hotel
	| _	  		-> failwith "Clients arrive from left or right only !"

let rec pp l =
	match l with
	| [] -> ()
	| i::tl ->  print_int i; pp tl

let init n =
	let rec iter i l =
		if i = n then l else iter  (i+1) (0::l)
	in
	iter 0 []

let main =
	let n = read_int () in
	let s = read_line () in
	let hotel = ref (init 10)  in
	for i=0 to (String.length s) - 1 do hotel := handle (s.[i]) !hotel done;
	pp !hotel

let assign_left hotel =
	let rec iter prev next =
		match next with
		| 0::res 	-> prev @ [1] @ res
		| 1::res 	-> iter (prev @ [1]) res
		| [] 		-> prev
		| _ 		-> failwith "The Hotel is empty !"
	in
	iter [] hotel

let assign_right hotel =
	let reverted = List.rev hotel in
	let new_hotel = assign_left reverted in
	List.rev new_hotel

let leave i hotel =
	let rec iter j prev next =
		match next with
		| 1::res when j = i -> prev @ [0] @ res
		| c::res -> iter (j+1) (prev @ [c]) res
		| _ -> failwith "error"
	in
	iter 0 [] hotel

let handle client hotel =
	match client with
	| 'L' 		-> assign_left hotel
	| 'R' 		-> assign_right hotel
	| '0'..'9' 	-> leave (int_of_string (String.make 1 client)) hotel
	| _	  		-> failwith "Clients arrive from left or right only !"

let rec pp l =
	match l with
	| [] -> ()
	| i::tl ->  print_int i; pp tl

let init n =
	let rec iter i l =
		if i = n then l else iter  (i+1) (0::l)
	in
	iter 0 []

let main =
	let n = read_int () in
	let s = read_line () in
	let hotel = ref (init n)  in
	for i=0 to (String.length s) - 1 do hotel := handle (s.[i]) !hotel done;
	pp !hotel