open Scanf
open Printf

let (|>) f x = x f

module DisJoint: sig

  type 'a t
  val create : 'a -> 'a t
  val get    : 'a t -> 'a
  val set    : 'a t -> 'a -> unit
  val same   : 'a t -> 'a t -> bool
  val union  : 'a t -> 'a t -> unit

end = struct

  type 'a root = {
    mutable value: 'a;
    mutable rank: int;
  }

  type 'a t = { mutable parent : 'a parent; }
  and 'a parent =
    | Parent of 'a t
    | Root of 'a root

  let create v =
    { parent = Root { value = v; rank = 0; }; }

  let compress t =
    let rec loop t ac =
      match t.parent with
        | Root _ ->
            let p = Parent t in
            List.iter (fun t -> t.parent <- p) ac;
        | Parent t' -> loop t' (t :: ac)
    in loop t []

  let find t =
    compress t;
    match t.parent with
      | Root r -> (t, r)
      | Parent t ->
          match t.parent with
            | Root r -> (t, r)
            | Parent _ -> assert false

  let root t =
    snd (find t)

  let get t =
    (root t).value

  let set t v =
    (root t).value <- v

  let same t1 t2 =
    (root t1) == (root t2)

  let union t1 t2 =
    let (t1, r1) = find t1 in
    let (t2, r2) = find t2 in
    if r1 == r2 then ()
    else
      if r1.rank < r2.rank then
        t1.parent <- Parent t2
      else
        (t2.parent <- Parent t1;
         if r1.rank = r2.rank then
           r1.rank <- r1.rank + 1)

end

let (n, input) =
  bscanf Scanning.stdib "%d %d " (fun n m ->
    (n, Array.init m (fun _ ->
      bscanf Scanning.stdib "%d %d " (fun a b -> (a, b)))))

let _ =
  let ct = ref 0 in
  let u = Array.init (n + 1) (fun i -> DisJoint.create i) in
  input |> Array.iter (fun (a, b) ->
    if not (DisJoint.same u.(a) u.(b)) then
      DisJoint.union u.(a) u.(b)
    else
      u |> Array.map (fun b -> if DisJoint.same u.(a) b then 1 else 0)
        |> Array.fold_left (+) 0
        |> (fun c -> if c mod 2 = 1 then incr ct));

  printf "%d"
    (if (n - !ct) mod 2 = 0 then !ct else !ct + 1)

open Scanf
open Printf

let (|>) f x = x f

let (n, arr) =
  bscanf Scanning.stdib "%d %d " (fun n m ->
    (n, Array.init m (fun _ ->
      bscanf Scanning.stdib "%d %d " (fun a b -> (a, b)))))

let ct = ref 0

let rec merge (a, b, len) = function
  | [] -> []
  | (a2, b2, len2) :: xs ->
      if (a2 = a && b2 = b) || (a2 = b && b2 = a) then
        if (len + len2) mod 2 = 1 then
          (incr ct; xs)
        else
          xs
      else
        if a2 = a then (b, b2, len + len2) :: xs else
          if a2 = b then (a, b2, len + len2) :: xs else
            if b2 = a then (a2, b, len + len2) :: xs else
              if b2 = b then (a, a2, len + len2) :: xs else
                (a2, b2, len2) :: merge (a, b, len) xs

let rec process = function
  |      [] -> printf "%d" (if (n + !ct) mod 2 = 0 then !ct else !ct + 1)
  | x :: xs -> process (merge x xs)

let _ = process
  (arr |> Array.to_list
       |> List.map (fun (a, b) -> (a, b, 1)))

open Scanf
open Printf

let (|>) f x = x f

let (n, arr) =
  bscanf Scanning.stdib "%d %d " (fun n m ->
    (n, Array.init m (fun _ ->
      bscanf Scanning.stdib "%d %d " (fun a b -> (a, b)))))

let ct = ref 0

let rec merge (a, b, len) = function
  | [] -> []
  | (a2, b2, len2) :: xs ->
      if (a2 = a && b2 = b) || (a2 = b && b2 = a) then
        if (len + len2) mod 2 = 1 then
          (incr ct; xs)
        else
          xs
      else
        if a2 = a then (b, b2, len + len2) :: xs else
          if a2 = b then (a, b2, len + len2) :: xs else
            if b2 = a then (a2, b, len + len2) :: xs else
              if b2 = b then (a, a2, len + len2) :: xs else
                (a2, b2, len2) :: merge (a, b, len) xs

let rec process = function
  |      [] -> printf "%d" (match (n mod 2, !ct mod 2) with
                                | (0, 0) -> !ct
                                | (0, 1) -> !ct + 1
                                | (1, 0) -> !ct + 1
                                | (1, 1) -> !ct)
  | x :: xs -> process (merge x xs)

let _ = process
  (arr |> Array.to_list
       |> List.map (fun (a, b) -> (a, b, 1)))

open Scanf
open Printf

let (|>) f x = x f

module DisJoint: sig

  type 'a t
  val create : 'a -> 'a t
  val get    : 'a t -> 'a
  val set    : 'a t -> 'a -> unit
  val same   : 'a t -> 'a t -> bool
  val union  : 'a t -> 'a t -> unit

end = struct

  type 'a root = {
    mutable value: 'a;
    mutable rank: int;
  }

  type 'a t = { mutable parent : 'a parent; }
  and 'a parent =
    | Parent of 'a t
    | Root of 'a root

  let create v =
    { parent = Root { value = v; rank = 0; }; }

  let compress t =
    let rec loop t ac =
      match t.parent with
        | Root _ ->
            let p = Parent t in
            List.iter (fun t -> t.parent <- p) ac;
        | Parent t' -> loop t' (t :: ac)
    in loop t []

  let find t =
    compress t;
    match t.parent with
      | Root r -> (t, r)
      | Parent t ->
          match t.parent with
            | Root r -> (t, r)
            | Parent _ -> assert false

  let root t =
    snd (find t)

  let get t =
    (root t).value

  let set t v =
    (root t).value <- v

  let same t1 t2 =
    (root t1) == (root t2)

  let union t1 t2 =
    let (t1, r1) = find t1 in
    let (t2, r2) = find t2 in
    if r1 == r2 then ()
    else
      if r1.rank < r2.rank then
        t1.parent <- Parent t2
      else
        (t2.parent <- Parent t1;
         if r1.rank = r2.rank then
           r1.rank <- r1.rank + 1)

end

let (n, input) =
  bscanf Scanning.stdib "%d %d " (fun n m ->
    (n, Array.init m (fun _ ->
      bscanf Scanning.stdib "%d %d " (fun a b -> (a, b)))))

let _ =
  let ct = ref 0 in
  let u = Array.init (n + 1) (fun i -> DisJoint.create i) in
  input |> Array.iter (fun (a, b) ->
    if DisJoint.same u.(a) u.(b) then
      (let c = u |> Array.map (fun b -> if DisJoint.same u.(a) b then 1 else 0)
                 |> Array.fold_left (+) 0 in
       if c mod 2 = 1 then incr ct)
    else
      DisJoint.union u.(a) u.(b));

  printf "%d"
    (if (n - !ct) mod 2 = 0 then !ct else !ct + 1)

open Scanf
open Printf

let (|>) f x = x f

let (n, arr) =
  bscanf Scanning.stdib "%d %d " (fun n m ->
    (n, Array.init m (fun _ ->
      bscanf Scanning.stdib "%d %d " (fun a b -> (a, b)))))

let ct = ref 0

let rec merge (a, b, len) = function
  | [] -> []
  | (a2, b2, len2) :: xs ->
      if (a2 = a && b2 = b) || (a2 = b && b2 = a) then
        if (len + len2) mod 2 = 1 then
          (incr ct; xs)
        else
          xs
      else
        if a2 = a then (b, b2, len + len2) :: xs else
          if a2 = b then (a, b2, len + len2) :: xs else
            if b2 = a then (a2, b, len + len2) :: xs else
              if b2 = b then (a, a2, len + len2) :: xs else
                (a2, b2, len2) :: merge (a, b, len) xs

let rec process = function
  |      [] -> printf "%d" (if n mod 2 = 1 && !ct mod 2 = 0 then !ct + 1 else !ct)
  | x :: xs -> process (merge x xs)

let _ = process
  (arr |> Array.to_list
       |> List.map (fun (a, b) -> (a, b, 1)))

open Scanf
open Printf

let (|>) f x = x f

module DisJoint: sig

  type 'a t
  val create : 'a -> 'a t
  val get    : 'a t -> 'a
  val set    : 'a t -> 'a -> unit
  val same   : 'a t -> 'a t -> bool
  val union  : 'a t -> 'a t -> unit

end = struct

  type 'a root = {
    mutable value: 'a;
    mutable rank: int;
  }

  type 'a t = { mutable parent : 'a parent; }
  and 'a parent =
    | Parent of 'a t
    | Root of 'a root

  let create v =
    { parent = Root { value = v; rank = 0; }; }

  let compress t =
    let rec loop t ac =
      match t.parent with
        | Root _ ->
            let p = Parent t in
            List.iter (fun t -> t.parent <- p) ac;
        | Parent t' -> loop t' (t :: ac)
    in loop t []

  let find t =
    compress t;
    match t.parent with
      | Root r -> (t, r)
      | Parent t ->
          match t.parent with
            | Root r -> (t, r)
            | Parent _ -> assert false

  let root t =
    snd (find t)

  let get t =
    (root t).value

  let set t v =
    (root t).value <- v

  let same t1 t2 =
    (root t1) == (root t2)

  let union t1 t2 =
    let (t1, r1) = find t1 in
    let (t2, r2) = find t2 in
    if r1 == r2 then ()
    else
      if r1.rank < r2.rank then
        t1.parent <- Parent t2
      else
        (t2.parent <- Parent t1;
         if r1.rank = r2.rank then
           r1.rank <- r1.rank + 1)

end

let (n, input) =
  bscanf Scanning.stdib "%d %d " (fun n m ->
    (n, Array.init m (fun _ ->
      bscanf Scanning.stdib "%d %d " (fun a b -> (a, b)))))

let _ =
  let ct = ref 0 in
  let u = Array.init (n + 1) (fun i -> DisJoint.create i) in
  input |> Array.iter (fun (a, b) ->
    if DisJoint.same u.(a) u.(b) then incr ct else
      DisJoint.union u.(a) u.(b));

  printf "%d"
    (if (n - !ct) mod 2 = 0 then !ct else !ct + 1)

open Scanf
open Printf

let (n, arr) =
  bscanf Scanning.stdib "%d %d " (fun n m ->
    (n, Array.init m (fun _ ->
      bscanf Scanning.stdib "%d %d " (fun a b -> (a, b)))))

let ct = ref 0

let rec merge (a, b) = function
  | [] -> []
  | (a2, b2) :: xs ->
      if (a2 = a && b2 = b) || (a2 = b && b2 = a) then
        (incr ct; xs)
      else
        if a2 = a then (b, b2) :: xs else
          if a2 = b then (a, b2) :: xs else
            if b2 = a then (a2, b) :: xs else
              if b2 = b then (a, a2) :: xs else
                (a2, b2) :: merge (a, b) xs

let rec process = function
  |      [] -> printf "%d" (if n mod 2 = 1 && !ct mod 2 = 0 then !ct + 1 else !ct)
  | x :: xs -> process (merge x xs)

let _ = process (Array.to_list arr)

open Scanf
open Printf

let (|>) f x = x f

let (n, arr) =
  bscanf Scanning.stdib "%d %d " (fun n m ->
    (n, Array.init m (fun _ ->
      bscanf Scanning.stdib "%d %d " (fun a b -> (a, b)))))

let ct = ref 0

let rec merge (a, b, len) = function
  | [] -> []
  | (a2, b2, len2) :: xs ->
      if (a2 = a && b2 = b) || (a2 = b && b2 = a) then
        if (len + len2) mod 2 = 1 then
          (incr ct; xs)
        else
          xs
      else
        if a2 = a then (b, b2, len + len2) :: xs else
          if a2 = b then (a, b2, len + len2) :: xs else
            if b2 = a then (a2, b, len + len2) :: xs else
              if b2 = b then (a, a2, len + len2) :: xs else
                (a2, b2, len2) :: merge (a, b, len) xs

let rec process = function
  |      [] -> printf "%d" (if n mod 2 = 1 && !ct mod 2 = 0 then !ct + 1 else !ct)
  | x :: xs -> process (merge x xs)

let _ = process
  (arr |> Array.to_list
       |> List.map (fun (a, b) -> (a, b, 0)))

open Scanf
open Printf

let ct = ref 0

let rec merge (a, b) = function
  | [] -> []
  | (a2, b2) :: xs ->
      if (a2 = a && b2 = b) || (a2 = b && b2 = a) then
        (incr ct; xs)
      else
        if a2 = a then (b, b2) :: xs else
          if a2 = b then (a, b2) :: xs else
            if b2 = a then (a2, b) :: xs else
              if b2 = b then (a, a2) :: xs else
                (a2, b2) :: merge (a, b) xs

let rec process = function
  |      [] -> printf "%d" !ct
  | x :: xs -> process (merge x xs)

let _ = process
  (Array.to_list
     (bscanf Scanning.stdib "%d %d " (fun n m ->
       Array.init m (fun _ ->
         bscanf Scanning.stdib "%d %d " (fun a b -> (a, b))))))


let list_init n f =
    let rec read n list =
        if n > 0
        then
            let var = f() in
            read (n - 1) (var :: list)
        else
            List.rev list
    in read n []

let income n = list_init n (fun i -> Scanf.scanf "%d " (fun k -> k))

let input () =
    let days = Scanf.scanf "%d " (fun n -> n) in
    income days

let max a b =
    if a > b
    then
        a
    else
        b

let find_max list =
    let rec loop list prev count max_seen =
        match list with
        |(head :: tail) ->
            if prev <= head
            then
                let new_count = count + 1 in
                loop tail head new_count (max new_count max_seen)
            else
                loop tail head 1 max_seen
        |[] -> max_seen

    in loop list 0 0 0

let solve list = find_max list

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

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

let list_init n f =
    let rec read n list =
        if n > 0
        then
            let var = f() in
            read (n - 1) (var :: list)
        else
            List.rev list
    in read n []

let income n = list_init n (fun i -> Scanf.scanf "%d " (fun k -> k))

let input () =
    let days = Scanf.scanf "%d " (fun n -> n) in
    income days

let find_max list =
    let rec loop list prev count max_seen =
        match list with
        |(head :: tail) ->
            if prev <= head
            then
                let new_count = count + 1 in
                loop tail head new_count (Pervasives.max new_count max_seen)
            else
                loop tail head 1 max_seen
        |[] -> max_seen

    in loop list 0 0 0

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

let () = print (find_max (input ()))

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

let () =
  let n = read_int () in
  let ans = ref 0 in
  let rec loop acc prev = function
    | 0 -> ()
    | num -> (
      let curr = read_int () in
      if curr >= prev then
        (ans := max !ans (acc + 1);
        loop (acc + 1) curr (num - 1))
      else
        loop 1 curr (num - 1)
    ) in
  loop 0 0 n;
  Printf.printf "%d\n" !ans

open Big_int;;

let rec biggest aux = function
	|[a]	-> aux
	| a::b::q -> if compare_big_int a b > -1
			then biggest (aux + 1) (b::q)
			else max aux (biggest 1 (b::q));;

let main () =
	let l = ref [] and n = Scanf.scanf "%d" (fun i -> i) in
		for i=1 to n do
			l := (Scanf.scanf " %s" big_int_of_string)::!l;
		done;
	Printf.printf "%d" (biggest 1 !l);;

main ();;

open Printf
open String

let n = Scanf.bscanf Scanf.Scanning.stdin "%d " ( fun x -> x) ;;

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

for i = 0 to n-1 do
  let jj = Scanf.bscanf Scanf.Scanning.stdin "%d " (fun x -> x) in
  a.(i) <- jj
done

let c = Array.make n  1;; (* This is the array counting the number of increasing sequence *)

let d = ref 1;;

  for i = 1 to n-1 do
    begin
      if( a.(i) >= a.(i-1) ) then
        c.(i) <- c.(i-1) + 1;
      if( !d < c.(i) ) then d := c.(i)
    end
  done;;

let () = print_int !d; print_endline "";;

let read_int () = Scanf.scanf " %d " (fun x -> x);;
let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> read_int()) in
  let rec go i prev cnt best =
    if i = n then max cnt best else
      if a.(i) >= prev then go (i+1) a.(i) (cnt+1) best else
        go (i+1) a.(i) 1 (max cnt best)
  in
  Printf.printf "%d\n" (go 0 0 0 0);;

let n = int_of_string (input_line stdin);;
let first = Scanf.scanf "%d " (fun v -> v);;

let rec solve num_remaining last acc best =
  if num_remaining == 0 then (max acc best) else
  let v = Scanf.scanf "%d " (fun v -> v) in
  if v >= last then solve (num_remaining - 1) v (acc + 1) best
  else solve (num_remaining - 1) v 1 (max acc best);;

let ans = solve (n - 1) first 1 0 in
Printf.printf "%d\n" ans;

open Printf
open List
open Pervasives

let split_on_char sep s =
  let r = ref [] in
  let j = ref (String.length s) in
  for i = String.length s - 1 downto 0 do
    if (String.unsafe_get s i) = sep then begin
      r := String.sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  String.sub s 0 !j :: !r

(* 2 2 1 3 4 1 *)
let rec longest_non_decr_seq seq last count longest =
  match seq with
  | [] -> longest
  | hd::tl ->
    if last > hd then longest_non_decr_seq tl hd 1 (if count > longest then
                                                      count else longest)
    else longest_non_decr_seq tl hd (count + 1) (if (count + 1) > longest then
                                                   (count + 1 ) else longest)

let get_list_size () =
  int_of_string (read_line ())

let get_input_list () =
  let in_line = read_line() in
  List.map int_of_string (split_on_char ' ' in_line)

let () =
  let expected_len = get_list_size () in
  let list = get_input_list () in
  assert (expected_len = List.length list);
  match list with
  | [] -> printf "0\n"
  | hd::_ -> printf "%d\n" (longest_non_decr_seq list hd 0 0)

open Pervasives
open Printf

let () = printf "%d\n" 3

open Printf
open List
open Pervasives

let split_on_char sep s =
  let r = ref [] in
  let j = ref (String.length s) in
  for i = String.length s - 1 downto 0 do
    if (String.unsafe_get s i) = sep then begin
      r := String.sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  String.sub s 0 !j :: !r

let rec longest_non_decr_seq seq last count longest =
  match seq with
  | [] -> longest
  | hd::tl ->
    if last > hd then longest_non_decr_seq tl hd 0 (if count > longest then
                                                      count else longest)
    else longest_non_decr_seq tl hd (count + 1) (if (count + 1) > longest then
                                                   (count + 1 ) else longest)

let get_list_size () =
  int_of_string (read_line ())

let get_input_list () =
  let in_line = read_line() in
  List.map int_of_string (split_on_char ' ' in_line)

let () =
  let expected_len = get_list_size () in
  let list = get_input_list () in
  assert (expected_len = List.length list);
  printf "%d\n" ((longest_non_decr_seq list 2 0 0) + 1)

open Printf
open String

let n = Scanf.bscanf Scanf.Scanning.stdin "%d " ( fun x -> x) ;;

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

for i = 0 to n-1 do
  let jj = Scanf.bscanf Scanf.Scanning.stdin "%d " (fun x -> x) in
  a.(i) <- jj
done

let c = Array.make n  1;; (* This is the array counting the number of increasing sequence *)

let d = ref 0;;

  for i = 1 to n-1 do
    begin
      if( a.(i) >= a.(i-1) ) then
        c.(i) <- c.(i-1) + 1;
      if( !d < c.(i) ) then d := c.(i)
    end
  done;;

let () = print_int !d; print_endline "";;


let read_int _ = Scanf.bscanf Scanf.Scanning.stdib " %d" (fun x -> x)
let (|>) x f = f x

let () =
  let n = read_int 0 in
  let a = Array.init n read_int in
  let ans = ref (-1) in
  for i = 1 to n-1 do
    for j = i to n-1 do
      (* representation of a_{i-1}-1 *)
      let p = a.(i-1)-1 |> ref
      and c = ref 1
      and w = ref a.(j) in
      for k = i to j do
        let t = !p / a.(k) in
        c := !c + t;
        w := !w + a.(k) * t;
        p := !p mod a.(k)
      done;

      p := !w;
      for k = 0 to n-1 do
        c := !c - !p / a.(k);
        p := !p mod a.(k)
      done;
      if !c < 0 && (!ans < 0 || !w < !ans) then
        ans := !w;
    done
  done;
  Printf.printf "%d\n" !ans

let read_int _ = Scanf.bscanf Scanf.Scanning.stdib " %d" (fun x -> x)
let (|>) x f = f x

let () =
  let n = read_int 0 in
  let a = Array.init n read_int in
  let ans = ref (-1) in
  for i = 1 to n-1 do
    for j = i to n-1 do
      let p = a.(i-1)-1 |> ref
      and c = ref 1
      and w = ref a.(j) in
      for k = i to j do
        let t = !p / a.(k) in
        c := !c + t;
        w := !w + a.(k) * t;
        p := !p mod a.(k)
      done;
      if !p = 0 then (
        p := !w;
        for k = 0 to n-1 do
          c := !c - !p / a.(k);
          p := !p mod a.(k)
        done
      );
      if !c < 0 && (!ans < 0 || !w < !ans) then
        ans := !w;
    done
  done;
  Printf.printf "%d\n" !ans

let read_int _ = Scanf.bscanf Scanf.Scanning.stdib " %d" (fun x -> x)
let (|>) x f = f x

let () =
  let n = read_int 0 in
  let a = Array.init n read_int in
  let ans = ref (-1) in
  for i = 1 to n-1 do
    for j = i to n-1 do
      let p = a.(i-1)-1 |> ref
      and c = ref 0
      and w = ref a.(j) in
      for k = i to j do
        let t = !p / a.(k) in
        c := !c + t;
        w := !w + a.(k) * t;
        p := !p mod a.(k)
      done;
      if !p = 0 then (
        p := !w;
        for k = 0 to n-1 do
          c := !c - !p / a.(k);
          p := !p mod a.(k)
        done
      );
      if !c < 0 && (!ans < 0 || !w < !ans) then
        ans := !w;
    done
  done;
  Printf.printf "%d\n" !ans


(*********************************************************************************)

type disk = {
	a : int; (* inner radius *)
	b : int; (* outer radius *)
	h : int64; (* dist height *)
};;

(*********************************************************************************)

let read_disks n =
	let arr = Array.make n {a=0; b=0; h=Int64.zero} in
	begin
		for k=0 to (n - 1) do
			Scanf.bscanf Scanf.Scanning.stdin " %d %d %Ld " (fun a b h -> arr.(k) <- {a=a; b=b; h=h};);
		done;
		arr;
	end
;;

(*********************************************************************************)

let lower_bound arr n x less =
	let l = ref 0 in
	let r = ref n in
	begin
		while !l < !r do
			let mid = !l + (!r - !l) / 2 in
			if (less arr.(mid) x) then
				begin
					l := mid + 1;
				end
			else
				begin
					r := mid;
				end
		done;
		!r
	end
;;

(*********************************************************************************)
let upper_bound arr n x less =
	let l = ref 0 in
	let r = ref n in
	begin
		while !l < !r do
			let mid = !l + (!r - !l) / 2 in
			if (less x arr.(mid)) then
				begin
					r := mid;
				end
			else (* a[mid] <= x *)
				begin
					l := mid + 1;
				end
		done;
		!r
	end
;;

(*********************************************************************************)

let find_highest_tower arr =
	(* precondition: arr is sorted by increasing disk.b *)
	let n = Array.length arr in
	let tw = Array.make n 0 in
	(*
		Towers are arranged according to increase of width and decrease of height.
		In essence tower with a smaller width can precede a tower with a greater width only if it is higher.
	*)
	let th = Array.make n Int64.zero in
	let m = ref 0 in (* amount of towers to lookup *)
	begin
	for k = 0 to n - 1 do
		let d = arr.(k) in
		let j = upper_bound tw !m d.a (<) in (* find the tower with width > outer radius of the disk, or return the end of tower list *)
		let t = if j < !m then (Int64.add th.(j) d.h) else d.h in
		let mm = lower_bound th j t (>) in (* find first tower which is not taller than the new one *)
		begin
			m := mm + 1; (* no point to search beyond the widest tower *)
			tw.(mm) <- d.b;
			th.(mm) <- t;
			(*Printf.printf "j=%d, m=%d, w=%d, h=%Ld\n" j !m d.b t;*)
		end
	done;
	th.( 0 )
	end
;;

(*********************************************************************************)

let cmp_disks d1 d2 =
	if d1.b < d2.b then -1
	else if d2.b < d1.b then 1
	else compare d1.a d2.a
;;

(*********************************************************************************)

let read_and_process n =
	let a = read_disks n in
	begin
		Array.sort cmp_disks a;
		Printf.printf "%Ld\n" (find_highest_tower a);
	end
;;

(*********************************************************************************)

let read_input () =
	Scanf.bscanf Scanf.Scanning.stdin " %d " read_and_process
;;

(*********************************************************************************)

read_input ()

(*********************************************************************************)

type disk = {
	a : int; (* inner radius *)
	b : int; (* outer radius *)
	h : int; (* dist height *)
	mutable t : int; (* height of tallest tower containing this disk *)
};;

(*********************************************************************************)

let print_disks a =
	let n = Array.length a in
	for k = 0 to n - 1 do
		let d = a.(k) in
		Printf.printf "a=%d; b=%d; h=%d; t=%d;\n" d.a d.b d.h d.t;
	done;
	(*print_newline ();*)
;;

(*********************************************************************************)

let create_disk va vb vh = { a=va; b=vb; h=vh; t=vh };;

(*********************************************************************************)

let read_disks n =
	let arr = Array.make n (create_disk 0 0 0) in
	begin
		for k=0 to (n - 1) do
			Scanf.bscanf Scanf.Scanning.stdin " %d %d %d " (fun a b h -> arr.(k) <- (create_disk a b h););
		done;
		arr;
	end
;;

(*********************************************************************************)

let find_highest_tower arr =
	(* precondition: arr is sorted by increasing disk.b *)
	let n = Array.length arr in
	let tt = ref 0 in (* height of the tallest tower *)
	begin
		for k = 0 to n - 1 do (* Invariant k: tt contains height of the tallest tower from arr[0] to arr[k-1] *)
			let d = arr.(k) in
			let t = ref 0 in (* height of the tallest tower involving disk d.(k) *)
			begin
				(*
				*	We need to check only the towers ending with the disk of outer radius <= d.b
				*	because the towers ending with wider disks cannot be placed on top of disk d.
				*	All these good towers are to the left of k-th disk because by precondition our array is sorted by disk.b
				*
				*	Invariant j:
				*	------------
				*	t is the height of the tallest tower such that it contains some (possibly all or none)
				*	properly arranged disks in the range (j..k)
				*)
				for j=(k-1) downto 0 do
					let dd = arr.(j) in
					(*
					*	Only disks with outer radius greater than arr[k].b can be put on top of k-th disk
					*)
					t := if dd.b > d.a then max !t dd.t else !t;
				done;
				d.t <- (!t + d.h);
				(*
					The tallest tower from 0-th to k-th is either:
					1. The tallest one among those containing the k-th disk
					2. The tallest one among those which do not contain k-th disk
				*)
				tt := max !tt d.t;
			end
		done;

		!tt
	end
;;

(*********************************************************************************)

let read_and_process n =
	let a = read_disks n in
	begin
		Array.sort (fun d1 d2 -> compare d1.b d2.b) a;
		Printf.printf "%d\n" (find_highest_tower a);
	end
;;

(*********************************************************************************)

let read_input () =
	Scanf.bscanf Scanf.Scanning.stdin " %d " read_and_process
;;

(*********************************************************************************)

read_input ()

(*********************************************************************************)

type disk = {
	a : int; (* inner radius *)
	b : int; (* outer radius *)
	h : int; (* dist height *)
	mutable t : int; (* height of tallest tower containing this disk *)
};;

(*********************************************************************************)

let print_disks a =
	let n = Array.length a in
	for k = 0 to n - 1 do
		let d = a.(k) in
		Printf.printf "a=%d; b=%d; h=%d; t=%d;\n" d.a d.b d.h d.t;
	done;
	(*print_newline ();*)
;;

(*********************************************************************************)

let create_disk va vb vh = { a=va; b=vb; h=vh; t=vh };;

(*********************************************************************************)

let read_disks n =
	let arr = Array.make n (create_disk 0 0 0) in
	begin
		for k=0 to (n - 1) do
			Scanf.bscanf Scanf.Scanning.stdin " %d %d %d " (fun a b h -> arr.(k) <- (create_disk a b h););
		done;
		arr;
	end
;;

(*********************************************************************************)

let find_highest_tower arr =
	(* precondition: arr is sorted by increasing disk.b *)
	let n = Array.length arr in
	let tt = ref 0 in (* height of the tallest tower *)
	begin
		for k = 0 to n - 1 do (* Invariant k: tt contains height of the tallest tower from arr[0] to arr[k-1] *)
			let d = arr.(k) in
			let t = ref 0 in (* height of the tallest tower involving disk d.(k) *)
			begin
				(*
				*	We need to check only the towers ending with the disk of outer radius <= d.b
				*	because the towers ending with wider disks cannot be placed on top of disk d.
				*	All these good towers are to the left of k-th disk because by precondition our array is sorted by disk.b
				*
				*	Invariant j:
				*	------------
				*	t is the height of the tallest tower such that it contains some (possibly all or none)
				*	properly arranged disks in the range (j..k)
				*)
				for j=(k-1) downto 0 do
					let dd = arr.(j) in
					(*
					*	Only disks with outer radius greater than arr[k].b can be put on top of k-th disk
					*)
					t := if dd.b > d.a then max !t dd.t else !t;
				done;
				d.t <- (!t + d.h);
				(*
					The tallest tower from 0-th to k-th is either:
					1. The tallest one among those containing the k-th disk
					2. The tallest one among those which do not contain k-th disk
				*)
				tt := max !tt d.t;
			end
		done;

		!tt
	end
;;

(*********************************************************************************)

let cmp_disks d1 d2 =
	if d1.b < d2.b then -1
	else if d2.b < d1.b then 1
	else compare d1.a d2.a
;;

(*********************************************************************************)

let read_and_process n =
	let a = read_disks n in
	begin
		Array.sort cmp_disks a;
		Printf.printf "%d\n" (find_highest_tower a);
	end
;;

(*********************************************************************************)

let read_input () =
	Scanf.bscanf Scanf.Scanning.stdin " %d " read_and_process
;;

(*********************************************************************************)

read_input ()


let input () =
  Scanf.bscanf Scanf.Scanning.stdin " %s" (fun x -> x)

let eat () =
  let s = input ()
  in let len = String.length s
  in if len > 10 then
    Printf.printf "%c%d%c\n" (String.get s 0) (len - 2) (String.get s (len - 1))
  else
    Printf.printf "%s\n" s

let main () =
  let n = Scanf.bscanf Scanf.Scanning.stdin " %d" (fun x -> x)
  in let rec int x =
       if x = 0 then ()
       else (eat (); int (x - 1))
  in int n

;;
main ();;

let next_int ()=
	Scanf.scanf " %d" (function i -> i);;

let next_string ()=
	Scanf.scanf " %s" (function i -> i);;

let string_of_char c =
	String.make 1 c
;;

let n = next_int();;

let rec read n =
	if n = 0 then []
	else next_string() :: (read (n - 1))
;;

let data = read n;;

let change s =
	let len = String.length s in
	if len <= 10 then s
	else string_of_char (String.get s 0) ^ (string_of_int (len - 2)) ^ string_of_char (String.get s (len - 1))
;;

let ans = List.map change data;;

List.map (function x -> print_endline x) (List.rev ans);;

let n=read_int();;
for i=1 to n do
    let str=read_line() in
    let va=String.length(str) in
    if va<=10 then print_endline(str) else print_endline((String.make 1 str.[0])^(string_of_int (va-2))^(String.make 1 str.[va-1]));
done;;

let abbr s =
  let len = String.length s in
  let head = String.sub s 0 1 in
  let last = String.sub s (len - 1) 1
  in
  if 10 < len then
    head ^ (string_of_int (len - 2)) ^ last
  else
    s
;;

let make_list n =
  Array.to_list (Array.init n (fun _ -> read_line ()))
;;

(* solve :: bytes list -> bytes *)
let solve xs =
  String.concat "\n" (List.map abbr xs)
;;

let () =
  Printf.printf "%s\n"
                (solve (make_list (read_int ())))
;;

let rec read_lines n =
  match n with
  | 0 -> []
  | _ -> (read_line ()) :: read_lines (n - 1)

let () =
  let num = read_int() in
  read_lines num
  |> List.rev
  |> List.iter (fun str ->
      let len = String.length str in
      if len <= 10
      then
        Printf.printf "%s\n" str
      else
        Printf.printf "%c%d%c\n" str.[0] (len - 2) str.[len - 1]
    )
;;

open Scanf
open Num
open Printf
open String

let n = Scanf.bscanf Scanf.Scanning.stdin "%d " ( fun x -> x)

for i = 1 to n do
  let s = Scanf.bscanf Scanf.Scanning.stdin "%s " ( fun x -> x) in
  let l = length s in
  if ( l <= 10) then
    print_endline s
  else
      let s1 = String.make 1 (String.get s 0) in
      let se = String.make 1 (String.get s ( l - 1)) in
      let num = string_of_int ( l - 2 ) in
      print_endline (s1 ^ num ^ se)
done

let abbrev word =
    let len = (String.length word) in
    if len < 11 then word
    else (String.make 1 (String.get word 0))
    ^ (string_of_int (len-2))
    ^ (String.make 1 (String.get word (len-1)))

let main () =
    let gr () = Scanf.scanf " %d\n" (fun i -> i) in
    let n = gr () in
    for i = 1 to n do
        let grr () = Scanf.scanf "%s\n" (fun i -> i) in
        let word = grr () in
        Printf.printf "%s\n" (abbrev word)
    done
;;

let _ = main();;

let len word = String.length word;;
let first word = String.make 1 (String.get word 0);;
let last word = String.make 1 (String.get word ((len word) - 1));;
let abbr word = (first word) ^ (string_of_int ((len word) - 2)) ^ (last word);;
let solve word = if len word > 10 then abbr word else word;;

let rec read_and_solve n = if n > 0 then (
  Scanf.scanf "%s\n" (fun s -> print_string ((solve s) ^ "\n"));
  read_and_solve (n - 1);
) else ();;

let () = Scanf.scanf "%d\n" read_and_solve;;

open Printf
open Scanf

let id x = x

let abbreviate s =
  let n = String.length s in
  if n > 10 then sprintf "%c%d%c" s.[0] (n - 2) s.[n-1] else s

let () =
  let n = scanf " %d" id in
  for i = 1 to n do begin
    let s = scanf " %s" id in
    let t = abbreviate s in
    printf "%s\n" t
  end done

let trans = function
  | s when (String.length s) <= 10 -> s
  | s -> let head = String.get s 0
    and len = String.length s in
    let tail = String.get s (len - 1)
    in
    Printf.sprintf "%c%d%c" head (len - 2) tail;;

let case_num = read_int ();;
for i = 1 to case_num do
  let s = read_line ()
  in Printf.printf "%s\n" (trans s)
done ;;

open Printf

let compress word =
    let l = String.length word in
    if l > 10 then
        sprintf "%c%d%c" (word.[0]) (l - 2) (word.[l - 1])
    else
        word

let main =
    let n = read_int() in
    for i = 1 to n do
        let word = read_line() in
        printf "%s\n" (compress word)
    done

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

let () =
  let n = read_int() in
    for i=1 to n do
      let s = read_string() in
      let l = String.length s in
      if l > 10 then Printf.printf "%c%d%c\n" s.[0] (l - 2) s.[l - 1]
      else  print_endline s
    done

let _ =
    let main () =
        let n = read_int () in
        for i = 1 to n do
            let s = read_line () in
            let l = String.length s in
            if l > 10 then (
                Printf.printf "%c%d%c\n" s.[0] (l - 2) s.[l - 1]
            ) else print_endline s
        done
    in
    main ()

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

let abbreviate w =
    let l = String.length w in
    let first_char = String.make 1 (String.get w 0) in
    let last_char = String.make 1 (String.get w (l - 1)) in
    if l > 10
    then first_char ^ Pervasives.string_of_int (l - 2) ^ last_char
    else w

let rec reading_words n =
    if n > 0
    then
        let word = Scanf.scanf "%s " (fun word -> word) in
        Printf.printf "%s\n" (abbreviate word);
        reading_words (n - 1)
    else
    ()

let () = reading_words number_of_words

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

let abbreviate w =
    let l = String.length w in
    let first_char = String.make 1 (String.get w 0) in
    let last_char = String.make 1 (String.get w (l - 1)) in
    if l > 10
    then first_char ^ string_of_int (l - 2) ^ last_char
    else w

let rec reading_words n =
    if n > 0
    then
        let word = Scanf.scanf "%s " (fun word -> word) in
        Printf.printf "%s\n" (abbreviate word);
        reading_words (n - 1)
    else
    ()

let () = reading_words number_of_words

(* Code Forces : Way Too Long Words *)

open Scanf
open Printf

let i = scanf " %d" (fun i -> i)

let l_w =
  let rec loop i out =
    if i = 0 then
      out
    else
      loop (i-1) ((scanf " %s" (fun w -> w))::out)
  in loop i []

let () =
  let l_w' =
    List.rev_map
      (fun w ->
        let len = String.length w in
        if len > 10 then
          let b = String.sub w 0 1 in
          let e = String.sub w (len - 1) 1 in
          let slen = string_of_int (len-2) in
          b ^ slen ^ e
        else
          w)
      l_w
  in
  List.iter (fun w -> printf "%s\n" w) l_w'

let () =
  let n=read_int () in
  for i=1 to n do
    let s=read_line () in
    let len=String.length s in
    if len > 10 then
      print_endline ((String.sub s 0 1) ^ (string_of_int(len - 2)) ^ (String.sub s (len - 1) 1))
    else
      print_endline s
  done

for i=1to read_int()do let s,c=read_line(),print_char in let l=String.length s in if l>10then(c s.[0];print_int(l-2);c s.[l-1])else print_string s; c '\n' done

let short s =
	let len = String.length s in
	if len > 10 then
		(String.sub s 0 1) ^ (string_of_int (len-2)) ^ (String.sub s (len-1) 1)
	else
		s
;;

let () =
	let n = read_int() in
	for i = 1 to n do print_string (short (read_line()) ^ "\n") done
;;

let readList n f =
  let rec loop n =
    if n == 0 then
      []
    else
      f() :: loop (n-1)
  in
  List.rev(loop n);;

let solve() =
  let str = read_line() in
  let len = String.length str in
  if (len) <= 10 then
    Printf.printf "%s\n" str
  else
    Printf.printf "%c%d%c\n" (str.[0]) (len-2) (str.[len-1]);;

let n = read_int() in
readList n solve

let process s len =
    String.sub s 0 1 ^ string_of_int (len-2) ^ String.sub s (len-1) 1

let rec solve n =
    match n with
    | 0 -> ()
    | n ->
        let s = read_line () in
        let f s =
            let len = String.length s in
            match s with
            | s when len <= 10 -> print_string (s ^ "\n")
            | s -> print_string ((process s len) ^ "\n")
        in let top n =
            f s;
            solve (n-1) in top n

let n = read_int() in
    solve n

let n=read_int();;
for i=1 to n do
   let s=read_line() in
   if String.length(s)<=10 then print_endline(s)
   else print_endline((String.sub s 0 1)^string_of_int(String.length(s)-2)^(String.sub s (String.length(s)-1) 1))
done;;

let () =
  let n = read_int () in
  for i = 1 to n do
    let str = read_line () in
    let len = String.length str in
    if len>10 then
      Printf.printf "%c%d%c\n" (String.get str 0) (len-2) (String.get str (len-1))
    else
      Printf.printf "%s\n" str
  done;;

let _ =
    let main () =
        let n = read_int () in
        for i = 1 to n do
            let s = read_line () in
            let l = String.length s in
            if l >= 10 then (
                Printf.printf "%c%d%c\n" s.[0] (l - 2) s.[l - 1]
            ) else print_endline s
        done
    in
    main ()

let input () =
  Scanf.bscanf Scanf.Scanning.stdin "%s" (fun x -> x)

let main () =
  let s = input ()
  in let len = String.length s
  in if len > 10 then
    Printf.printf "%c%d%c" (String.get s 0) (len - 2) (String.get s (len - 1))
  else
    Printf.printf "%s" s
;;

main ();;

let n=read_int();;
for i=1 to n do
   let s=read_line() in
   if String.length(s)<10 then print_endline(s)
   else print_endline((String.sub s 0 1)^string_of_int(String.length(s)-2)^(String.sub s (String.length(s)-1) 1))
done;;

let rec read_lines n =
  match n with
  | 0 -> []
  | _ -> (read_line ()) :: read_lines (n - 1)

let () =
  let num = read_int() in
  read_lines num
  |> List.rev
  |> List.iter (fun str ->
      let len = String.length str in
      if len <= num
      then
        Printf.printf "%s\n" str
      else
        Printf.printf "%c%d%c\n" str.[0] (len - 2) str.[len - 1]
    )
;;

let rec read_lines n =
  match n with
  | 0 -> []
  | _ -> (read_line ()) :: read_lines (n - 1)

let () =
  let num = read_int() in
  read_lines num
  |> List.iter (fun str ->
      let len = String.length str in
      if len <= num
      then
        Printf.printf "%s\n" str
      else
        Printf.printf "%c%d%c\n" str.[0] (len - 2) str.[len - 1]
    )
;;

let abbrev word =
    let len = (String.length word) in
    if len < 10 then word
    else (String.make 1 (String.get word 0))
    ^ (string_of_int (len-2))
    ^ (String.make 1 (String.get word (len-1)))

let main () =
    let gr () = Scanf.scanf " %d\n" (fun i -> i) in
    let n = gr () in
    for i = 1 to n do
        let grr () = Scanf.scanf "%s\n" (fun i -> i) in
        let word = grr () in
        Printf.printf "%s\n" (abbrev word)
    done
;;

let _ = main();;


let find x t = let rep = ref 0 in
  for i = 0 to Array.length t -1 do
    if t.(i) = x then rep:=i ;
  done ;
  !rep ;;

let inverse s n1 n2 = let rep = ref "" in
  let pile = Stack.create () in
  for i = 0 to Array.length s -1 do
    let popo = if i = Array.length s -1 then "" else " " in
    if i<n1 || i>n2 then (rep := (!rep)^(string_of_int s.(i)^popo))
    else (
      if i = n2 then (Stack.push s.(i) pile ; for j = n1 to n2 -1 do rep := (!rep)^(string_of_int (Stack.pop pile))^" ";done; rep:=(!rep)^(string_of_int (Stack.pop pile))^popo)
      else (Stack.push s.(i) pile ) )
  done ; !rep ;;

let to_t s len = let t = Array.make len 0 in
  let temp = ref "" in
  let inc = ref 0 in
  for i = 0 to String.length s -1 do
    if s.[i] = ' ' then (t.(!inc)<- int_of_string (!temp); incr inc ; temp:= "" )else
      temp := !temp^(String.make 1 (s.[i])) done ; t.(!inc)<- int_of_string (!temp); t;;

let n = int_of_string(input_line stdin) in

for i = 0 to n-1 do
  let len = int_of_string(input_line stdin) in
  let str = (input_line stdin) in
  let t = to_t str len in
  let finito = ref false in
  let interest = ref (-1,-1) in
  for j = 0 to Array.length t -1  do
    if not(!finito) && (t.(j))<>j+1 then
      (interest := (j,find (j+1) t) ;
       finito := true)
  done ;
  let rety = if !interest <> (-1,-1) then
      (let a,b = !interest in inverse t a b )
    else str in
  print_endline rety
done;
;;

(* Codeforces 1638 A Reverse train *)

(* you can use either gr or rdln but not both *)
let gr () = Scanf.scanf " %d" (fun i -> i);;
let grf () = Scanf.scanf " %f" (fun i -> i);;
let grl () = Scanf.scanf " %Ld" (fun i -> i);;
let rdln() = input_line stdin;;
(* let spli s = Str.split (Str.regexp " ") s;; *)
let printlisti li = List.iter (fun i -> (print_int i; print_string " ")) li;;
let printarri ai = Array.iter (fun i -> (print_int i; print_string " ")) ai;;
let debug = false;;

(* reading list *)
let rec readlist n acc = match n with
	| 0 -> List.rev acc
	| _ -> readlist (n -1) (gr() :: acc);;
let printlisti li = List.iter (fun i -> (print_int i; print_string " ")) li;;
let printlists ls = List.iter (fun s -> (print_string s; print_string " ")) ls;;
let list_to_s li = String.concat " " (List.map string_of_int li);;

let rec extract_smallest_start i first l = match l with
    | [] -> (i, [])
    | h :: t ->
        if h == i then extract_smallest_start (i+1) (h :: first) t
        else
        (i, l);;

let rec get_until_a a part l = match l with
    | [] -> (part, l)
    | h :: t ->
        if h == a then (a :: part, t)
                  else get_until_a a (h :: part) t;;

let rec generater n = if n==0 then [] else n :: generater (n-1);;
let generate n = List.rev (generater n);;

let do_one () =
    let n = gr () in
    let p = readlist n [] in
    let nfirst, pl = extract_smallest_start 1 [] p in
    (*let _ = Printf.printf "nfirst = %d\n" nfirst in
    let _ = Printf.printf "pl: %s\n" (list_to_s pl) in*)
    let pend = if List.length pl == 0 then []
        else
            ( let revpart, pla = get_until_a nfirst [] pl in
            (List.append revpart pla)) in
    let lret = List.append (generate (nfirst-1)) pend in
    (printlisti lret; print_string "\n");;

let do_all () =
    let t = gr () in
    for i = 1 to t do
        do_one ()
    done;;

let main() =
	do_all ();;

main();;

let find x s = let rep = ref 0 in
  for i = 0 to String.length s -1 do
    if s.[i] = (string_of_int(x)).[0] then rep:=i ;
  done ;
  !rep ;;

let inverse s n1 n2 = let rep = ref "" in
  let pile = Stack.create () in
  for i = 0 to String.length s -1 do
    if i<n1 || i>n2 then (rep := (!rep)^(String.make 1 (s.[i])))
    else (
      if i = n2 then (Stack.push (String.make 1 (s.[i])) pile ; for j = n1 to n2 do rep := (!rep)^(Stack.pop pile);done;)
      else (
        (String.make 1 (s.[i])) ;  Stack.push (String.make 1 (s.[i])) pile ))
  done ; !rep ;;

let n = int_of_string(input_line stdin) in

for i = 0 to n-1 do
  let len = int_of_string(input_line stdin) in
  let str = (input_line stdin) in
  let finito = ref false in
  let interest = ref (-1,-1) in
  for j = 0 to String.length str -1  do
    if str.[j] <> ' ' && not(!finito) && str.[j]<>(string_of_int (j/2 +1)).[0] then
      (prerr_endline (string_of_int j);
       interest := (j,find (j/2 +1) str) ;
       finito := true)
  done ;
  let rety = if !interest <> (-1,-1) then
      (let a,b = !interest in inverse str a b )
    else str in
  print_endline rety
done;
;;


let _ =
  let sb = Scanf.Scanning.stdib in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let m = Scanf.bscanf sb "%d " (fun s -> s) in
  let a = Array.make_matrix n m (-1) in
  let b = Array.make_matrix n m (-1) in
  let res = ref 0 in
  let pred = ref 10 in
  let rec bf x y k =
    (*Printf.printf "asd %d %d  %d\n" x y k;
    for i = 0 to n - 1 do
      for j = 0 to m - 1 do
	Printf.printf "%d " a.(i).(j)
      done;
      Printf.printf "\n"
    done;*)
    let x = ref x in
    let y = ref y in
      while !x < n && a.(!x).(!y) >= 0 do
	incr x
      done;
    (*Printf.printf "qwe %d %d  %d\n" !x !y k;
    for i = 0 to n - 1 do
      for j = 0 to m - 1 do
	Printf.printf "%d " a.(i).(j)
      done;
      Printf.printf "\n"
    done;*)
      if !x = n then (
	if !y < m - 1 then (
	  x := 0;
	  incr y;
	  bf !x !y k;
	) else (
	  if !res < k then (
	    res := k;
	    for i = 0 to n - 1 do
	      for j = 0 to m - 1 do
		b.(i).(j) <- a.(i).(j)
	      done
	    done;
	    if !res >= !pred then raise Not_found
	  )
	)
      ) else (
	let x = !x
	and y = !y in
	  if x <= n - 3 && y <= m - 3 &&
	    a.(x).(y + 1) < 0 &&
	    a.(x).(y + 2) < 0 &&
	    a.(x + 1).(y + 1) < 0 &&
	    a.(x + 2).(y + 1) < 0
	  then (
	    a.(x).(y) <- k;
	    a.(x).(y + 1) <- k;
	    a.(x).(y + 2) <- k;
	    a.(x + 1).(y + 1) <- k;
	    a.(x + 2).(y + 1) <- k;
	    bf x y (k + 1);
	    a.(x).(y) <- -1;
	    a.(x).(y + 1) <- -1;
	    a.(x).(y + 2) <- -1;
	    a.(x + 1).(y + 1) <- -1;
	    a.(x + 2).(y + 1) <- -1;
	  );
	  if 1 <= x && x <= n - 2 && y <= m - 3 &&
	    a.(x).(y + 1) < 0 &&
	    a.(x).(y + 2) < 0 &&
	    a.(x + 1).(y + 2) < 0 &&
	    a.(x - 1).(y + 2) < 0
	  then (
	    a.(x).(y) <- k;
	    a.(x).(y + 1) <- k;
	    a.(x).(y + 2) <- k;
	    a.(x + 1).(y + 2) <- k;
	    a.(x - 1).(y + 2) <- k;
	    bf x y (k + 1);
	    a.(x).(y) <- -1;
	    a.(x).(y + 1) <- -1;
	    a.(x).(y + 2) <- -1;
	    a.(x + 1).(y + 2) <- -1;
	    a.(x - 1).(y + 2) <- -1;
	  );
	  if 2 <= x && x <= n - 1 && y <= m - 3 &&
	    a.(x).(y + 1) < 0 &&
	    a.(x).(y + 2) < 0 &&
	    a.(x - 1).(y + 1) < 0 &&
	    a.(x - 2).(y + 1) < 0
	  then (
	    a.(x).(y) <- k;
	    a.(x).(y + 1) <- k;
	    a.(x).(y + 2) <- k;
	    a.(x - 1).(y + 1) <- k;
	    a.(x - 2).(y + 1) <- k;
	    bf x y (k + 1);
	    a.(x).(y) <- -1;
	    a.(x).(y + 1) <- -1;
	    a.(x).(y + 2) <- -1;
	    a.(x - 1).(y + 1) <- -1;
	    a.(x - 2).(y + 1) <- -1;
	  );
	  if x <= n - 3 && y <= m - 3 &&
	    a.(x + 1).(y) < 0 &&
	    a.(x + 2).(y) < 0 &&
	    a.(x + 1).(y + 1) < 0 &&
	    a.(x + 1).(y + 2) < 0
	  then (
	    a.(x).(y) <- k;
	    a.(x + 1).(y) <- k;
	    a.(x + 2).(y) <- k;
	    a.(x + 1).(y + 1) <- k;
	    a.(x + 1).(y + 2) <- k;
	    bf x y (k + 1);
	    a.(x).(y) <- -1;
	    a.(x + 1).(y) <- -1;
	    a.(x + 2).(y) <- -1;
	    a.(x + 1).(y + 1) <- -1;
	    a.(x + 1).(y + 2) <- -1;
	  );
	  bf (x + 1) y k;
      )
  in
    (match n, m with
       | 9, 9 -> pred := 13
       | 8, 9 -> pred := 12
       | 9, 8 -> pred := 12
       | 8, 8 -> pred := 10
       | 7, 9 -> pred := 10
       | 9, 7 -> pred := 10
       | 7, 8 -> pred := 9
       | 8, 7 -> pred := 9
       | _ -> ()
    );
    (try bf 0 0 0 with Not_found -> ());
    Printf.printf "%d\n" !res;
    for i = 0 to n - 1 do
      for j = 0 to m - 1 do
	let v = b.(i).(j) in
	let c =
	  if v < 0
	  then '.'
	  else Char.chr (Char.code 'A' + v)
	in
	  Printf.printf "%c" c
      done;
      Printf.printf "\n"
    done

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

let n = read_int()
let m = read_int()

let (h,w) = (n+1,m+1)

let wall = -2
let hole = -1
let empty = 0

let a = Array.make (h*w) wall
let () =
  for i=0 to n-1 do for j=0 to m-1 do
    a.(w*i+j) <- empty
  done done

let p = Array.make 4 [||]
let () =
  p.(0) <- [|w;w+1;w+2;2*w|];
  p.(1) <- [|1;2;w+1;2*w+1|];
  p.(2) <- [|w-2;w-1;w;2*w|];
  p.(3) <- [|w;2*w-1;2*w;2*w+1|]

let rec backtrack i blanks =  (* i is the first empty space, blanks is the # of blanks left *)
  if i=h*w then true else if a.(i) != empty then backtrack (i+1) blanks else
    let rec trypiece q = if q=4 then (
      if blanks=0 then false else (
	a.(i) <- hole;
	if backtrack (i+1) (blanks-1) then true else (
	  a.(i) <- empty;
	  false
	)
      )
    ) else (
      let rec fit j = if j=4 then true else a.(i+p.(q).(j)) = 0 && (fit (j+1)) in
      let rec fill j x = if j=4 then a.(i) <- x else (
	a.(i+p.(q).(j)) <- x;
	fill (j+1) x
      )
      in
	if not (fit 0) then trypiece (q+1) else (
	  fill 0 (i+1);
	  if backtrack (i+1) blanks then true else (
	    fill 0 empty;
	    trypiece (q+1)
	  )
	)
    )
    in
      trypiece 0

let rec tryblanks b = if backtrack 0 b then b else tryblanks (b+5)

let () =
  let blanks = tryblanks (n*m mod 5) in
  let lab = Array.make (h*w) (-1) in
  let rec labels i c = if i=h*w then () else (
    if a.(i)=hole || a.(i)=wall || lab.(a.(i)) >= 0 then labels (i+1) c else (
      lab.(a.(i)) <- c;
      labels (i+1) (c+1)
    )
  )
  in
    Printf.printf "%d\n" (((n*m)-blanks)/5);
    labels 0 0;
    for i=0 to n-1 do
      for j=0 to m-1 do
	let c = if a.(w*i+j) = hole then '.' else char_of_int ((int_of_char 'A') + lab.(a.(w*i+j))) in
	  print_char c
      done;
      print_newline ()
    done

let _ =
  let sb = Scanf.Scanning.stdib in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let m = Scanf.bscanf sb "%d " (fun s -> s) in
  let n = min n m
  and m = max n m in
  let a = Array.make_matrix n m (-1) in
  let b = Array.make_matrix n m (-1) in
  let res = ref 0 in
  let pred = ref 10 in
  let rec bf x y k =
    (*Printf.printf "asd %d %d  %d\n" x y k;
    for i = 0 to n - 1 do
      for j = 0 to m - 1 do
	Printf.printf "%d " a.(i).(j)
      done;
      Printf.printf "\n"
    done;*)
    let x = ref x in
    let y = ref y in
      while !x < n && a.(!x).(!y) >= 0 do
	incr x
      done;
    (*Printf.printf "qwe %d %d  %d\n" !x !y k;
    for i = 0 to n - 1 do
      for j = 0 to m - 1 do
	Printf.printf "%d " a.(i).(j)
      done;
      Printf.printf "\n"
    done;*)
      if !x = n then (
	if !y < m - 1 then (
	  x := 0;
	  incr y;
	  bf !x !y k;
	) else (
	  if !res < k then (
	    res := k;
	    for i = 0 to n - 1 do
	      for j = 0 to m - 1 do
		b.(i).(j) <- a.(i).(j)
	      done
	    done;
	    if !res >= !pred then raise Not_found
	  )
	)
      ) else (
	let x = !x
	and y = !y in
	  if x <= n - 3 && y <= m - 3 &&
	    a.(x).(y + 1) < 0 &&
	    a.(x).(y + 2) < 0 &&
	    a.(x + 1).(y + 1) < 0 &&
	    a.(x + 2).(y + 1) < 0
	  then (
	    a.(x).(y) <- k;
	    a.(x).(y + 1) <- k;
	    a.(x).(y + 2) <- k;
	    a.(x + 1).(y + 1) <- k;
	    a.(x + 2).(y + 1) <- k;
	    bf x y (k + 1);
	    a.(x).(y) <- -1;
	    a.(x).(y + 1) <- -1;
	    a.(x).(y + 2) <- -1;
	    a.(x + 1).(y + 1) <- -1;
	    a.(x + 2).(y + 1) <- -1;
	  );
	  if 1 <= x && x <= n - 2 && y <= m - 3 &&
	    a.(x).(y + 1) < 0 &&
	    a.(x).(y + 2) < 0 &&
	    a.(x + 1).(y + 2) < 0 &&
	    a.(x - 1).(y + 2) < 0
	  then (
	    a.(x).(y) <- k;
	    a.(x).(y + 1) <- k;
	    a.(x).(y + 2) <- k;
	    a.(x + 1).(y + 2) <- k;
	    a.(x - 1).(y + 2) <- k;
	    bf x y (k + 1);
	    a.(x).(y) <- -1;
	    a.(x).(y + 1) <- -1;
	    a.(x).(y + 2) <- -1;
	    a.(x + 1).(y + 2) <- -1;
	    a.(x - 1).(y + 2) <- -1;
	  );
	  if 2 <= x && x <= n - 1 && y <= m - 3 &&
	    a.(x).(y + 1) < 0 &&
	    a.(x).(y + 2) < 0 &&
	    a.(x - 1).(y + 1) < 0 &&
	    a.(x - 2).(y + 1) < 0
	  then (
	    a.(x).(y) <- k;
	    a.(x).(y + 1) <- k;
	    a.(x).(y + 2) <- k;
	    a.(x - 1).(y + 1) <- k;
	    a.(x - 2).(y + 1) <- k;
	    bf x y (k + 1);
	    a.(x).(y) <- -1;
	    a.(x).(y + 1) <- -1;
	    a.(x).(y + 2) <- -1;
	    a.(x - 1).(y + 1) <- -1;
	    a.(x - 2).(y + 1) <- -1;
	  );
	  if x <= n - 3 && y <= m - 3 &&
	    a.(x + 1).(y) < 0 &&
	    a.(x + 2).(y) < 0 &&
	    a.(x + 1).(y + 1) < 0 &&
	    a.(x + 1).(y + 2) < 0
	  then (
	    a.(x).(y) <- k;
	    a.(x + 1).(y) <- k;
	    a.(x + 2).(y) <- k;
	    a.(x + 1).(y + 1) <- k;
	    a.(x + 1).(y + 2) <- k;
	    bf x y (k + 1);
	    a.(x).(y) <- -1;
	    a.(x + 1).(y) <- -1;
	    a.(x + 2).(y) <- -1;
	    a.(x + 1).(y + 1) <- -1;
	    a.(x + 1).(y + 2) <- -1;
	  );
	  bf (x + 1) y k;
      )
  in
    (match n, m with
       | 9, 9 -> pred := 13
       | 8, 9 -> pred := 12
       | 8, 8 -> pred := 10
       | 7, 9 -> pred := 10
       | 7, 8 -> pred := 9
       | _ -> ()
    );
    (try bf 0 0 0 with Not_found -> ());
    Printf.printf "%d\n" !res;
    for i = 0 to n - 1 do
      for j = 0 to m - 1 do
	let v = b.(i).(j) in
	let c =
	  if v < 0
	  then '.'
	  else Char.chr (Char.code 'A' + v)
	in
	  Printf.printf "%c" c
      done;
      Printf.printf "\n"
    done

let _ =
  let sb = Scanf.Scanning.stdib in
  let n = Scanf.bscanf sb "%d " (fun s -> s) in
  let m = Scanf.bscanf sb "%d " (fun s -> s) in
  let n = min n m
  and m = max n m in
  let a = Array.make_matrix n m (-1) in
  let b = Array.make_matrix n m (-1) in
  let res = ref 0 in
  let pred = ref 10 in
  let rec bf x y k =
    (*Printf.printf "asd %d %d  %d\n" x y k;
    for i = 0 to n - 1 do
      for j = 0 to m - 1 do
	Printf.printf "%d " a.(i).(j)
      done;
      Printf.printf "\n"
    done;*)
    let x = ref x in
    let y = ref y in
      while !x < n && a.(!x).(!y) >= 0 do
	incr x
      done;
    (*Printf.printf "qwe %d %d  %d\n" !x !y k;
    for i = 0 to n - 1 do
      for j = 0 to m - 1 do
	Printf.printf "%d " a.(i).(j)
      done;
      Printf.printf "\n"
    done;*)
      if !x = n then (
	if !y < m - 1 then (
	  x := 0;
	  incr y;
	  bf !x !y k;
	) else (
	  if !res < k then (
	    res := k;
	    for i = 0 to n - 1 do
	      for j = 0 to m - 1 do
		b.(i).(j) <- a.(i).(j)
	      done
	    done;
	    if !res >= !pred then raise Not_found
	  )
	)
      ) else (
	let x = !x
	and y = !y in
	  if x <= n - 3 && y <= m - 3 &&
	    a.(x).(y + 1) < 0 &&
	    a.(x).(y + 2) < 0 &&
	    a.(x + 1).(y + 1) < 0 &&
	    a.(x + 2).(y + 1) < 0
	  then (
	    a.(x).(y) <- k;
	    a.(x).(y + 1) <- k;
	    a.(x).(y + 2) <- k;
	    a.(x + 1).(y + 1) <- k;
	    a.(x + 2).(y + 1) <- k;
	    bf x y (k + 1);
	    a.(x).(y) <- -1;
	    a.(x).(y + 1) <- -1;
	    a.(x).(y + 2) <- -1;
	    a.(x + 1).(y + 1) <- -1;
	    a.(x + 2).(y + 1) <- -1;
	  );
	  if 1 <= x && x <= n - 2 && y <= m - 3 &&
	    a.(x).(y + 1) < 0 &&
	    a.(x).(y + 2) < 0 &&
	    a.(x + 1).(y + 2) < 0 &&
	    a.(x - 1).(y + 2) < 0
	  then (
	    a.(x).(y) <- k;
	    a.(x).(y + 1) <- k;
	    a.(x).(y + 2) <- k;
	    a.(x + 1).(y + 2) <- k;
	    a.(x - 1).(y + 2) <- k;
	    bf x y (k + 1);
	    a.(x).(y) <- -1;
	    a.(x).(y + 1) <- -1;
	    a.(x).(y + 2) <- -1;
	    a.(x + 1).(y + 2) <- -1;
	    a.(x - 1).(y + 2) <- -1;
	  );
	  if 2 <= x && x <= n - 1 && y <= m - 3 &&
	    a.(x).(y + 1) < 0 &&
	    a.(x).(y + 2) < 0 &&
	    a.(x - 1).(y + 1) < 0 &&
	    a.(x - 2).(y + 1) < 0
	  then (
	    a.(x).(y) <- k;
	    a.(x).(y + 1) <- k;
	    a.(x).(y + 2) <- k;
	    a.(x - 1).(y + 1) <- k;
	    a.(x - 2).(y + 1) <- k;
	    bf x y (k + 1);
	    a.(x).(y) <- -1;
	    a.(x).(y + 1) <- -1;
	    a.(x).(y + 2) <- -1;
	    a.(x - 1).(y + 1) <- -1;
	    a.(x - 2).(y + 1) <- -1;
	  );
	  if x <= n - 3 && y <= m - 3 &&
	    a.(x + 1).(y) < 0 &&
	    a.(x + 2).(y) < 0 &&
	    a.(x + 1).(y + 1) < 0 &&
	    a.(x + 1).(y + 2) < 0
	  then (
	    a.(x).(y) <- k;
	    a.(x + 1).(y) <- k;
	    a.(x + 2).(y) <- k;
	    a.(x + 1).(y + 1) <- k;
	    a.(x + 1).(y + 2) <- k;
	    bf x y (k + 1);
	    a.(x).(y) <- -1;
	    a.(x + 1).(y) <- -1;
	    a.(x + 2).(y) <- -1;
	    a.(x + 1).(y + 1) <- -1;
	    a.(x + 1).(y + 2) <- -1;
	  );
	  bf (x + 1) y k;
      )
  in
    (match n, m with
       | 9, 9 -> pred := 13
       | 8, 9 -> pred := 12
       | 7, 9 -> pred := 10
       | 7, 8 -> pred := 9
       | _ -> ()
    );
    (try bf 0 0 0 with Not_found -> ());
    Printf.printf "%d\n" !res;
    for i = 0 to n - 1 do
      for j = 0 to m - 1 do
	let v = b.(i).(j) in
	let c =
	  if v < 0
	  then '.'
	  else Char.chr (Char.code 'A' + v)
	in
	  Printf.printf "%c" c
      done;
      Printf.printf "\n"
    done


(* 2n+1, 1 then second player wins
since 1st moves 2a-1, 2nd moves 2(n-a)+1, leaving 1,1 for first.

2n,1 then first player wins since first moves 2n-1
which leaves second with 1,1

2n,2m then 2x+1,2m so second player wins.
2n+1,2m then first moves 2m-1 leaving 2n+1,1 and that means
first player wins as second player must go first in this grid type.

2n+1,2m+1 then first player moves 2a-1 in either direction so
second should move in that direction s.t 1,2m+1 or 2n+1,1 which means they win as the player that
needs to go seconds in the config wins.
*)

let read_long () = Scanf.scanf " %Ld" (fun l-> l);;
let read_int () = Scanf.scanf " %d" (fun x-> x);;
let run_case = function
| () ->
     let n = read_long () in
     let m = read_long () in
     let nrem = Int64.sub n (Int64.mul (Int64.div n 2L) 2L) in
     let mrem = Int64.sub m (Int64.mul (Int64.div m 2L) 2L) in
     if ((nrem=0L)&&(mrem=0L)) then print_string "Tonya"
     else if ((nrem=0L)||(mrem=0L)) then print_string "Burenka"
     else print_string "Tonya"
;;

let rec iter_cases = function
| 0->()
| t -> run_case (); print_newline (); iter_cases (t-1)
;;

let t=read_int () in iter_cases t;;

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

let () =
  let t = read_int () in
  for _ = 1 to t do
    let n = read_int () in
    let m = read_int () in
    if (n + m) mod 2 = 0 then
      Printf.printf "Tonya\n"
    else
      Printf.printf "Burenka\n"
  done;


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

let best_time pos spd =
  let n = Array.length pos in
  let max_x = float_of_int (Array.fold_left max min_int pos) in
  let min_v = float_of_int (Array.fold_left min max_int spd) in
  let merge (a, b) (c, d) = (max a c, min b d) in
  let feasible_time t =
    let range = ref (neg_infinity, infinity) in
    for i = 0 to (n-1) do
      let (x, dx) = (float_of_int pos.(i), float_of_int spd.(i) *. t) in
      range := merge !range (x -. dx, x +. dx)
    done;
    let (a, b) = !range in a <= b
  in
  let rec find lo hi it =
    if (hi -. lo) < epsilon_float || it >= 64
    then lo
    else
      let m = lo +. (hi -. lo) /. 2. in
      if feasible_time m
      then find lo m (it + 1)
      else find (m +. epsilon_float) hi (it + 1)
  in
  find 0.0 (max_x /. min_v) 0

let () =
  let n = Scanf.scanf "%d" (fun x -> x) in
  let pos = read_array n in
  let spd = read_array n in
  Printf.printf "%10.12f\n" (best_time pos spd)

open Printf
open Scanf

let read_int _ = bscanf Scanning.stdib " %d " (fun x -> x)
let read_float _ = bscanf Scanning.stdib " %f " (fun x -> x)

let () =
  let n = read_int () in
  let x = Array.init n read_float in
  let v = Array.init n read_float in

  let intersect (lo1,hi1) (lo2,hi2) = (max lo1 lo2, min hi1 hi2) in
  let no_overlap (lo,hi) = lo > hi in

  let overlap_interval t =
  (* given time t, if they overlap return Some (lo,hi) else None *)
    let rec loop oldinterval i =
      if i=n then Some oldinterval else
	let my_hi = x.(i) +. t *. v.(i) in
	let my_lo = x.(i) -. t *. v.(i) in
	let newinterval = if i=0 then (my_lo,my_hi) else intersect (my_lo,my_hi) oldinterval in
	if no_overlap newinterval then None else loop newinterval (i+1)
    in
    loop (0.0, 0.0) 0
  in

  let rec bsearch lo_t hi_t count =  (* hi has overlap, lo has no overlap *)
    if count = 50 then hi_t else
      let m = (lo_t +. hi_t) /. 2.0 in
      match overlap_interval m with
	| None -> bsearch m hi_t (count+1)
	| Some _ -> bsearch lo_t m (count+1)
  in

  let rec find_hi t = match overlap_interval t with None -> find_hi (2.0 *. t) | Some _ -> t in

  let answer = match overlap_interval 0.0 with Some _ -> 0.0
    | None -> bsearch 0.0 (find_hi 1.0) 0
  in

  printf "%.10f\n" answer

open Printf
open Scanf

let read_int _ = bscanf Scanning.stdib " %d " (fun x -> x)
let read_float _ = bscanf Scanning.stdib " %f " (fun x -> x)

let () =
  let n = read_int () in
  let x = Array.init n read_float in
  let v = Array.init n read_float in

  let intersect (lo1,hi1) (lo2,hi2) = (max lo1 lo2, min hi1 hi2) in
  let no_overlap (lo,hi) = lo > hi in

  let overlap_interval t =
  (* given time t, if they overlap return Some (lo,hi) else None *)
    let rec loop oldinterval i =
      if i=n then Some oldinterval else
	let my_hi = x.(i) +. t *. v.(i) in
	let my_lo = x.(i) -. t *. v.(i) in
	let newinterval = if i=0 then (my_lo,my_hi) else intersect (my_lo,my_hi) oldinterval in
	if no_overlap newinterval then None else loop newinterval (i+1)
    in
    loop (0.0, 0.0) 0
  in

  let rec bsearch lo_t hi_t count =  (* hi has overlap, lo has no overlap *)
    if count = 50 then hi_t else
      let m = (lo_t +. hi_t) /. 2.0 in
      match overlap_interval m with
	| None -> bsearch m hi_t (count+1)
	| Some _ -> bsearch lo_t m (count+1)
  in

  let rec find_hi t = match overlap_interval t with None -> find_hi (2.0 *. t) | Some _ -> t in

  let answer = match overlap_interval 0.0 with Some (lo,hi) -> lo | None ->
    bsearch 0.0 (find_hi 1.0) 0
  in

  printf "%.10f\n" answer


let rd_int = (fun () -> Scanf.scanf " %d" (fun n -> n)) in
let pri i = print_string ((string_of_int i) ^ " ") in
let n = rd_int () in
let rec make_list n =
    if n == 0 then
        []
    else
        let num = rd_int () in
        num :: make_list (n - 1)
in
let a = make_list n in
let rec pr_list k l rl =
    if k >= n then
        ()
    else

        match l with
        | [] -> ()
        | hd :: tl ->
                match rl with
                | [] -> ()
                | hdr :: tlr ->
                        let _ = pri hdr in
                        let _ = pr_list (k + 2) tlr tl in
                        if k + 1 == n then () else pri hd
in
pr_list 0 a (List.rev a);;

let () =
  let n = read_int () in
  (* values *)
  let a = Array.init n (fun _ -> Scanf.scanf "%d%_c" (fun x -> x)) in
  (* permutation *)
  let p = Array.init n (fun i ->
                       if i mod 2 = (if n mod 2 = 0 && i >= n / 2 then 1 else 0)
                       then a.(n - i - 1)
                       else a.(i)) in
  (* output *)
  print_endline (String.concat " " (Array.to_list (Array.map string_of_int p)))

let print_array a =
    for k = 0 to (Array.length a) - 1 do
        print_int a.(k);
        print_char ' ';
    done;

    print_newline ();
;;

let rearrange_blocks a =
    let n = Array.length a in
    let n_2 = n / 2 in
    let n_4 = (n_2 + 1) / 2 in
    for j = 0 to (n_4 - 1) do
        let k = j * 2 in
        let tmp = a.(k) in
        begin
            a.( k ) <- a.( n - k - 1 );
            a.( n - k - 1 ) <- tmp;
        end
    done;
    print_array a;
;;

let rec read_block a k =
    if k < (Array.length a) then
        Scanf.bscanf Scanf.Scanning.stdin "%i " (add_block a k)
    else
        rearrange_blocks a
and add_block a k v =
    begin
        a.(k) <- v;
        read_block a (k + 1)
    end
;;

let read_blocks n =
    let blocks = Array.make n 0 in
    read_block blocks 0
;;

read_blocks (read_int ());;


(* Feeding Chicken
 * https://codeforces.com/contest/1254/problem/A *)

(* I shouldn't need explicitly named record fields. But I wanted to
 * practice the notation. *)
type cell = {coords: int * int; has_rice: bool}
type assignment = {coords: int * int; chicken: int}

(* Converts a board into a list of cells, in snake order. *)
let cells_of_board n m (board: string array) =
  let next (i, j) = match (i mod 2, j) with
    | (0, k) when k = m - 1 -> (i + 1, j)
    | (0, _)                -> (i, j + 1)
    | (_, 0)                -> (i + 1, j)
    | _                     -> (i, j - 1) in
  let rec iter i j acc =
    if i >= n then
      acc
    else
      let (ni, nj) = next (i, j) in
      iter ni nj ({coords =  (i, j); has_rice = String.get board.(i) j = 'R'} :: acc)
  in iter 0 0 []

(* Converts a bunch of chicken assignments to an array of 'bytes' arrays representing
 * the result. *)
let result_of_assns n m (assns : assignment list) =
  let chicken_labels =
    "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" in
  (* The following didn't work! It created n references to the same array.
     It's like doing "arr = [[0] * m] * n" in Python.
     let res = Array.make n (Bytes.make m '0') in *)
     let res = Array.init n (fun _ -> Bytes.make m '0') in
  (* Ugh, imperative updates... but this is probably more efficient. *)
  let rec iter ls = match ls with
    | [] -> ()
    | {coords=(i, j); chicken = c} :: lss ->
      (Bytes.set res.(i) j (String.get chicken_labels c);
       iter lss)
  in (iter assns; res)

(* Takes a 'board' (2D array showing where the rice is) and
 * converts it to a board of chicken assignments. *)
let solve n m chicks (board: string array) =
  let cells = cells_of_board n m board in
  (* There's probably a function to do this in one go. *)
  let rice_total = List.fold_left
      (fun acc cl -> if cl.has_rice then acc + 1 else acc)
      0 cells
  in
  (* The amount of rice each chicken should have. *)
  let amt = rice_total / chicks in
  (* These are hungry chickens! They will eat amt+1 rice. *)
  let hungry = rice_total - amt * chicks in
  (* Iterate through cells and assign them chickens in order.
   * Assign the hungry chickens first, then the rest. *)
  let rec iter cls prev_chick k acc =
    match cls with
    | [] -> acc
    | {coords=crd; has_rice=hr} :: clss ->
      let mx = if prev_chick < hungry then amt + 1 else amt in
      let nk' = if hr then k + 1 else k in
      let (cur_chick, nk) = if nk' > mx then
          (prev_chick + 1, 1)
        else
          (prev_chick, nk') in
      iter clss cur_chick nk ({coords=crd; chicken=cur_chick} :: acc)
  in result_of_assns n m (iter cells 0 0 [])

let rec rep n f = if n = 0 then () else (f (); rep (n-1) f)

let main () =
  let tt = read_int () in
  rep tt (fun () ->
      (* Scanf.scanf caused Codeforces to give a runtime error for some reason *)
      let [n; m; k] =
        read_line ()
        |> Str.split (Str.regexp " ")
        |> List.map int_of_string in
      let board = Array.init n (fun _ -> read_line ()) in
      Array.iter (fun s -> (print_bytes s; print_newline ())) (solve n m k board)
    )

let _ = main ()

(* Feeding Chicken
 * https://codeforces.com/contest/1254/problem/A *)

(* I shouldn't need explicitly named record fields. But I wanted to
 * practice the notation. *)
type cell = {coords: int * int; has_rice: bool}
type assignment = {coords: int * int; chicken: int}

(* Converts a board into a list of cells, in snake order. *)
let cells_of_board n m (board: string array) =
  let next (i, j) = match (i mod 2, j) with
    | (0, k) when k = m - 1 -> (i + 1, j)
    | (0, _)                -> (i, j + 1)
    | (_, 0)                -> (i + 1, j)
    | _                     -> (i, j - 1) in
  let rec iter i j acc =
    if i >= n then
      acc
    else
      let (ni, nj) = next (i, j) in
      iter ni nj ({coords =  (i, j); has_rice = String.get board.(i) j = 'R'} :: acc)
  in iter 0 0 []

(* Converts a bunch of chicken assignments to an array of 'bytes' arrays representing
 * the result. *)
let result_of_assns n m (assns : assignment list) =
  let chicken_labels =
    "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" in
  (* The following didn't work! It created n references to the same array.
     It's like doing "arr = [[0] * m] * n" in Python.
     let res = Array.make n (Bytes.make m '0') in *)
     let res = Array.init n (fun _ -> Bytes.make m '0') in
  (* Ugh, imperative updates... but this is probably more efficient. *)
  let rec iter ls = match ls with
    | [] -> ()
    | {coords=(i, j); chicken = c} :: lss ->
      (Bytes.set res.(i) j (String.get chicken_labels c);
       iter lss)
  in (iter assns; res)

(* Takes a 'board' (2D array showing where the rice is) and
 * converts it to a board of chicken assignments. *)
let solve n m chicks (board: string array) =
  let cells = cells_of_board n m board in
  (* There's probably a function to do this in one go. *)
  let rice_total = List.fold_left
      (fun acc cl -> if cl.has_rice then acc + 1 else acc)
      0 cells
  in
  (* The amount of rice each chicken should have. *)
  let amt = rice_total / chicks in
  (* These are hungry chickens! They will eat amt+1 rice. *)
  let hungry = rice_total - amt * chicks in
  (* Iterate through cells and assign them chickens in order.
   * Assign the hungry chickens first, then the rest. *)
  let rec iter cls prev_chick k acc =
    match cls with
    | [] -> acc
    | {coords=crd; has_rice=hr} :: clss ->
      let mx = if prev_chick < hungry then amt + 1 else amt in
      let nk' = if hr then k + 1 else k in
      let (cur_chick, nk) = if nk' > mx then
          (prev_chick + 1, 1)
        else
          (prev_chick, nk') in
      iter clss cur_chick nk ({coords=crd; chicken=cur_chick} :: acc)
  in result_of_assns n m (iter cells 0 0 [])

let rec rep n f = if n = 0 then () else (f (); rep (n-1) f)

let main () =
  let tt = read_int () in
  rep tt (fun () ->
      (* Scanf.scanf caused Codeforces to give a runtime error for some reason *)
      let (n, m, k) = Scanf.sscanf (read_line ()) "%d %d %d" (fun x y z -> (x, y, z)) in
      let board = Array.init n (fun _ -> read_line ()) in
      Array.iter (fun s -> (print_bytes s; print_newline ())) (solve n m k board)
    )

let _ = main ()

(* Feeding Chicken
 * https://codeforces.com/contest/1254/problem/A *)

(* I shouldn't need explicitly named record fields. But I wanted to
 * practice the notation. *)
type cell = {coords: int * int; has_rice: bool}
type assignment = {coords: int * int; chicken: int}

(* Converts a board into a list of cells, in snake order. *)
let cells_of_board n m (board: string array) =
  let next (i, j) = match (i mod 2, j) with
    | (0, k) when k = m - 1 -> (i + 1, j)
    | (0, _)                -> (i, j + 1)
    | (_, 0)                -> (i + 1, j)
    | _                     -> (i, j - 1) in
  let rec iter i j acc =
    if i >= n then
      acc
    else
      let (ni, nj) = next (i, j) in
      iter ni nj ({coords =  (i, j); has_rice = String.get board.(i) j = 'R'} :: acc)
  in iter 0 0 []

(* Converts a bunch of chicken assignments to an array of 'bytes' arrays representing
 * the result. *)
let result_of_assns n m (assns : assignment list) =
  let chicken_labels =
    "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKKLZXCVBNM" in
  (* The following didn't work! It created n references to the same array.
     It's like doing "arr = [[0] * m] * n" in Python.
     let res = Array.make n (Bytes.make m '0') in *)
     let res = Array.init n (fun _ -> Bytes.make m '0') in
  (* Ugh, imperative updates... but this is probably more efficient. *)
  let rec iter ls = match ls with
    | [] -> ()
    | {coords=(i, j); chicken = c} :: lss ->
      (Bytes.set res.(i) j (String.get chicken_labels c);
       iter lss)
  in (iter assns; res)

(* Takes a 'board' (2D array showing where the rice is) and
 * converts it to a board of chicken assignments. *)
let solve n m chicks (board: string array) =
  let cells = cells_of_board n m board in
  (* There's probably a function to do this in one go. *)
  let rice_total = List.fold_left
      (fun acc cl -> if cl.has_rice then acc + 1 else acc)
      0 cells
  in
  (* The amount of rice each chicken should have. *)
  let amt = rice_total / chicks in
  (* These are hungry chickens! They will eat amt+1 rice. *)
  let hungry = rice_total - amt * chicks in
  (* Iterate through cells and assign them chickens in order.
   * Assign the hungry chickens first, then the rest. *)
  let rec iter cls prev_chick k acc =
    match cls with
    | [] -> acc
    | {coords=crd; has_rice=hr} :: clss ->
      let mx = if prev_chick < hungry then amt + 1 else amt in
      let nk' = if hr then k + 1 else k in
      let (cur_chick, nk) = if nk' > mx then
          (prev_chick + 1, 1)
        else
          (prev_chick, nk') in
      iter clss cur_chick nk ({coords=crd; chicken=cur_chick} :: acc)
  in result_of_assns n m (iter cells 0 0 [])

let rec rep n f = if n = 0 then () else (f (); rep (n-1) f)

let main () =
  let tt = read_int () in
  rep tt (fun () ->
      (* Scanf.scanf caused Codeforces to give a runtime error for some reason *)
      let (n, m, k) = Scanf.sscanf (read_line ()) "%d %d %d" (fun x y z -> (x, y, z)) in
      let board = Array.init n (fun _ -> read_line ()) in
      Array.iter (fun s -> (print_bytes s; print_newline ())) (solve n m k board)
    )

let _ = main ()

(* Feeding Chicken
 * https://codeforces.com/contest/1254/problem/A *)

(* I shouldn't need explicitly named record fields. But I wanted to
 * practice the notation. *)
type cell = {coords: int * int; has_rice: bool}
type assignment = {coords: int * int; chicken: int}

(* Converts a board into a list of cells, in snake order. *)
let cells_of_board n m (board: string array) =
  let next (i, j) = match (i mod 2, j) with
    | (0, k) when k = m - 1 -> (i + 1, j)
    | (0, _)                -> (i, j + 1)
    | (_, 0)                -> (i + 1, j)
    | _                     -> (i, j - 1) in
  let rec iter i j acc =
    if i >= n then
      acc
    else
      let (ni, nj) = next (i, j) in
      iter ni nj ({coords =  (i, j); has_rice = String.get board.(i) j = 'R'} :: acc)
  in iter 0 0 []

(* Converts a bunch of chicken assignments to an array of 'bytes' arrays representing
 * the result. *)
let result_of_assns n m (assns : assignment list) =
  let chicken_labels =
    "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKKLZXCVBNM" in
  (* The following didn't work! It created n references to the same array.
     It's like doing "arr = [[0] * m] * n" in Python.
     let res = Array.make n (Bytes.make m '0') in *)
     let res = Array.init n (fun _ -> Bytes.make m '0') in
  (* Ugh, imperative updates... but this is probably more efficient. *)
  let rec iter ls = match ls with
    | [] -> ()
    | {coords=(i, j); chicken = c} :: lss ->
      (Bytes.set res.(i) j (String.get chicken_labels c);
       iter lss)
  in (iter assns; res)

(* Takes a 'board' (2D array showing where the rice is) and
 * converts it to a board of chicken assignments. *)
let solve n m chicks (board: string array) =
  let cells = cells_of_board n m board in
  (* There's probably a function to do this in one go. *)
  let rice_total = List.fold_left
      (fun acc cl -> if cl.has_rice then acc + 1 else acc)
      0 cells
  in
  (* The amount of rice each chicken should have. *)
  let amt = rice_total / chicks in
  (* These are hungry chickens! They will eat amt+1 rice. *)
  let hungry = rice_total - amt * chicks in
  (* Iterate through cells and assign them chickens in order.
   * Assign the hungry chickens first, then the rest. *)
  let rec iter cls prev_chick k acc =
    match cls with
    | [] -> acc
    | {coords=crd; has_rice=hr} :: clss ->
      let mx = if prev_chick < hungry then amt + 1 else amt in
      let nk' = if hr then k + 1 else k in
      let (cur_chick, nk) = if nk' > mx then
          (prev_chick + 1, 1)
        else
          (prev_chick, nk') in
      iter clss cur_chick nk ({coords=crd; chicken=cur_chick} :: acc)
  in result_of_assns n m (iter cells 0 0 [])

let rec rep n f = if n = 0 then () else (f (); rep (n-1) f)

let main () =
  print_string "asdf"

let _ = main ()


let _ =
  let sb = Scanf.Scanning.stdib in
  let a = Scanf.bscanf sb "%s " (fun s -> s) in
  let b = Scanf.bscanf sb "%s " (fun s -> s) in
  let c2i c = Char.code c - Char.code 'a' in
  let n = String.length a
  and m = String.length b in
  let inf = 1000000000 in
  let prev = Array.make_matrix 26 n 0 in
  let next = Array.make_matrix 26 n 0 in
  let p = Array.make 26 inf in
  let p' = Array.make 26 (-1) in
  let _ =
    for i = 0 to n - 1 do
      let c = c2i a.[i] in
	for j = 0 to 25 do
	  prev.(j).(i) <- p'.(j)
	done;
	p'.(c) <- i;
    done;
    for i = n - 1 downto 0 do
      let c = c2i a.[i] in
	for j = 0 to 25 do
	  next.(j).(i) <- p.(j)
	done;
	p.(c) <- i;
    done;
  in
  let d = Array.make m (-1) in
  let pos = ref p.(c2i b.[0]) in
  let _ =
    d.(0) <- !pos;
    for i = 1 to m - 1 do
      if !pos < inf then (
	let c = c2i b.[i] in
	  pos := next.(c).(!pos);
      );
      d.(i) <- !pos;
    done;
  in
  let d' = Array.make m (-1) in
  let _ =
    pos := p'.(c2i b.[m - 1]);
    d'.(m - 1) <- !pos;
    for i = m - 2 downto 0 do
      if !pos >= 0 then (
	let c = c2i b.[i] in
	  pos := prev.(c).(!pos);
      );
      d'.(i) <- !pos;
    done;
  in
    (*for i = 0 to m - 1 do
      Printf.printf "asd %d %d\n" d.(i) d'.(i)
    done;*)
  let bl = ref (-1) in
  let br = ref m in
  let r = ref 0 in
    while !r < m && d'.(!r) < 0 do
      incr r;
    done;
    if !br - !bl > !r - (-1) then (
      br := !r;
      bl := -1;
    );
    for l = 0 to m - 1 do
      while !r < m && (!r <= l || d'.(!r) <= d.(l)) do
	incr r;
      done;
      if d.(l) < inf && !br - !bl > !r - l then (
	br := !r;
	bl := l;
      )
    done;
    (*Printf.printf "qwe %d %d\n" !bl !br;*)
    let res = String.sub b 0 (!bl + 1) ^ String.sub b !br (m - !br) in
      if res = ""
      then Printf.printf "-\n"
      else Printf.printf "%s\n" res

let print_result s =
	match s with
	| "" ->
		Printf.printf "-\n";
	| _ ->
		Printf.printf "%s\n" s;
;;

let left_arrangements s p =
	let ns = String.length s in
	let np = String.length p in
	let arr = Array.make (ns+1) 0 in
	let kp = ref 0 in
	let js = ref 0 in
	begin
		(*
		Invariant:
			1. forall j' < js, arr[j'] is amount of matches between strings p and s[0..j'-1]
			2. kp - amount of matches between strings p[0..kp-1] and s[0..js-1]
		Base case: 1,2. vacuous truth
		Termination: js == ns, array range of indices j=[0..ns-1] contains amount of matches between p and corresponding substrings s[0..j-1]
				kp - maximal amount of matches between s[0..ns-1] (i.e. the whole string s) and p
		*)
		while !js < ns do

			arr.(!js) <- !kp; (* now arr[!js] contains amount of matches between p and s[0..js-1] *)

			if (!kp < np) && (String.get p !kp) == (String.get s !js) then
			begin
				kp := !kp + 1;
			end;

			js := !js + 1;

		done;

		(* the last value just duplicates amount if matches between the whole strings p and s *)
		arr.(!js) <- !kp;

		arr
	end
;;

let right_arrangements s p =
	let ns = String.length s in
	let np = String.length p in
	let arr = Array.make (ns+1) 0 in
	let kp = ref np in
	let js = ref ns in
	begin

		(*
		Invariant:
			1. forall j' > js, arr[j'] is amount of matches between strings p and s[j'..ns-1]
			2. kp - position of the last match (if any) in string p or np otherwise.
		Base case: 1,2. vacuous truth
		Termination: js == 0, array range of indices j=[1..ns-1] contains amount of matches between p and corresponding substrings s[j..ns-1]
					arr[ns] contains 0 as there is no matches beyond string length
				kp - maximal amount of matches between s[1..ns-1] and p
		*)
		while !js > 0 do

			arr.(!js) <- (np - !kp);

			if (!kp > 0) && (String.get p (!kp-1) ) == (String.get s (!js-1) ) then
			begin
				kp := !kp - 1;
			end;

			js := !js - 1;

		done;

		(* amount of matches between the whole strings p and s *)
		arr.(!js) <- (np - !kp);

		arr;
	end
;;

let process_strings s p =
	let ns = String.length s in
	let np = String.length p in
	let l = left_arrangements s p in
	let r = right_arrangements s p in
	let best_ks = ref 0 in
	let best_sum = ref 0 in
	begin
		for ks = 0 to ns do
			let sum = l.(ks) + r.(ks) in
			if sum > !best_sum then
				begin
					best_sum := sum;
					best_ks := ks;
				end;
		done;

		let res = if !best_sum <= np
				then (String.sub p 0 l.(!best_ks)) ^ (String.sub p (np - r.(!best_ks)) r.(!best_ks))
				else p in
		print_result res;
	end
;;

let read_input () =
	Scanf.bscanf Scanf.Scanning.stdin " %s %s " process_strings
;;

read_input ()

let print_result s =
	match s with
	| "" ->
		Printf.printf "-\n";
	| _ ->
		Printf.printf "%s\n" s;
;;

let left_subsequence_lengths a b =

	let n = String.length a in
	let m = String.length b in
	let l = Array.make (n+1) 0 in
	let j = ref 0 in
	begin

	l.(0) <- !j;

	for k=0 to (n-1) do

		if (!j < m) && ((String.get a k) == (String.get b !j))  then
			begin
			j := !j + 1;
			end;

		l.(k+1) <- !j; (* now l[!js] contains amount of matches between b and a[0..js-1] *)

	done;

	l
	end
;;

let right_subsequence_lengths a b =
	let n = String.length a in
	let m = String.length b in
	let r = Array.make (n+1) 0 in
	let j = ref m in
	begin

	r.(n) <- (m - !j);

	for k = (n-1) downto 0 do

		if (!j > 0) && ((String.get a k ) == (String.get b (!j-1)))  then
			begin
			j := !j - 1;
			end;

		r.(k) <- (m - !j);

	done;

	r;
	end
;;

let longest_subsequence a b =
	let n = String.length a in
	let m = String.length b in
	let l = left_subsequence_lengths a b in
	let r = right_subsequence_lengths a b in
	let s_best = ref (l.(0) + r.(0)) in
	let k_best = ref 0 in
	begin
	for k = 1 to n do
		let s = l.(k) + r.(k) in
		if s > !s_best then
			begin
			s_best := s;
			k_best := k;
			end;
	done;

	if !s_best >= m
		then b
		else (String.sub b 0 l.(!k_best)) ^ (String.sub b (m - r.(!k_best)) r.(!k_best))
	end
;;

let read_input () =
	Scanf.bscanf Scanf.Scanning.stdin " %s %s " (fun a b -> print_result (longest_subsequence a b))
;;

read_input ()

let print_result s =
	match s with
	| "" ->
		Printf.printf "-\n";
	| _ ->
		Printf.printf "%s\n" s;
;;

let left_mismatch s p =
	let ns = String.length s in
	let np = String.length p in
	let kp = ref 0 in
	let js = ref 0 in
	let jl = ref 0 in (* index in s after last match with p *)
	begin
		while (!kp < np) && (!js < ns)
		do
			if (String.get p !kp) == (String.get s !js) then
			begin
				kp := !kp + 1;
				jl := !js + 1;
			end;
			js := !js + 1;
		done; (* for k : (p_b..p_e) *)
		(!kp, !jl)
	end
;;

let right_mismatch s p s_b p_b =
	let ns = String.length s in
	let np = String.length p in
	let kp = ref np in
	let js = ref ns in
	begin
		while (!kp > p_b) && (!js > s_b)
		do
			if (String.get p (!kp - 1) ) == (String.get s (!js - 1) ) then
			begin
				kp := !kp - 1;
			end;
			js := !js - 1;
		done; (* for k : (p_b..p_e) *)
		!kp
	end
;;

let process_strings s p =
	begin
		let m = String.length p in
		let (lp, ls) = left_mismatch s p in
		let rp = right_mismatch s p ls lp in
		let nr = m - rp in
		let res = (String.sub p 0 lp) ^ (String.sub p rp nr) in
		print_result res;
	end
;;

let read_input () =
	Scanf.bscanf Scanf.Scanning.stdin " %s %s " process_strings
;;

read_input ()

let print_result s =
	match s with
	| "" ->
		Printf.printf "-\n";
	| _ ->
		Printf.printf "%s\n" s;
;;

let left_arrangements s p =
	let ns = String.length s in
	let np = String.length p in
	let arr = Array.make ns 0 in
	let kp = ref 0 in
	let js = ref 0 in
	begin
		while (!kp < np) && (!js < ns) do

			arr.(!js) <- !kp;

			if (String.get p !kp) == (String.get s !js) then
			begin
				kp := !kp + 1;
			end;

			js := !js + 1;
		done;

		while !js < ns do
			arr.(!js) <- np;
			js := !js + 1;
		done;

		arr
	end
;;

let right_arrangements s p =
	let ns = String.length s in
	let np = String.length p in
	let arr = Array.make ns 0 in
	let kp = ref np in
	let js = ref ns in
	begin
		while (!kp > 0) && (!js > 0) do

			if (String.get p (!kp-1) ) == (String.get s (!js-1) ) then
			begin
				kp := !kp - 1;
			end;

			js := !js - 1;

			arr.(!js) <- (np - !kp);
		done;

		while (!js > 0) do
			js := !js - 1;
			arr.(!js) <- np;
		done;

		arr;
	end
;;

let process_strings s p =
	let n = String.length s in
	let m = String.length p in
	let l = left_arrangements s p in
	let r = right_arrangements s p in
	let best_k = ref 0 in
	let best_sum = ref 0 in
	begin
		for k = 0 to (n-1) do
			let sum = l.(k) + r.(k) in
			if sum > !best_sum then
				begin
					best_sum := sum;
					best_k := k;
				end;
		done;

		let res = if !best_sum <= m
				then (String.sub p 0 l.(!best_k)) ^ (String.sub p (m - r.(!best_k)) r.(!best_k))
				else p in
		print_result res;
	end
;;

let read_input () =
	Scanf.bscanf Scanf.Scanning.stdin " %s %s " process_strings
;;

read_input ()

let print_result s =
	match s with
	| "" ->
		Printf.printf "-\n";
	| _ ->
		Printf.printf "%s\n" s;
;;

let left_arrangements s p =
	let ns = String.length s in
	let np = String.length p in
	let arr = Array.make ns 0 in
	let kp = ref 0 in
	let js = ref 0 in
	begin
		while (!kp < np) && (!js < ns) do

			arr.(!js) <- !kp;

			if (String.get p !kp) == (String.get s !js) then
			begin
				kp := !kp + 1;
			end;

			js := !js + 1;
		done;

		while !js < ns do
			arr.(!js) <- np;
			js := !js + 1;
		done;

		arr
	end
;;

let right_arrangements s p =
	let ns = String.length s in
	let np = String.length p in
	let arr = Array.make ns 0 in
	let kp = ref np in
	let js = ref ns in
	begin
		while (!kp > 0) && (!js > 0) do

			if (String.get p (!kp-1) ) == (String.get s (!js-1) ) then
			begin
				kp := !kp - 1;
			end;

			js := !js - 1;

			arr.(!js) <- (np - !kp);
		done;

		while (!js > 0) do
			arr.(!js) <- np;
			js := !js - 1;
		done;

		arr;
	end
;;

let process_strings s p =
	let n = String.length s in
	let m = String.length p in
	let l = left_arrangements s p in
	let r = right_arrangements s p in
	let best_k = ref 0 in
	let best_sum = ref 0 in
	begin
		for k = 0 to (n-1) do
			let sum = l.(k) + r.(k) in
			if sum > !best_sum then
				begin
					best_sum := sum;
					best_k := k;
				end;
		done;

		let res = (String.sub p 0 l.(!best_k)) ^ (String.sub p (m - r.(!best_k)) r.(!best_k)) in
		print_result res;
	end
;;

let read_input () =
	Scanf.bscanf Scanf.Scanning.stdin " %s %s " process_strings
;;

read_input ()

let print_result s =
	match s with
	| "" ->
		Printf.printf "-\n";
	| _ ->
		Printf.printf "%s\n" s;
;;

let left_arrangements s p =
	let ns = String.length s in
	let np = String.length p in
	let arr = Array.make ns 0 in
	let kp = ref 0 in
	let js = ref 0 in
	begin
		while (!kp < np) && (!js < ns) do

			arr.(!js) <- !kp;

			if (String.get p !kp) == (String.get s !js) then
			begin
				kp := !kp + 1;
			end;

			js := !js + 1;

		done;

		arr
	end
;;

let right_arrangements s p =
	let ns = String.length s in
	let np = String.length p in
	let arr = Array.make ns 0 in
	let kp = ref np in
	let js = ref ns in
	begin
		while (!kp > 0) && (!js > 0) do

			if (String.get p (!kp-1) ) == (String.get s (!js-1) ) then
			begin
				kp := !kp - 1;
			end;

			js := !js - 1;

			arr.(!js) <- (np - !kp);

		done;

		arr;
	end
;;

let process_strings s p =
	let n = String.length s in
	let m = String.length p in
	let l = left_arrangements s p in
	let r = right_arrangements s p in
	let best_k = ref 0 in
	let best_sum = ref 0 in
	begin
		for k = 0 to (n-1) do
			let sum = l.(k) + r.(k) in
			if sum > !best_sum then
				begin
					best_sum := sum;
					best_k := k;
				end;
		done;

		let res = (String.sub p 0 l.(!best_k)) ^ (String.sub p (m - r.(!best_k)) r.(!best_k)) in
		print_result res;
	end
;;

let read_input () =
	Scanf.bscanf Scanf.Scanning.stdin " %s %s " process_strings
;;

read_input ()

let print_result s =
	match s with
	| "" ->
		Printf.printf "-\n";
	| _ ->
		Printf.printf "%s\n" s;
;;

let left_arrangements s p =
	let ns = String.length s in
	let np = String.length p in
	let arr = Array.make ns 0 in
	let kp = ref 0 in
	let js = ref 0 in
	begin
		while (!kp < np) && (!js < ns) do

			arr.(!js) <- !kp;

			if (String.get p !kp) == (String.get s !js) then
			begin
				kp := !kp + 1;
			end;

			js := !js + 1;
		done;

		while !js < ns do
			arr.(!js) <- np;
			js := !js + 1;
		done;

		arr
	end
;;

let right_arrangements s p =
	let ns = String.length s in
	let np = String.length p in
	let arr = Array.make ns 0 in
	let kp = ref np in
	let js = ref ns in
	begin
		while (!kp > 0) && (!js > 0) do

			if (String.get p (!kp-1) ) == (String.get s (!js-1) ) then
			begin
				kp := !kp - 1;
			end;

			js := !js - 1;

			arr.(!js) <- (np - !kp);
		done;

		while (!js > 0) do
			js := !js - 1;
			arr.(!js) <- np;
		done;

		arr;
	end
;;

let process_strings s p =
	let n = String.length s in
	let m = String.length p in
	let l = left_arrangements s p in
	let r = right_arrangements s p in
	let best_k = ref 0 in
	let best_sum = ref 0 in
	begin
		for k = 0 to (n-1) do
			let sum = l.(k) + r.(k) in
			if sum > !best_sum then
				begin
					best_sum := sum;
					best_k := k;
				end;
		done;

		let res = (String.sub p 0 l.(!best_k)) ^ (String.sub p (m - r.(!best_k)) r.(!best_k)) in
		print_result res;
	end
;;

let read_input () =
	Scanf.bscanf Scanf.Scanning.stdin " %s %s " process_strings
;;

read_input ()

let print_result s =
	match s with
	| "" ->
		Printf.printf "-\n";
	| _ ->
		Printf.printf "%s\n" s;
;;

let left_mismatch s p s_e p_e =
	let kp = ref 0 in
	let js = ref 0 in
	let jl = ref 0 in (* index in s after last match with p *)
	begin
		while (!kp < p_e) && (!js < s_e)
		do
			if (String.get p !kp) == (String.get s !js) then
			begin
				kp := !kp + 1;
				jl := !js + 1;
			end;
			js := !js + 1;
		done; (* for k : (p_b..p_e) *)
		(!kp, !jl)
	end
;;

let right_mismatch s p s_b p_b =
	let ns = String.length s in
	let np = String.length p in
	let kp = ref np in
	let js = ref ns in
	let jl = ref ns in
	begin
		while (!kp > p_b) && (!js > s_b)
		do
			if (String.get p (!kp - 1) ) == (String.get s (!js - 1) ) then
			begin
				kp := !kp - 1;
				jl := !js - 1;
			end;
			js := !js - 1;
		done; (* for k : (p_b..p_e) *)
		(!kp, !jl)
	end
;;

let process_strings s p =
	begin
		let n = String.length s in
		let m = String.length p in
		let (lp1, ls1) = left_mismatch s p n m in
		let (rp1, _) = right_mismatch s p ls1 lp1 in
		let (rp2, rs2) = right_mismatch s p 0 0 in
		let (lp2, _) = left_mismatch s p rs2 rp2 in
		let nr1 = m - rp1 in
		let nr2 = m - rp2 in
		let n1 = lp1 + nr1  in
		let n2 = lp2 + nr2 in
		let res = if (n1 > n2)
			then (String.sub p 0 lp1) ^ (String.sub p rp1 nr1)
			else (String.sub p 0 lp2) ^ (String.sub p rp2 nr2) in
		print_result res;
	end
;;

let read_input () =
	Scanf.bscanf Scanf.Scanning.stdin " %s %s " process_strings
;;

read_input ()

let _ =
  let sb = Scanf.Scanning.stdib in
  let a = Scanf.bscanf sb "%s " (fun s -> s) in
  let b = Scanf.bscanf sb "%s " (fun s -> s) in
  let c2i c = Char.code c - Char.code 'a' in
  let n = String.length a
  and m = String.length b in
  let inf = 1000000000 in
  let prev = Array.make_matrix 26 n 0 in
  let next = Array.make_matrix 26 n 0 in
  let p = Array.make 26 inf in
  let p' = Array.make 26 (-1) in
  let _ =
    for i = 0 to n - 1 do
      let c = c2i a.[i] in
	for j = 0 to 25 do
	  prev.(j).(i) <- p'.(j)
	done;
	p'.(c) <- i;
    done;
    for i = n - 1 downto 0 do
      let c = c2i a.[i] in
	for j = 0 to 25 do
	  next.(j).(i) <- p.(j)
	done;
	p.(c) <- i;
    done;
  in
  let d = Array.make m (-1) in
  let pos = ref p.(c2i b.[0]) in
  let _ =
    d.(0) <- !pos;
    for i = 1 to m - 1 do
      if !pos < inf then (
	let c = c2i b.[i] in
	  pos := next.(c).(!pos);
      );
      d.(i) <- !pos;
    done;
  in
  let d' = Array.make m (-1) in
  let _ =
    pos := p'.(c2i b.[m - 1]);
    d'.(m - 1) <- !pos;
    for i = m - 2 downto 0 do
      if !pos >= 0 then (
	let c = c2i b.[i] in
	  pos := prev.(c).(!pos);
      );
      d'.(i) <- !pos;
    done;
  in
    for i = 0 to m - 1 do
      Printf.printf "asd %d %d\n" d.(i) d'.(i)
    done;
  let bl = ref (-1) in
  let br = ref m in
  let r = ref 0 in
    (*while !r < m && d'.(!r) < 0 do
      incr r;
    done;*)
    if !br - !bl > !r - (-1) then (
      br := !r;
      bl := -1;
    );
    for l = 0 to m - 1 do
      while !r < m && (!r <= l || d'.(!r) <= d.(l)) do
	incr r;
      done;
      if d.(l) < inf && !br - !bl > !r - l then (
	br := !r;
	bl := l;
      )
    done;
    (*Printf.printf "qwe %d %d\n" !bl !br;*)
    let res = String.sub b 0 (!bl + 1) ^ String.sub b !br (m - !br) in
      if res = ""
      then Printf.printf "-\n"
      else Printf.printf "%s\n" res

let _ =
  let sb = Scanf.Scanning.stdib in
  let a = Scanf.bscanf sb "%s " (fun s -> s) in
  let b = Scanf.bscanf sb "%s " (fun s -> s) in
  let c2i c = Char.code c - Char.code 'a' in
  let n = String.length a
  and m = String.length b in
  let inf = 1000000000 in
  let prev = Array.make_matrix 26 n 0 in
  let next = Array.make_matrix 26 n 0 in
  let p = Array.make 26 inf in
  let p' = Array.make 26 (-1) in
  let _ =
    for i = 0 to n - 1 do
      let c = c2i a.[i] in
	for j = 0 to 25 do
	  prev.(j).(i) <- p'.(j)
	done;
	p'.(c) <- i;
    done;
    for i = n - 1 downto 0 do
      let c = c2i a.[i] in
	for j = 0 to 25 do
	  next.(j).(i) <- p.(j)
	done;
	p.(c) <- i;
    done;
  in
  let d = Array.make m (-1) in
  let pos = ref p.(c2i b.[0]) in
  let _ =
    d.(0) <- !pos;
    for i = 1 to m - 1 do
      if !pos < inf then (
	let c = c2i b.[i] in
	  pos := next.(c).(!pos);
      );
      d.(i) <- !pos;
    done;
  in
  let d' = Array.make m (-1) in
  let _ =
    pos := p'.(c2i b.[m - 1]);
    d'.(m - 1) <- !pos;
    for i = m - 2 downto 0 do
      if !pos >= 0 then (
	let c = c2i b.[i] in
	  pos := prev.(c).(!pos);
      );
      d'.(i) <- !pos;
    done;
  in
    (*for i = 0 to m - 1 do
      Printf.printf "asd %d %d\n" d.(i) d'.(i)
    done;*)
  let bl = ref (-1) in
  let br = ref m in
  let r = ref 0 in
    for l = 0 to m - 1 do
      while !r < m && d'.(!r) <= d.(l) do
	incr r;
      done;
      if d.(l) < inf && !br - !bl > !r - l then (
	br := !r;
	bl := l;
      )
    done;
    (*Printf.printf "qwe %d %d\n" !bl !br;*)
    let res = String.sub b 0 (!bl + 1) ^ String.sub b !br (m - !br) in
      if res = ""
      then Printf.printf "-\n"
      else Printf.printf "%s\n" res

let _ =
  let sb = Scanf.Scanning.stdib in
  let a = Scanf.bscanf sb "%s " (fun s -> s) in
  let b = Scanf.bscanf sb "%s " (fun s -> s) in
  let c2i c = Char.code c - Char.code 'a' in
  let n = String.length a
  and m = String.length b in
  let inf = 1000000000 in
  let prev = Array.make_matrix 26 n 0 in
  let next = Array.make_matrix 26 n 0 in
  let p = Array.make 26 inf in
  let p' = Array.make 26 (-1) in
  let _ =
    for i = 0 to n - 1 do
      let c = c2i a.[i] in
	for j = 0 to 25 do
	  prev.(j).(i) <- p'.(j)
	done;
	p'.(c) <- i;
    done;
    for i = n - 1 downto 0 do
      let c = c2i a.[i] in
	for j = 0 to 25 do
	  next.(j).(i) <- p.(j)
	done;
	p.(c) <- i;
    done;
  in
  let d = Array.make m (-1) in
  let pos = ref p.(c2i b.[0]) in
  let _ =
    d.(0) <- !pos;
    for i = 1 to m - 1 do
      if !pos < inf then (
	let c = c2i b.[i] in
	  pos := next.(c).(!pos);
      );
      d.(i) <- !pos;
    done;
  in
  let d' = Array.make m (-1) in
  let _ =
    pos := p'.(c2i b.[m - 1]);
    d'.(m - 1) <- !pos;
    for i = m - 2 downto 0 do
      if !pos >= 0 then (
	let c = c2i b.[i] in
	  pos := prev.(c).(!pos);
      );
      d'.(i) <- !pos;
    done;
  in
    (*for i = 0 to m - 1 do
      Printf.printf "asd %d %d\n" d.(i) d'.(i)
    done;*)
  let bl = ref (-1) in
  let br = ref m in
  let r = ref 0 in
    for l = 0 to m - 1 do
      while !r < m && d'.(!r) <= d.(l) do
	incr r;
      done;
      if d.(l) < m && !br - !bl > !r - l then (
	br := !r;
	bl := l;
      )
    done;
    (*Printf.printf "asd %d %d\n" !bl !br;*)
    let res = String.sub b 0 (!bl + 1) ^ String.sub b !br (m - !br) in
      if res = ""
      then Printf.printf "-\n"
      else Printf.printf "%s\n" res


type state = Unseen | One | Both

let () =
  let n = Scanf.scanf "%d" (fun x -> x) in
  let pairs = Array.make (n + 1) Unseen in
  let on_table = ref 0 in
  let m = ref 0 in
  for i = 1 to 2*n do
    let k = Scanf.scanf " %d" (fun x -> x) in
    match pairs.(k) with
    | Unseen -> begin
        pairs.(k) <- One;
        incr on_table;
        m := max !m !on_table
      end
    | One -> begin
        pairs.(k) <- Both;
        decr on_table
      end
    | Both -> ()
  done;
  Printf.printf "%d\n" !m

open Printf
open Scanf

let read_int _ = bscanf Scanning.stdib " %d " (fun x -> x)
let () =
  let n = read_int () in
  let x = Array.init (2*n) read_int in

  let out = Array.make (2*n) false in

  let rec loop i nout maxout = if i=2*n then maxout else (
    let sock = x.(i)-1 in
    if out.(sock) then (
      out.(sock) <- false;
      loop (i+1) (nout-1) maxout
    ) else (
      out.(sock) <- true;
      loop (i+1) (nout+1) (max maxout (nout+1))
    )
  ) in

  printf "%d\n" (loop 0 0 0)

open Printf
open Scanf

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

  let out = Array.make n false in

  let rec loop i nout maxout = if i=n then maxout else (
    let sock = x.(i)-1 in
    if out.(sock) then (
      out.(sock) <- false;
      loop (i+1) (nout-1) maxout
    ) else (
      out.(sock) <- true;
      loop (i+1) (nout+1) (max maxout (nout+1))
    )
  ) in

  printf "%d\n" (loop 0 0 0)