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


(*LMAOOOOOOOOOO*)

class ['a] vector =
  object (self)
    val mutable a = ([||] : 'a array)
    val mutable size = 0
    method check =
      if size = Array.length a then
        a <- Array.append a a
    method pop =
      if size = 0 then false
      else
        let () = size <- size - 1 in
        true
    method push x =
      if Array.length a = 0 then
        let () = a <- Array.make 1 x in
        size <- 1
      else
        let () = self#check in
        let () = a.(size) <- x in
        size <- size + 1
    method size =
      size
    method get i =
      a.(i)
    method con (other : 'a vector) =
      for i = 0 to other#size do
        self#push (other#get i)
      done
    method sub l r =
      let ans = (new vector : 'a vector) in
      let () =
        for i = l to r do
          ans#push (self#get i)
        done in
      ans
    method from_string s =
      for i = 0 to String.length s - 1 do
        self#push s.[i]
      done
    method eq (other : 'a vector) =
      if self#size <> other#size then false
      else
        let pos = ref true in
        let () =
          for i = 0 to self#size - 1 do
            if (self#get i) <> (other#get i) then pos := false
          done in
        !pos
    method string =
      String.init self#size (fun i -> self#get i)
  end;;

let readInt() = Scanf.scanf " %d" (fun i -> i);;
let readLine() = input_line stdin;;
let print_number x = print_string ((string_of_int x) ^ " ");;
let print_char c = print_string (Char.escaped c);;
let print_array a =
  let () =
    for i = 0 to Array.length a - 1 do
      print_number a.(i)
    done in
  print_string "\n";;
let f c = int_of_char(c) - int_of_char('a');;
let build s1 order =
  let ans = new vector in
  let () =
    let banned = Array.make 26 false in
    for i = 0 to Array.length order - 1 do
      let j = ref 0 in
      let quit_loop = ref false in
      let () =
        while not !quit_loop do
          let () =
            if ans#size = 500000 then quit_loop := true
            else if !j = s1#size then quit_loop := true
            else if not banned.(f (s1#get !j)) then
              ans#push (s1#get !j) in
          j := !j + 1
        done in
      banned.(order.(i)) <- true
    done in
  ans;;

let check s1 s2 order =
  (build s1 order)#eq s2;;

(*let a = new vector in
 let b = new vector in
 let () = a#from_string "abacaba" in
 let () = b#from_string "abacabaaacaac" in
 (build a [|1; 0; 2|])#string;;*)

let da x = ()
let reverse a n = Array.init (n+1) (fun i -> a.(n - i));;
let t = readLine() in
for i = 1 to int_of_string t do
  let inp = readLine() in
  let s = new vector in
  let () = (s#from_string inp) in
  let ptr = ref (-1) in
  let seen = Array.make 26 0 in
  let rev_order = Array.make 26 0 in
  let freq = Array.make 26 0 in
  let possible = ref true in
  let sum = ref 0 in
  let () =
    for j = 0 to s#size - 1 do
      let rj = s#size - 1 - j in
      let c = f (s#get rj) in
      let () =
        freq.(c) <- freq.(c) + 1 in
      if seen.(c) = 0 then
        let () = seen.(c) <- 1 in
        let () = ptr := !ptr + 1 in
        rev_order.(!ptr) <- c
    done in
  let order = reverse rev_order !ptr in
  let () =
    for j = 0 to Array.length order - 1 do
      let c = order.(j) in
      let () =
        if freq.(c) mod (j+1) <> 0 then
          possible := false
        else
          freq.(c) <- freq.(c) / (j+1) in
      sum := !sum + freq.(c)
    done in
  let sb = s#sub 0 (!sum - 1) in
  let ord = String.init (Array.length order) (fun i -> char_of_int (order.(i) + int_of_char('a'))) in
  if (check sb s order) then
    print_string (sb#string ^ " " ^ ord ^ "\n")
  else
    print_string "-1\n"
done;;

(*LMAOOOOOOOOOO'*)

class ['a] vector =
  object (self)
    val mutable a = ([||] : 'a array)
    val mutable size = 0
    method check =
      if size = Array.length a then
        a <- Array.append a a
    method pop =
      if size = 0 then false
      else
        let () = size <- size - 1 in
        true
    method push x =
      if Array.length a = 0 then
        let () = a <- Array.make 1 x in
        size <- 1
      else
        let () = self#check in
        let () = a.(size) <- x in
        size <- size + 1
    method size =
      size
    method get i =
      a.(i)
    method con (other : 'a vector) =
      for i = 0 to other#size do
        self#push (other#get i)
      done
    method sub l r =
      let ans = (new vector : 'a vector) in
      let () =
        for i = l to r do
          ans#push (self#get i)
        done in
      ans
    method from_string s =
      for i = 0 to String.length s - 1 do
        self#push s.[i]
      done
    method eq (other : 'a vector) =
      if self#size <> other#size then false
      else
        let pos = ref true in
        let () =
          for i = 0 to self#size - 1 do
            if (self#get i) <> (other#get i) then pos := false
          done in
        !pos
    method string =
      String.init self#size (fun i -> self#get i)
  end;;

let readInt() = Scanf.scanf " %d" (fun i -> i);;
let readLine() = input_line stdin;;
let print_number x = print_string ((string_of_int x) ^ " ");;
let print_char c = print_string (Char.escaped c);;
let print_array a =
  let () =
    for i = 0 to Array.length a - 1 do
      print_number a.(i)
    done in
  print_string "\n";;
let f c = int_of_char(c) - int_of_char('a');;
let build s1 order =
  let ans = new vector in
  let () =
    let banned = Array.make 26 false in
    for i = 0 to Array.length order - 1 do
      let j = ref 0 in
      let quit_loop = ref false in
      let () =
        while not !quit_loop do
          let () =
            if ans#size = 500000 then quit_loop := true
            else if !j = s1#size then quit_loop := true
            else if not banned.(f (s1#get !j)) then
              ans#push (s1#get !j) in
          j := !j + 1
        done in
      banned.(order.(i)) <- true
    done in
  ans;;

let check s1 s2 order =
  (build s1 order)#eq s2;;

(*let a = new vector in
 let b = new vector in
 let () = a#from_string "abacaba" in
 let () = b#from_string "abacabaaacaac" in
 (build a [|1; 0; 2|])#string;;*)

let da x = ()
let reverse a n = Array.init (n+1) (fun i -> a.(n - i));;
let t = readLine() in
for i = 1 to int_of_string t do
  let inp = readLine() in
  let s = new vector in
  let () = (s#from_string inp) in
  let ptr = ref (-1) in
  let seen = Array.make 26 0 in
  let rev_order = Array.make 26 0 in
  let freq = Array.make 26 0 in
  let possible = ref true in
  let sum = ref 0 in
  let () =
    for j = 0 to s#size - 1 do
      let rj = s#size - 1 - j in
      let c = f (s#get rj) in
      let () =
        freq.(c) <- freq.(c) + 1 in
      if seen.(c) = 0 then
        let () = seen.(c) <- 1 in
        let () = ptr := !ptr + 1 in
        rev_order.(!ptr) <- c
    done in
  let order = reverse rev_order !ptr in
  let () =
    for j = 0 to Array.length order - 1 do
      let c = order.(j) in
      let () =
        if freq.(c) mod (j+1) <> 0 then
          possible := false
        else
          freq.(c) <- freq.(c) / (j+1) in
      sum := !sum + freq.(c)
    done in
  let sb = s#sub 0 (!sum - 1) in
  let ord = String.init (Array.length order) (fun i -> char_of_int (order.(i) + int_of_char('a'))) in
  if (check sb s order) then
    print_string (sb#string ^ " " ^ ord ^ "\n")
  else
    print_string "-1\n"
done;;


let read () = Scanf.scanf "%d " (fun n -> n)

let make_list () =
    let n = read () in
    let rec loop i list =
        if i < n
        then
            let temp = read () in
            loop (i + 1) (temp :: list)
        else
            List.sort (Pervasives.compare) list
    in loop 0 []

let input () =
    let boys = make_list () in
    let girls = make_list () in
    (boys, girls)

let pair boy girl =
    if boy = girl || boy = girl + 1 || boy = girl - 1
    then
        `Paired
    else
        if boy <= girl - 2
        then
            `Next_boy
        else
            `Next_girl

let solve (boys, girls) =
    let rec loop l ll count =
        match (l, ll) with
        | (hd :: tl), (hhd :: ttl) ->
            (match (pair hd hhd) with
            | `Paired -> loop tl ttl (count + 1)
            | `Next_boy -> loop tl ll count
            | `Next_girl -> loop l ttl count)
        | _, [] -> count
        | [], _ -> count
        | [], [] -> count
    in loop boys girls 0

let print result = Printf.printf "%d\n" result
let () = print (solve (input ()))

let read () = Scanf.scanf "%d " (fun n -> n)

let make_list () =
    let n = read () in
    let rec loop i list =
        if i < n
        then
            let temp = read () in
            loop (i + 1) (temp :: list)
        else
            List.sort (Pervasives.compare) list
    in loop 0 []

let input () =
    let boys = make_list () in
    let girls = make_list () in
    (boys, girls)

let pair boy girl =
    if boy = girl || boy = girl + 1 || boy = girl - 1
    then
        `Paired
    else
        if boy <= girl - 2
        then
            `Next_boy
        else
            `Next_girl

let solve (boys, girls) =
    let rec loop l ll count =
        match (l, ll) with
        | (hd :: tl), (hhd :: ttl) ->
            (match (pair hd hhd) with
            | `Paired -> loop tl ttl (count + 1)
            | `Next_boy -> loop tl ll count
            | `Next_girl -> loop l ttl count)
        | _, _ -> count
    in loop boys girls 0

let print result = Printf.printf "%d\n" result
let () = print (solve (input ()))


let _ =
  let sb = Scanf.Scanning.stdib in
  let n = 8 in
  let a = Array.make n (0, 0) in
  let _ =
    for i = 0 to n - 1 do
      let x = Scanf.bscanf sb "%d " (fun s -> s) in
      let y = Scanf.bscanf sb "%d " (fun s -> s) in
	a.(i) <- (x, y)
    done
  in
  let is_right (x, y) (x1, y1) (x2, y2) =
    (x1 - x) * (x2 - x) + (y1 - y) * (y2 - y) = 0
  in
  let is_rect p1 p2 p3 p4 =
    is_right p1 p2 p4 &&
      is_right p2 p1 p3 &&
      is_right p3 p2 p4
  in
  let sqr x = x * x in
  let dist2 (x1, y1) (x2, y2) =
    sqr (x1 - x2) + sqr (y1 - y2)
  in
  let is_square p1 p2 p3 p4 =
    is_rect p1 p2 p3 p4 &&
      dist2 p1 p2 = dist2 p2 p3
  in
  let b = Array.make n 0 in
  let u = Array.make n false in
  let rec bf k =
    if k >= 0 then (
      for i = 0 to n - 1 do
	if not u.(i) then (
	  u.(i) <- true;
	  b.(k) <- i;
	  bf (k - 1);
	  u.(i) <- false;
	)
      done
    ) else (
      if is_square a.(b.(0)) a.(b.(1)) a.(b.(2)) a.(b.(3)) &&
	is_rect a.(b.(4)) a.(b.(5)) a.(b.(6)) a.(b.(7))
      then (
	Printf.printf "YES\n";
	for i = 0 to 3 do
	  Printf.printf "%d " (b.(i) + 1)
	done;
	Printf.printf "\n";
	for i = 4 to 7 do
	  Printf.printf "%d " (b.(i) + 1)
	done;
	Printf.printf "\n";
	exit 0
      )
    )
  in
    bf (n - 1);
    Printf.printf "NO\n"


let yolo hasht x =
	try
		Hashtbl.find hasht x
	with _ -> 0

let _ =
	let hasht = Hashtbl.create 0 in
	let s = Scanf.scanf "%s" (fun s -> s) in
		for i = 0 to String.length s - 1 do
			let x = s.[i] in
			let a = yolo hasht x in
				Hashtbl.add hasht x (a+1)
		done;
	let bleu = List.fold_left min max_int
		(List.map (yolo hasht) ['B';'l';'b';'s';'r'])
	in
	let rouge = min bleu ((yolo hasht 'u') / 2) in
	let vert = min rouge ((yolo hasht 'a') / 2) in
		print_int vert

let _ =
  let sb = Scanf.Scanning.stdib in
  let s = Scanf.bscanf sb "%s " (fun s -> s) in
  let a = Array.make 256 0 in
  let _ =
    for i = 0 to String.length s - 1 do
      let c = Char.code s.[i] in
	a.(c) <- a.(c) + 1
    done;
  in
  let r = a.(Char.code 'B') in
  let r = min r (a.(Char.code 'u') / 2) in
  let r = min r a.(Char.code 'l') in
  let r = min r a.(Char.code 'b') in
  let r = min r (a.(Char.code 'a') / 2) in
  let r = min r a.(Char.code 's') in
  let r = min r a.(Char.code 'r') in
    Printf.printf "%d\n" r

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 sum i j f = fold i j (fun i a -> (f i) + a) 0

let read_string () = bscanf Scanning.stdib " %s " (fun x -> x)
let () =
  let s = read_string () in
  let n = String.length s in

  let count c = sum 0 (n-1) (fun i -> if s.[i] = c then 1 else 0) in
  let nB = count 'B' in
  let ns = count 's' in
  let nl = count 'l' in
  let nu = count 'u' in
  let nr = count 'r' in
  let na = count 'a' in
  let nb = count 'b' in

  let answer = min nB (min (nu/2) (min nl (min nb (min (na/2) (min ns nr))))) in

  printf "%d\n" answer


let input () = let number_of_coins = Scanf.scanf "%d " (fun n -> n) in
    (*List.init number_of_coins (fun _ -> Scanf.scanf "%d " (fun n -> n))
    *)
    let rec read list n =
        if n > 0
        then
            let var = Scanf.scanf "%d " (fun n -> n) in
            read (var :: list) (n - 1)
        else
            list
    in read [] number_of_coins

let sort list = List.rev(List.sort(Pervasives.compare) list)

let get_total list = List.fold_left(fun a b -> a + b) 0 list

let more_than_half total = (total / 2) + 1

let get_big_coins list amount =
    let rec loop list amount count =
        if amount > 0
        then
            match list with
            |(a :: tail) -> loop tail (amount - a) (count + 1)
            |[] -> failwith "No money. Now cry"
        else
            count
    in loop list amount 0

let solve input = get_big_coins (sort input)(more_than_half(get_total input))

let print result = Printf.printf "%d\n" result

let () = print (solve (input ()))

open Array;;
let main () =
    let a = ref 0
    in let summ = ref 0
    in let n = read_int ()
    in let f n =
        let tmp = Scanf.scanf "%d " (fun x->x)  in
            summ := !summ + tmp; tmp
    in let ar =  init n f
    in fast_sort (-) ar;
      for i = n-1 downto 0 do
            if !a > !summ then( print_int (n-1-i);exit 0)
            else( a:= !a + ar.(i); summ:= !summ - ar.(i); ())
        done;
        print_int n
;;
main()

let sum seq = List.fold_left (+) 0 seq;;

let coins lst =
  let rec inner llst num get rest =
    if rest < get then
      num
    else
      let curr = List.hd llst
      in
      inner (List.tl llst) (num + 1) (get + curr) (rest - curr)
  in
  inner lst 0 0 (sum lst);;

let () =
  let arr = Scanf.scanf "%d "
                        (fun n -> Array.init
                                    n
                                    (fun _ -> Scanf.scanf "%d " (fun m -> m))) in
  let _ = Array.fast_sort compare arr
  in
  Printf.printf "%d\n" (coins (List.rev (Array.to_list arr)));;

open Scanf
open Printf

let n = Scanf.scanf "%d " ( fun x -> x )

let a = Array.make n (-1);;

for i = 0 to n-1 do
  let j = Scanf.scanf "%d " ( fun x -> x ) in
  a.(i)<-j;
done

let sum = Array.fold_left (fun x y -> x + y ) 0 a

let () = Array.sort (fun x y -> y - x) a

(*
let () = printf "%d \n" sum
let () = Array.iter (fun x -> printf "%d " x) a
*)

let rec loop s i =
  let s' = s+a.(i) in
  if s' > (sum - s') || i >= n then
    printf "%d\n" (i+1)
  else
    loop s' (i+1)
in loop 0 0

open Array;;
let main () =
    let a = ref 0
    in let summ = ref 0
    in let n = read_int ()
    in let f n =
        let tmp = Scanf.scanf "%d " (fun x->x)  in
            summ := !summ + tmp; tmp
    in let ar =  init n f
    in fast_sort (-) ar;
      for i = n-1 downto 0 do
            if !a > !summ then( print_int (i-1);exit 0)
            else( a:= !a + ar.(i); summ:= !summ - ar.(i); ())
        done;
        print_int n
;;
main()

let sum seq = List.fold_left (+) 0 seq;;

let coins lst =
  let rec inner llst num get rest =
    if rest < get then
      num
    else
      let curr = List.hd llst
      in
      inner (List.tl llst) (num + 1) (get + curr) (rest - curr)
  in
  inner lst 0 0 (sum lst);;

let () =
  let arr = Scanf.scanf "%d "
                        (fun n -> Array.init
                                    n
                                    (fun _ -> Scanf.scanf "%d " (fun m -> m))) in
  let _ = Array.fast_sort compare arr
  in
  Printf.printf "%d\n" (coins (Array.to_list arr));;


open Printf
open Scanf

let read_int () = bscanf Scanning.stdib " %d " (fun x -> x)
let () =
  let n = read_int () in
  let m = read_int () in

  let overlap (a,b) (c,d) =  max a c  <=  min b d in

  let possible n m startwith =  (* n zeros, m ones *)
    let bal n m =
      let zlo = n in
      let zhi = n in
      let olo = (m+1)/2 in
      let ohi = m in
      n>=0 && m>=0 && overlap (zlo,zhi) (olo,ohi)
    in
    if bal n m  then true else
      if startwith = 0 then bal (n-1) m
      else bal n (m-1) || bal n (m-2)
  in

  let mcount = [|1;2|]in

  if not (possible n m 0 || possible n m 1) then printf "-1\n" else (

    let rec loop current maxremain n m =
      if m=0 && n=0 then ()
      else if n=0 then (printf "1"; loop 1 (maxremain-1) n (m-1))
      else if m=0 then (printf "0"; loop 0 (maxremain-1) (n-1) m)
      else (
	if maxremain = 0 then (
	  let current = 1-current in
	  loop current mcount.(current) n m
	) else (
	  let nc = if possible n m current then current else 1-current in
	  printf "%d" nc;
	  let n = if nc = 0 then n-1 else n in
	  let m = if nc = 1 then m-1 else m in
	  let maxremain = if nc=current then maxremain-1 else mcount.(nc)-1 in
	  loop nc maxremain n m
	)
      )
    in

    let current = if possible n m 1 then 1 else 0 in
    printf "%d" current;
    let n = if current = 0 then n-1 else n in
    let m = if current = 1 then m-1 else m in
    loop current (mcount.(current) - 1) n m;
    printf "\n"

  )

let read_int()=Scanf.scanf " %d" (fun x->x);;
let n=read_int() and m=read_int();;

let rec print_list a b=
if b>a+1 then (if b=2 then print_int 11 else (print_int 110;print_list (a-1) (b-2)))
else if a>b then (print_int 0;print_list (a-1) b)
else if (a=b)&&(a<>0) then (print_int 10;print_list (a-1) (b-1))
else if a+1=b then (if b=1 then print_int 1 else (print_int 10;print_list (a-1) (b-1)));;

if n>m+1 then print_int (-1)
else if (m/2)+(m mod 2)>n+1 then print_int (-1)
else print_list n m;;

open Printf
open Scanf

let read_int () = bscanf Scanning.stdib " %d " (fun x -> x)
let () =
  let n = read_int () in
  let m = read_int () in

  let overlap (a,b) (c,d) =  max a c  <=  min b d in

  let possible n m startwith =  (* n zeros, m ones *)
    let bal n m =
      let zlo = (n+1)/2 in
      let zhi = n in
      let olo = (m+1)/2 in
      let ohi = m in
      n>=0 && m>=0 && overlap (zlo,zhi) (olo,ohi)
    in
    if bal n m  then true else
      if startwith = 0 then bal (n-1) m || bal (n-2) m
      else bal n (m-1) || bal n (m-2)
  in

  let mcount = [|2;2|]in

  if not (possible n m 0 || possible n m 1) then printf "-1\n" else (

    let rec loop current maxremain n m =
      if m=0 && n=0 then ()
      else if n=0 then (printf "1"; loop 1 (maxremain-1) n (m-1))
      else if m=0 then (printf "0"; loop 0 (maxremain-1) (n-1) m)
      else (
	if maxremain = 0 then (
	  let current = 1-current in
	  loop current mcount.(current) n m
	) else (
	  let nc = if possible n m current then current else 1-current in
	  printf "%d" nc;
	  let n = if nc = 0 then n-1 else n in
	  let m = if nc = 1 then m-1 else m in
	  let maxremain = if nc=current then maxremain-1 else mcount.(nc)-1 in
	  loop nc maxremain n m
	)
      )
    in

    let current = if possible n m 1 then 1 else 0 in
    printf "%d" current;
    let n = if current = 0 then n-1 else n in
    let m = if current = 1 then m-1 else m in
    loop current (mcount.(current) - 1) n m;
    printf "\n"

  )


open Scanf

let read_int () = bscanf Scanning.stdib " %d " (fun x -> x)
let read_string () = bscanf Scanning.stdib " %s " (fun x -> x)

type result =
    | YES of (char * char * char * char) list
    | NO

let print_result (r:result) =
    match r with
    | NO -> print_string "NO"
    | YES l ->
        match l with
        | [] -> print_string "NO"
        | l ->
            print_string "YES\n";
            let rec print result_l =
                match result_l with
                | [] -> print_string ""
                | (a,b,c,d)::tl ->
                    Printf.printf "%c%c|%c%c\n" a b c d;
                    print tl
            in print l

let find_and_replace_seats row_arr =
    let row_l = Array.to_list row_arr in
    let rec helper acc row_l =
        match row_l with
        | [] -> NO
        | (a,b,c,d)::tl ->
            if a = 'O' && b = 'O' then YES (List.rev (List.rev tl @ [('+','+',c,d)] @ acc))
            else if c = 'O' && d = 'O' then YES (List.rev (List.rev tl @ [(a,b,'+','+')] @ acc))
            else helper ((a,b,c,d)::acc) tl
    in helper [] row_l

let () =
    let n = read_int () in
    let row_arr = Array.init n (fun _ ->
        let input = read_string () in
        let a = input.[0] in
        let b = input.[1] in
        let c = input.[3] in
        let d = input.[4] in
        (a,b,c,d)
    )
    in
    find_and_replace_seats row_arr
    |> print_result

let list_init n f =
    let rec loop i list =
        if i < n
        then
            let element = f(i) in
            loop (i + 1) (element :: list)
        else
            List.rev list
    in loop 0 []

let mod_first list f =
    let rec loop prev list =
        match list with
        | [] -> None
        | (hd :: tl) ->
            match (f hd) with
            | None -> loop (hd :: prev) tl
            | Some hd' -> Some (List.rev_append (hd' :: prev) tl)
    in loop [] list

let read_input () =
    let n = Scanf.scanf "%d " (fun n -> n) in
    let read_row () = Scanf.scanf "%c%c%c%c%c " (fun a b c d e -> ((a, b) :: (d, e) :: [])) in
    let bus = list_init n (fun _ -> read_row ()) in
    bus

let seat bus = mod_first bus (fun row -> mod_first row (fun pair ->
    if pair = ('O', 'O')
    then
        Some ('+', '+')
    else
        None))

let print_row row =
    match row with
    | [a, b; c, d] -> Printf.printf "%c%c|%c%c\n" a b c d
    | _ -> failwith "Invalid bus"

let print_bus bus =
    match bus with
    | Some bus ->
        Printf.printf "YES\n";
        List.iter print_row bus
    | _ -> Printf.printf "NO\n"

let () = print_bus (seat (read_input ()))

let list_init n f =
    let rec loop i list =
        if i < n
        then
            let element = f(i) in
            loop (i + 1) (element :: list)
        else
            List.rev list
    in loop 0 []

let mod_first list f =
    let rec loop prev list =
        match list with
        | [] -> None
        | (hd :: tl) ->
            match (f hd) with
            | None -> loop (hd :: prev) tl
            | Some hd' -> Some (List.rev_append (hd' :: prev) tl)
    in loop [] list

let read_input () =
    let n = Scanf.scanf "%d " (fun n -> n) in
    let read_row () = Scanf.scanf "%c%c%c%c%c " (fun a b c d e -> ((a, b) :: (d, e) :: [])) in
    let bus = list_init n (fun _ -> read_row ()) in
    bus

let seat bus = mod_first bus (fun row -> mod_first row (fun pair ->
    if pair = ('O', 'O')
    then
        Some ('+', '+')
    else
        None))

let print_char char =
    Printf.printf "%c" char

let print_str str =
    Printf.printf "%s\n" str

let print_side (a, b) =
    Printf.printf "%c%c" a b

let print_row row =
    match row with
    | [left; right] ->
        print_side left;
        print_char '|';
        print_side right;
        print_char '\n'
    | _ -> failwith "Invalid bus"

let print_bus bus =
    match bus with
    | Some bus ->
        print_str "YES";
        List.iter print_row bus
    | _ -> print_str "NO"

let () = print_bus (seat (read_input ()))

let read_int () = Scanf.scanf "%d " (fun n -> n)
let read_char () = Scanf.scanf "%c " (fun c -> c)
let print option =
    match option with
    | Some array -> Printf.printf "YES\n";
        Array.iter (fun row ->
            Array.iter (Printf.printf "%c") row;
            Printf.printf "\n") array
    | None -> Printf.printf "NO\n"

let input () =
    let n = read_int () in
    let all_rows = Array.init n (fun _ -> Array.init 5 (fun _ -> read_char ())) in
    (all_rows, n)

let modify row =
    let rec loop i =
        if i < 5
        then
            let char = row.(i) in
            let prev = row.(i - 1) in
            if char = 'O' && char = prev
            then
                (Array.set row i '+';
                Array.set row (i - 1) '+';
                true)
            else
                loop (i + 1)
        else
            false
    in loop 1

let solve (all_rows, n) =
    let rec loop i =
        if i < n
        then
            let row = all_rows.(i) in
            if modify row
            then
                Some all_rows
            else
                loop (i + 1)
        else
            None
    in loop 0

let () = print (solve (input ()))