open Printf
open Num

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

let my_hash = Hashtbl.create 1234567

let my_hash2 = Hashtbl.create 1234567

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

let () =
  for i = 0 to n-2 do
    let j = Scanf.scanf "%d " (fun x -> x) in
    Hashtbl.add my_hash2 j i;
    Hashtbl.remove my_hash j
  done

let () = Hashtbl.iter (fun x y -> printf "%d\n" x) my_hash

let () =
  for i = 0 to n-3 do
    let j = Scanf.scanf "%d " (fun x -> x) in
    Hashtbl.remove my_hash2 j;
  done

let () =  Hashtbl.iter (fun x y -> printf "%d\n" x) my_hash2

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

let get_list l =
    let rec loop i list =
        if i > 0
        then
            let var = read () in
            loop (i - 1) (var :: list)
        else
            List.sort (Pervasives.compare) list
    in loop l []

let subtract_lists first second =
    let rec subtract l1 l2 =
        match l1, l2 with
        | [], _ -> []
        | _, [] -> l1
        | hd :: tl, hhd :: ttl when hd = hhd -> subtract tl ttl
        | hd :: tl, _ -> hd :: (subtract tl l2)
    in subtract first second

let solve () =
    let n = read () in
    let first = get_list n in
    let second = get_list (n - 1) in
    let third = get_list (n - 2) in
    let bug_one = subtract_lists first second in
    let bug_two = subtract_lists second third in
    match bug_one, bug_two with
    | hd :: tl, hhd :: ttl -> (hd, hhd)
    | _ -> failwith "Empty list"

let print (a, b) = Printf.printf "%d\n%d\n" a b
let () = print (solve ())

let _ = read_line () in
let ints _  =  read_line () |> Str.split (Str.regexp " +") |> List.map int_of_string |> List.sort compare in
let rec diff x y =
  match (x ,y) with
   | ([e],[])  -> e
   | ((c :: cs), (d :: ds)) when c != d -> c
   | ((a :: ax), (b :: bx)) when a = b -> diff ax bx
  | _ -> failwith "error" in

let first = ints () and
    second = ints () and
    third = ints () in
Printf.printf "%d\n%d" (diff first second) (diff second third)

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

let read_list n f =
  let rec loop idx =
    if idx == n then
      []
    else
      f()::loop (idx+1) in
  loop 0;;

let findDiff l1 l2 =
  let rec loop l1 l2 =
    match l1, l2 with
    | h1::t1, h2::t2 ->
       if h1 == h2 then
         loop t1 t2
       else
         h1
    | h1::t1, [] -> h1
    | _, _ -> 0 in
  loop (List.sort compare l1) (List.sort compare l2);;

let _ =
  let n = read_int() in
  let l1 = read_list n next_int in
  let l2 = read_list (n-1) next_int in
  let l3 = read_list (n-2) next_int in
  print_int(findDiff l1 l2);
  print_newline();
  print_int(findDiff l2 l3);
  print_newline();;

let rec prem_dif = function
	|[a],[]		-> a
	|t::q,t'::q'	-> if t=t'
				then prem_dif (q,q')
				else t;;

let main () =
	let n = Scanf.scanf "%d " (fun i -> i) and prem = ref []
	and sec = ref [] and tro = ref [] in
		for i = 1 to n do
			prem := (Scanf.scanf "%d " (fun j -> j))::!prem;
		done;
		for i = 1 to n-1 do
			sec := (Scanf.scanf "%d " (fun j -> j))::!sec;
		done;
		for i = 1 to n-2 do
			tro := (Scanf.scanf "%d " (fun j -> j))::!tro;
		done;
		prem := List.sort compare !prem;
		sec := List.sort compare !sec;
		tro := List.sort compare !tro;
		Printf.printf "%d\n%d" (prem_dif (!prem,!sec)) (prem_dif (!sec,!tro));;

main ();;

open Printf
open Scanf

let increment h t d =
  let c = try Hashtbl.find h t with Not_found -> 0 in
  if c+d = 0 then Hashtbl.remove h t else Hashtbl.replace h t (c+d)

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

  let ha = Hashtbl.create 1000 in

  for i=0 to n-1 do
    increment ha a.(i) 1
  done;

  for i=0 to n-2 do
    increment ha b.(i) (-1)
  done;

  if Hashtbl.length ha <> 1 then failwith "input wrong 1";
  let e1 = ref (-1) in
  Hashtbl.iter (fun k v -> e1 := k) ha;

  let hb = Hashtbl.create 1000 in

  for i=0 to n-2 do
    increment hb b.(i) 1
  done;

  for i=0 to n-3 do
    increment hb c.(i) (-1)
  done;

  if Hashtbl.length hb <> 1 then failwith "input wrong 2";
  let e2 = ref (-1) in
  Hashtbl.iter (fun k v -> e2 := k) hb;

  printf "%d\n%d\n" !e1 !e2

let rec prem_dif = function
	|[a],[]		-> a
	|t::q,t'::q'	-> if t=t'
				then prem_dif (q,q')
				else t;;

let main () =
	let n = Scanf.scanf "%d " (fun i -> i) and prem = ref []
	and sec = ref [] and tro = ref [] in
		for i = 1 to n do
			prem := (Scanf.scanf "%d " (fun j -> j))::!prem;
		done;
		for i = 1 to n-1 do
			sec := (Scanf.scanf "%d " (fun j -> j))::!sec;
		done;
		for i = 1 to n-2 do
			tro := (Scanf.scanf "%d " (fun j -> j))::!tro;
		done;
		Printf.printf "%d\n%d" (prem_dif (!prem,!sec)) (prem_dif (!sec,!tro));;

main ();;


open Printf
open Scanf

let ( ** ) a b = Int64.mul a b
let ( ++ ) a b = Int64.add a b
let ( -- ) a b = Int64.sub a b
let ( // ) a b = Int64.div a b
let ( %% ) a b = Int64.rem a b

let long x = Int64.of_int x
let short x = Int64.to_int x

let rec fold i j f init = if i>j then init else fold (i+1) j f (f i init)
let sum i j f = fold i j (fun i a -> (f i) + a) 0
let minf i j f = fold (i+1) j (fun k a -> min (f k) a) (f i)
let sq x = x ** x

let read_int _ = bscanf Scanning.stdib " %d " (fun x -> x)
let read_string _ = bscanf Scanning.stdib " %s " (fun x -> x)
let () =
  let n = read_int () in
  let c1 = long (read_int ()) in
  let c2 = long (read_int ()) in
  let s = read_string() in
  let m = sum 0 (n-1) (fun i -> if s.[i] = '0' then 0 else 1) in (* number of adults *)

  let answer = minf 1 m (fun g ->  (* g = number of groups *)
    let x1 = n/g in
    let x2 = x1 + 1 in
    let n2 = n - (g * x1) in
    let n1 = g - n2 in
    let (g,n1,n2,x1,x2) = (long g, long n1, long n2, long x1, long x2) in
    c1 ** g ++ c2 ** (n1 ** (sq (x1--1L)) ++ n2 ** (sq (x2 -- 1L)))
  ) in

  printf "%Ld\n" answer

open Printf;;
open String;;

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

let inp = Str.split (Str.regexp " ") (read_line());;
let n = int_of_string (List.nth inp 0);;
let c1 = Int64.of_string (List.nth inp 1);;
let c2 = Int64.of_string (List.nth inp 2);;
let s = read_line();;

let rec count_one idx =
    if idx = n then 0
    else (if (String.get s idx) = '1' then 1 else 0) + (count_one (idx + 1));;

let adults = count_one 0;;

let calc_single x = c1 +| (c2 *| ((x -| 1L) *| (x -| 1L)));;

let calc_total x =
    let nn = Int64.of_int n in
    let r = Int64.rem nn x in
    (r *| calc_single((nn /| x) +| 1L)) +|
    ((x -| r) *| calc_single(nn /| x));;

let rec process i ans =
    if i > adults then printf "%Ld\n" ans else
    let newcost = calc_total (Int64.of_int i) in
    process (i + 1) (if ans > newcost then newcost else ans);;

let _ = process 1 Int64.max_int;;

open Printf;;
open String;;

let inp = Str.split (Str.regexp " ") (read_line());;
let n = int_of_string (List.nth inp 0);;
let c1 = Int64.of_string (List.nth inp 1);;
let c2 = Int64.of_string (List.nth inp 2);;
let s = read_line();;

let rec can_group len idx adult =
    let slen = (String.length s) in
    if idx = slen then true
    else if (idx mod len) = 0 && (not adult) then false
    else can_group len (idx + 1) (((String.get s idx) = '1')
        || ((idx mod len) > 0 && adult));;

let rec process i ans =
    if i > n then printf "%Ld\n" ans else
    let newcost =
        if (n mod i) = 0 && (can_group i 0 true) then
            let scost = Int64.add c1 (Int64.mul c2 (Int64.mul (Int64.of_int (i - 1)) (Int64.of_int (i - 1)))) in
            Int64.mul scost (Int64.div (Int64.of_int n) (Int64.of_int i))
        else Int64.max_int in
    process (i + 1) (if ans > newcost then newcost else ans);;

let _ = process 1 Int64.max_int;;

open Printf;;
open String;;

let inp = Str.split (Str.regexp " ") (read_line());;
let n = int_of_string (List.nth inp 0);;
let c1 = Int64.of_string (List.nth inp 1);;
let c2 = Int64.of_string (List.nth inp 2);;
let s = read_line();;

let rec can_group len idx adult =
    let slen = (String.length s) in
    if idx = slen then true
    else if (idx mod len) = 0 && (not adult) then false
    else can_group len (idx + 1) (((String.get s idx) = '1')
        || ((idx mod len) > 0 && adult));;

let rec process i ans =
    if i > n then printf "%Ld\n" ans else
    let newcost =
        if (n mod i) = 0 && (can_group i 0 true) then
            let scost = Int64.add c1 (Int64.mul c2 (Int64.mul (Int64.of_int (i - 1)) (Int64.of_int (i - 1)))) in
            Int64.mul scost (Int64.div (Int64.of_int n) (Int64.of_int i))
        else 1000000000000000000L in
    process (i + 1) (if ans > newcost then newcost else ans);;

let _ = process 1 1000000000000000000L;;


open Printf
open Scanf

let ( ** ) a b = Int64.mul a b
let ( ++ ) a b = Int64.add a b
let ( -- ) a b = Int64.sub a b
let ( // ) a b = Int64.div a b
let ( %% ) a b = Int64.rem a b

let rec fold i j f init = if i>j then init else fold (i+1) j f (f i init)
let sum i j f = fold i j (fun i a -> (f i) + a) 0
let rec forall i j f = (i>j) || ((f i) && forall (i+1) j f)

let read_int _ = bscanf Scanning.stdin " %d " (fun x -> x)
let read_string _ = bscanf Scanning.stdin " %s " (fun x -> x)
let read_pair _ = bscanf Scanning.stdin " %d %d " (fun x y -> (x,y))
let read_tup _ = bscanf Scanning.stdin " %d %d %d " (fun x y z -> (x,y,z))

let rec inp (n : int) =
    if (n == 0)
    then []
    else
        let i = read_int () in
        let j = read_int () in
        let x = read_int () in

        (i - 1, j - 1, x) :: inp (n - 1)

let rec solve (n : int) (m : int) arr =
    if (m == 0)
    then Array.make n 0
    else
        let prev = solve n (m / 2) arr in
        let z = Array.make n 0 in
        let res = Array.make n 0 in
        let adj = Array.make n [] in
        let rec process aa =
            match aa with
                [] -> ()
             |  (i, j, x) :: xs ->
                 let () = (
                 if ((x land m) == 0)
                 then
                    (* let () = printf "A %d %d %d %d \n" i j x m in *)
                    let () = Array.set z i 1 in
                    Array.set z j 1
                else
                    (* let () = printf "B %d %d %d %d \n" i j x m in *)
                    if (i == j)
                    then Array.set res i m
                    else
                    (
                    let oldi = Array.get adj i in
                    let () = Array.set adj i (j :: oldi) in
                    let oldj = Array.get adj j in
                    let () = Array.set adj j (i :: oldj) in
                    ()
                    )
                ) in
                process xs
        in
        let () = process arr in

        let () =
            for i = 0 to (n - 1) do
                let rec uu aa =
                    (
                    match aa with
                        [] -> ()
                     |  x :: xs ->
                        let () = (
                        if ((Array.get z x) == 1)
                        then Array.set res i m
                        else ()
                        ) in
                        uu xs
                    )
                in
                let rec vv aa =
                    (
                    match aa with
                        [] -> ()
                     |  x :: xs ->
                        let () = Array.set res x m in
                        (* let () = printf "%d %d %d \n" m i x in *)
                        vv xs
                    )
                in
                let () = uu (Array.get adj i) in
                (
                if ((Array.get res i) == 0)
                then
                    (* let () = Array.set z i 1 in *)
                    vv (Array.get adj i)
                else
                    ()
                )
            done
            in

        let () =
            for i = 0 to (n - 1) do
                Array.set res i ((Array.get res i) + (Array.get prev i))
            done
        in
        res

let () =
    let t = read_int () in

    for i = 1 to t do
        let n = read_int () in
        let a = n / 2 in
        let b = n / 3 in
    	printf "%d\n" (n + a + a + b + b)
    done

let rec loop (t : int) =
  if t = 0 then
    ()
  else
    let n = read_int () in
    let () = print_endline (string_of_int (n + 2*(n / 2) + 2*(n/3))) in
    loop (t-1)
;;

let t = read_int () in loop t;;

(* This is an OCaml editor.
   Enter your program here and send it to the toplevel using the "Eval code"
   button or [Ctrl-e]. *)

let i = read_int() in
let rec loop x=
  if x=0 then () else
    (let j = read_int() in print_int (j+ (j/2)*2 + (j/3)*2);print_newline() ;  loop (x-1) )

in loop i


(* [@@@warning "-30"] *)

type vertex = {
  mutable adjacent : vertex array;
  mutable parent   : vertex;
  mutable depth    : int;
  mutable t_entr   : int;
  mutable t_exit   : int;
  mutable sigma_d  : int64;
  mutable sigma'_d : int64;
  mutable count    : int64;
          uf       : uf;
  mutable ancestor : vertex;
  mutable colored  : bool;
}
and uf = {
  mutable parent   : vertex;
  mutable rank     : int;
}

module H = Hashtbl.Make(struct type t = vertex let equal = (==) let hash v = v.t_entr end)

let none = -1

let dummy () =
  let rec v = {
    adjacent = [| |];
    parent   = v;
    depth    = none;
    t_entr   = none;
    t_exit   = none;
    sigma_d  = 0L;
    sigma'_d = 0L;
    count    = 0L;
    uf       = { parent = v; rank = 0 };
    ancestor = v;
    colored  = false
  }
  in
  v

let (+~), (-~), zero = Int64.(add, sub, zero)

let dfs1 root =
  let rec dfs d t p curr =
    curr.t_entr <- t;
    curr.depth <- d;
    curr.parent <- p;
    curr.count <- curr.count +~ 1L;
    let t =
      Array.fold_left
        (fun t v ->
           if v != p then begin
             let t = dfs (d + 1) (t + 1) curr v in
             curr.sigma_d <- curr.sigma_d +~ v.sigma_d +~ v.count;
             curr.count   <- curr.count +~ v.count;
             t
           end else t)
        t
        curr.adjacent
    in
    curr.t_exit <- t;
    t
  in
  ignore @@ dfs 0 0 root root

let dfs2 root =
  let rec dfs curr =
    let p = curr.parent in
    curr.sigma'_d <-
      if p != curr then
        (if p.parent != p then p.sigma'_d +~ root.count -~ p.count else 0L) +~
        p.sigma_d -~ curr.sigma_d -~ curr.count
      else
        0L;
    Array.iter (fun v -> if v != p then dfs v) curr.adjacent
  in
  dfs root

let tarjan_olca queries =
  let init v =
     v.uf.parent <- v;
     v.uf.rank   <- 0
  in
  let rec find v =
    if v.uf.parent == v then
      v
    else
      let p = find v.uf.parent in
      v.uf.parent <- p;
      p
  in
  let union u v =
    let u, v = find u, find v in
    if u.uf.rank > v.uf.rank then
      v.uf.parent <- u
    else if u.uf.rank < v.uf.rank then
      u.uf.parent <- v
    else if u != v then begin
      v.uf.parent <- u;
      u.uf.rank <- u.uf.rank + 1
    end
  in
  let rec tarjan u =
     init u;
     u.ancestor <- u;
     Array.iter
       (fun v ->
          if v != u.parent then begin
            tarjan v;
            union u v;
            (find u).ancestor <- u
          end)
       u.adjacent;
     u.colored <- true;
     try
       H.iter
         (fun v a ->
            if v.colored then
              let r = (find v).ancestor in
              a := r;
              H.find (H.find queries v) u := r)
         (H.find queries u)
     with
     | Not_found -> ()
  in
  tarjan

type data = { low : vertex; sub : vertex }

type path_kind = I of data | V

let search queries u v =
  let search u v =
    let rec search l r =
      if l = r then u.adjacent.(l)
      else
        let m = l + (r - l) / 2 in
        let m = if u.adjacent.(m) == u.parent then m + 1 else m in
        if      u.adjacent.(m).t_entr > v.t_entr then search l (m - 1)
        else if u.adjacent.(m).t_exit < v.t_exit then search (m + 1) r
        else u.adjacent.(m)
    in
    search 0 (Array.length u.adjacent - 1)
  in
  let kind =
    if      u.t_entr <= v.t_entr && u.t_exit >= v.t_exit then I { low = v; sub = search u v }
    else if v.t_entr <= u.t_entr && v.t_exit >= u.t_exit then I { low = u; sub = search v u }
    else V
  in
  kind, u.depth + v.depth - 2 * (!H.(find (find queries u) v)).depth

let solve queries root u v =
  let fl, (+), (/) = Int64.to_float, (+.), (/.) in
  match search queries u v with
  | V, n ->
    float_of_int n + 1. + fl u.sigma_d / fl u.count + fl v.sigma_d / fl v.count
  | I { low; sub } , n ->
    float_of_int n + 1. + fl low.sigma_d / fl low.count + fl sub.sigma'_d / fl (root.count -~ sub.count)

let () =
  let open Scanf in
  scanf "%d %d\n" @@ fun n m ->
  let vertices = Array.init n (fun _ -> dummy ()) in
  let root = vertices.(0) in
  let edges = Array.make n [] in
  let add a i e = a.(i) <- e :: a.(i) in
  for _ = 1 to n - 1 do
    scanf "%d %d\n" @@ fun a b ->
    add edges (a - 1) vertices.(b - 1);
    add edges (b - 1) vertices.(a - 1)
  done;
  Array.iteri (fun i v -> v.adjacent <- Array.of_list edges.(i)) vertices;
  dfs1 root;
  dfs2 root;
  let queries, queries_list = H.create 32, ref [] in
  let add_query u v =
    H.replace
      (try H.find queries u with Not_found -> let h = H.create 16 in H.replace queries u h; h)
      v
      (ref root)
  in
  for _ = 1 to m do
    scanf "%d %d\n" @@ fun u v ->
    let u, v = vertices.(u - 1), vertices.(v - 1) in
    add_query u v ;
    add_query v u;
    queries_list := (u, v) :: !queries_list
  done;
  tarjan_olca queries vertices.(0);
  List.(iter (fun (u, v) -> Printf.printf "%.7f\n" @@ solve queries root u v) @@ rev !queries_list)

module H = Hashtbl.Make(struct type t = int let equal = ((=) : int -> int -> _) let hash x = x end)

type tree = {
  verts    : int array;
  edges    : int array array;
  parent   : int array;
  depth    : int array;
  t_entr   : int array;
  t_exit   : int array;
  sigma_d  : int64 array;
  sigma'_d : int64 array;
  count    : int64 array;

  uf_parent : int array;
  uf_rank   : int array;
  ancestor  : int array;
  colored   : bool array;
  queries   : int ref H.t H.t;
}

let (+~), (-~), zero, none = Int64.(add, sub, zero, -1)

let incr a i n = a.(i) <- a.(i) +~ n

let dfs1 { verts; edges; parent; depth; t_entr; t_exit; sigma_d; count } =
  let rec dfs d t p curr =
    verts.(t) <- curr;
    t_entr.(curr) <- t;
    depth.(curr) <- d;
    parent.(curr) <- p;
    incr count curr 1L;
    let t =
      Array.fold_left
        (fun t v ->
           if v <> p then begin
             let t = dfs (d + 1) (t + 1) curr v in
             incr sigma_d curr @@ sigma_d.(v) +~ count.(v);
             incr count curr @@ count.(v);
             t
           end else t)
        t
        edges.(curr)
    in
    t_exit.(curr) <- t;
    t
  in
  ignore @@ dfs 0 0 none 0

let dfs2 { edges; parent; sigma'_d; sigma_d; count } =
  let rec dfs curr =
    let p = parent.(curr) in
    sigma'_d.(curr) <-
      if p <> none then
        (if parent.(p) <> none then sigma'_d.(p) +~ count.(0) -~ count.(p) else 0L) +~
        sigma_d.(p) -~ sigma_d.(curr) -~ count.(curr)
      else
        0L;
    Array.iter (fun v -> if v <> p then dfs v) edges.(curr)
  in
  dfs 0

let tarjan_olca { edges; parent; uf_parent; uf_rank; ancestor; colored; queries } =
  let init v =
     uf_parent.(v) <- v;
     uf_rank.(v)   <- 0
  in
  let rec find v =
    if uf_parent.(v) == v then
      v
    else
      let p = find uf_parent.(v) in
      uf_parent.(v) <- p;
      p
  in
  let union u v =
    let u, v = find u, find v in
    if uf_rank.(u) > uf_rank.(v) then
      uf_parent.(v) <- u
    else if uf_rank.(u) < uf_rank.(v) then
      uf_parent.(u) <- v
    else if u <> v then begin
      uf_parent.(v) <- u;
      uf_rank.(u) <- uf_rank.(u) + 1
    end
  in
  let rec tarjan u =
     init u;
     ancestor.(u) <- u;
     Array.iter
       (fun v ->
          if v <> parent.(u) then begin
            tarjan v;
            union u v;
            ancestor.(find u) <- u
          end)
       edges.(u);
     colored.(u) <- true;
     try
       H.iter
         (fun v a ->
            if colored.(v) then
              let r = ancestor.(find v) in
              a := r;
              H.find (H.find queries v) u := r)
         (H.find queries u)
     with
     | Not_found -> ()
  in
  tarjan 0

type data = { low : int; sub : int }

type path_kind = I of data | V

let search { verts; edges; parent; t_entr; t_exit; depth; queries } u v =
  let search u v =
    let rec search l r =
      if l = r then edges.(u).(l)
      else
        let m = l + (r - l) / 2 in
        let m = if edges.(u).(m) = parent.(u) then m + 1 else m in
        if      t_entr.(edges.(u).(m)) > t_entr.(v) then search l (m - 1)
        else if t_exit.(edges.(u).(m)) < t_exit.(v) then search (m + 1) r
        else edges.(u).(m)
    in
    search 0 (Array.length edges.(u) - 1)
  in
  let kind =
    if      t_entr.(u) <= t_entr.(v) && t_exit.(u) >= t_exit.(v) then I { low = v; sub = search u v }
    else if t_entr.(v) <= t_entr.(u) && t_exit.(v) >= t_exit.(u) then I { low = u; sub = search v u }
    else V
  in
  kind, depth.(u) + depth.(v) - 2 * depth.(!H.(find (find queries u) v))

let solve ({ sigma_d; sigma'_d; count } as t) u v =
  let fl, (+), (/) = Int64.to_float, (+.), (/.) in
  match search t u v with
  | V, n ->
    float_of_int n + 1. + fl sigma_d.(u) / fl count.(u) + fl sigma_d.(v) / fl count.(v)
  | I { low; sub } , n ->
    float_of_int n + 1. + fl sigma_d.(low) / fl count.(low) + fl sigma'_d.(sub) / fl (count.(0) -~ count.(sub))

let () =
  let open Scanf in
  scanf "%d %d\n" @@ fun n m ->
  let edges = Array.make n [] in
  let add a i e = a.(i) <- e :: a.(i) in
  for _ = 1 to n - 1 do
    scanf "%d %d\n" @@ fun a b ->
    add edges (a - 1) (b - 1);
    add edges (b - 1) (a - 1)
  done;
  let t =
    Array.{
      verts    = make n none;
      edges    = init n (fun i -> Array.of_list edges.(i));
      parent   = make n none;
      depth    = make n none;
      t_entr   = make n none;
      t_exit   = make n none;
      sigma_d  = make n zero;
      sigma'_d = make n zero;
      count    = make n zero;

      uf_parent = make n none;
      uf_rank   = make n none;
      ancestor  = make n none;
      colored   = make n false;
      queries   = H.create 32;
    }
  in
  dfs1 t;
  dfs2 t;
  let queries = ref [] in
  let add_query u v =
    H.replace
      (try H.find t.queries u with Not_found -> let h = H.create 16 in H.replace t.queries u h; h)
      v
      (ref none)
  in
  for _ = 1 to m do
    scanf "%d %d\n" @@ fun u v ->
    add_query (u - 1) (v - 1);
    add_query (v - 1) (u - 1);
    queries := (u - 1, v - 1) :: !queries
  done;
  tarjan_olca t;
  List.(iter (fun (u, v) -> Printf.printf "%.7f\n" @@ solve t u v) @@ rev !queries)

  (* keywords: dynamic programming, tree DP, union find, tarjan LCA *)
  (* see also ~/Sync/contest-work/NCPC-2014/particle/ *)

let order (a,b) = (min a b, max a b)

let ( ** ) a b = Int64.mul a b
let ( ++ ) a b = Int64.add a b
let long x = Int64.of_int x
let float = Int64.to_float

open Printf
open Scanf

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

  let tree = Array.make n [] in

  for i=1 to n-1 do
    let (a,b) = read_pair () in
    let (a,b) = (a-1,b-1) in
    tree.(a) <- b::tree.(a);
    tree.(b) <- a::tree.(b);
  done;

  let qgraph = Array.make n [] in
  let query = Array.make m (0,0) in

  for i=0 to m-1 do
    let (a,b) = read_pair () in
    let (a,b) = (a-1,b-1) in
    query.(i) <- (a,b);
    qgraph.(a) <- b::qgraph.(a);
    qgraph.(b) <- a::qgraph.(b);
  done;

  (* ------------------ union find ------------------- *)
  let uf = Array.make n (-1) in

  let rec find i = if uf.(i) < 0 then i else
      let r = find uf.(i) in
      uf.(i) <- r;
      r
  in

  let union i j =
    (* assume i and j are both canonical elements *)
    (* true union by rank (not size) *)
    let (wi,wj) = (-uf.(i), -uf.(j)) in
    let (wi,wj,i,j) = if wi < wj then (wi,wj,i,j) else (wj,wi,j,i) in
    uf.(j) <- - ((if wi=wj then 1 else 0) + wj);
    uf.(i) <- j;
  in
  (* ---------------- end union find ------------------ *)

  (* pure version
  (* ------------------ off-line LCA ------------------- *)
  let lca = Hashtbl.create 100 in
  let mark = Array.make n false in
  let ancestor = Array.make n 0 in

  let rec tarjan p u =
    List.iter (fun v -> if v <> p then (
      tarjan u v;
      union (find u) (find v);
      ancestor.(find u) <- u
    )) tree.(u);

    mark.(u) <- true;

    List.iter (fun v ->
      if mark.(v) then Hashtbl.replace lca (order (u,v)) ancestor.(find v)
    ) qgraph.(u)
  in
  tarjan (-1) 0;

  (* Hashtbl.iter (fun (u,v) a -> printf "LCA(%d,%d) = %d\n" (u+1) (v+1) (a+1)) lca;  *)
  (* ---------------- end off-line LCA ------------------ *)   *)

  (* ------------------ customized off-line LCA ------------------- *)
  let nbr = Hashtbl.create 100 in
  let dist = Hashtbl.create 100 in
  let mark = Array.make n false in
  let on_stack = Array.make n false in
  let ancestor = Array.make n 0 in
  let current_child = Array.make n 0 in
  let parent = Array.make n 0 in
  let depth = Array.make n 0 in

  let rec tarjan p u d =
    parent.(u) <- p;
    depth.(u) <- d;
    on_stack.(u) <- true;
    List.iter (fun v -> if v <> p then (
      current_child.(u) <- v;
      tarjan u v (d+1);
      union (find u) (find v);
      ancestor.(find u) <- u
    )) tree.(u);

    on_stack.(u) <- false;
    mark.(u) <- true;

    List.iter (fun v ->
      if mark.(v) then (
	let lca = ancestor.(find v) in
	let distance = depth.(v) + depth.(u) - 2*depth.(lca) in
	Hashtbl.add dist (order (u,v)) distance;
	if u <> lca then Hashtbl.add nbr (u,v) p;
	if v <> lca then Hashtbl.add nbr (v,u) parent.(v)
      ) else (
	if on_stack.(v) then Hashtbl.add nbr (v,u) current_child.(v)
      )
    ) qgraph.(u)
  in
  tarjan (-1) 0 0;
  (* --------------------------------------------------------------- *)

  (* now count paths *)

  let info = Hashtbl.create 100 in

  let rec dfs p u =
    try Hashtbl.find info (p,u) with Not_found ->
      let answer =
	List.fold_left (fun (ac_len, ac_n) v ->
	  if v = p then (ac_len, ac_n) else
	    let (pathlen, nnodes) = dfs u v in
	    (ac_len ++ pathlen ++ nnodes, ac_n ++ nnodes)
	) (0L, 1L) tree.(u)
      in
      Hashtbl.add info (p,u) answer;
      answer
  in

  for i=0 to m-1 do
    let (u,v) = query.(i) in
    let nu = Hashtbl.find nbr (u,v) in
    let nv = Hashtbl.find nbr (v,u) in
    let (len_u, n_u) = dfs nu u in
    let (len_v, n_v) = dfs nv v in
    let ave_len_u = (float len_u) /. (float n_u) in
    let ave_len_v = (float len_v) /. (float n_v) in
    let path_dist = float (long (Hashtbl.find dist (order (u,v)))) in
    printf "%.8f\n" (1.0 +. ave_len_u +. ave_len_v +. path_dist)
  done;

type tree = {
  verts    : int array;
  edges    : int array array;
  parent   : int array;
  depth    : int array;
  t_entr   : int array;
  t_exit   : int array;
  sigma_d  : int64 array;
  sigma'_d : int64 array;
  count    : int64 array
}

let (+~), (-~), zero, none = Int64.(add, sub, zero, -1)

let incr a i n = a.(i) <- a.(i) +~ n

let dfs1 { verts; edges; parent; depth; t_entr; t_exit; sigma_d; count } =
  let rec dfs d t p curr =
    verts.(t) <- curr;
    t_entr.(curr) <- t;
    depth.(curr) <- d;
    parent.(curr) <- p;
    incr count curr 1L;
    let t =
      Array.fold_left
        (fun t v ->
           if v <> p then begin
             let t = dfs (d + 1) (t + 1) curr v in
             incr sigma_d curr @@ sigma_d.(v) +~ count.(v);
             incr count curr @@ count.(v);
             t
           end else t)
        t
        edges.(curr)
    in
    t_exit.(curr) <- t;
    t
  in
  ignore @@ dfs 0 0 none 0

let dfs2 { edges; parent; sigma'_d; sigma_d; count } =
  let rec dfs curr =
    let p = parent.(curr) in
    sigma'_d.(curr) <-
      if p <> none then
        (if parent.(p) <> none then sigma'_d.(p) +~ count.(0) -~ count.(p) else 0L) +~
        sigma_d.(p) -~ sigma_d.(curr) -~ count.(curr)
      else
        0L;
    Array.iter (fun v -> if v <> p then dfs v) edges.(curr)
  in
  dfs 0

type data = { low : int; sub : int }

type path_kind = I of data | V

let search { verts; edges; t_entr; t_exit; depth } u v =
  let search u v =
    let rec search l r =
      if l = r then edges.(u).(l)
      else
        let m = l + (r - l) / 2 in
        if      t_entr.(edges.(u).(m)) > t_entr.(v) then search l (m - 1)
        else if t_exit.(edges.(u).(m)) < t_exit.(u) then search (m + 1) r
        else edges.(u).(m)
    in
    search 0 (Array.length edges.(u) - 1)
  in
  let kind =
    if      t_entr.(u) <= t_entr.(v) && t_exit.(u) >= t_exit.(v) then I { low = v; sub = search u v }
    else if t_entr.(v) <= t_entr.(u) && t_exit.(v) >= t_exit.(u) then I { low = u; sub = search v u }
    else V
  in
  let rec search l r =
    if l = r then verts.(l)
    else
      let m = l + (r - l + 1) / 2 in
      (*Printf.eprintf "m=%d(%d) t_entr.(m)=%d t_exit.(m)=%d t_entr.(u)=%d t_entr.(v)=%d\n"
        m verts.(m) t_entr.(verts.(m)) t_exit.(verts.(m)) t_entr.(u) t_entr.(v);*)
      if t_entr.(verts.(m)) > min t_entr.(u) t_entr.(v) ||
         t_exit.(verts.(m)) < max t_exit.(u) t_exit.(v)
      then search l (m - 1)
      else search m r
  in
  (*Printf.eprintf "For u=%d v=%d search gave %d\n" u v (search 0 (Array.length verts - 1));*)
  kind, depth.(u) + depth.(v) - 2 * depth.(search 0 (Array.length verts - 1))

let solve ({ sigma_d; sigma'_d; count } as t) u v =
  let fl, (+), (/) = Int64.to_float, (+.), (/.) in
  match search t u v with
  | V, n ->
    float_of_int n + 1. + fl sigma_d.(u) / fl count.(u) + fl sigma_d.(v) / fl count.(v)
  | I { low; sub } , n ->
    (*Printf.eprintf "u=%d v=%d n=%d s=%d l=%d fp=%f num=%f den=%f\n"
      u v n sub low
      (float_of_int n + 1. + fl sigma_d.(low) / fl count.(low))
      (fl sigma'_d.(sub))
      (fl (count.(0) -~ count.(sub)));*)
    float_of_int n + 1. + fl sigma_d.(low) / fl count.(low) + fl sigma'_d.(sub) / fl (count.(0) -~ count.(sub))

let () =
  let open Scanf in
  scanf "%d %d\n" @@ fun n m ->
  let edges = Array.make n [] in
  let add a i e = a.(i) <- e :: a.(i) in
  for _ = 1 to n - 1 do
    scanf "%d %d\n" @@ fun a b ->
    add edges (a - 1) (b - 1);
    add edges (b - 1) (a - 1)
  done;
  let t =
    Array.{
      verts    = make n none;
      edges    = init n (fun i -> Array.of_list edges.(i));
      parent   = make n none;
      depth    = make n none;
      t_entr   = make n none;
      t_exit   = make n none;
      sigma_d  = make n zero;
      sigma'_d = make n zero;
      count    = make n zero
    }
  in
  dfs1 t;
  dfs2 t;
  for _ = 1 to m do
    scanf "%d %d\n" @@ fun u v -> Printf.printf "%.7f\n" @@ solve t (u - 1) (v - 1)
  done

type tree = {
  verts    : int array;
  edges    : int array array;
  parent   : int array;
  depth    : int array;
  t_entr   : int array;
  t_exit   : int array;
  sigma_d  : int64 array;
  sigma'_d : int64 array;
  count    : int64 array
}

let (+~), (-~), zero, none = Int64.(add, sub, zero, -1)

let incr a i n = a.(i) <- a.(i) +~ n

let dfs1 { verts; edges; parent; depth; t_entr; t_exit; sigma_d; count } =
  let rec dfs d t p curr =
    verts.(t) <- curr;
    t_entr.(curr) <- t;
    depth.(curr) <- d;
    parent.(curr) <- p;
    incr count curr 1L;
    let t =
      Array.fold_left
        (fun t v ->
           if v <> p then begin
             let t = dfs (d + 1) (t + 1) curr v in
             incr sigma_d curr @@ sigma_d.(v) +~ count.(v);
             incr count curr @@ count.(v);
             t
           end else t)
        t
        edges.(curr)
    in
    t_exit.(curr) <- t;
    t
  in
  ignore @@ dfs 0 0 none 0

let dfs2 { edges; parent; sigma'_d; sigma_d; count } =
  let rec dfs curr =
    let p = parent.(curr) in
    sigma'_d.(curr) <-
      if p <> none then
        (if parent.(p) <> none then sigma'_d.(p) +~ count.(0) -~ count.(p) else 0L) +~
        sigma_d.(p) -~ sigma_d.(curr) -~ count.(curr)
      else
        0L;
    Array.iter (fun v -> if v <> p then dfs v) edges.(curr)
  in
  dfs 0

type data = { low : int; sub : int }

type path_kind = I of data | V

let search { verts; edges; parent; t_entr; t_exit; depth } u v =
  let search u v =
    let rec search l r =
      if l = r then edges.(u).(l)
      else
        let m = l + (r - l) / 2 in
        let m = if edges.(u).(m) = parent.(u) then m + 1 else m in
        if      t_entr.(edges.(u).(m)) > t_entr.(v) then search l (m - 1)
        else if t_exit.(edges.(u).(m)) < t_exit.(v) then search (m + 1) r
        else edges.(u).(m)
    in
    search 0 (Array.length edges.(u) - 1)
  in
  let kind =
    if      t_entr.(u) <= t_entr.(v) && t_exit.(u) >= t_exit.(v) then I { low = v; sub = search u v }
    else if t_entr.(v) <= t_entr.(u) && t_exit.(v) >= t_exit.(u) then I { low = u; sub = search v u }
    else V
  in
  let rec search best l r =
    (*Printf.eprintf "best=%d l=%d r=%d\n" best l r;*)
    if l > r then verts.(best)
    else
      let m = l + (r - l + 1) / 2 in
      (*Printf.eprintf "m=%d(%d) t_entr.(m)=%d t_exit.(m)=%d t_entr.(u)=%d t_entr.(v)=%d\n"
        m verts.(m) t_entr.(verts.(m)) t_exit.(verts.(m)) t_entr.(u) t_entr.(v);*)
      if      t_entr.(verts.(m)) > min t_entr.(u) t_entr.(v) then search best l (m - 1)
      else if t_exit.(verts.(m)) < max t_exit.(u) t_exit.(v) then search best (m + 1) r
      else if m = r then verts.(m)
      else search m m r
  in
  (*Printf.eprintf "For u=%d v=%d search gave %d\n" u v (search 0 0 (Array.length verts - 1));*)
  kind, depth.(u) + depth.(v) - 2 * depth.(search 0 0 (Array.length verts - 1))

let solve ({ sigma_d; sigma'_d; count } as t) u v =
  let fl, (+), (/) = Int64.to_float, (+.), (/.) in
  match search t u v with
  | V, n ->
    float_of_int n + 1. + fl sigma_d.(u) / fl count.(u) + fl sigma_d.(v) / fl count.(v)
  | I { low; sub } , n ->
    (*Printf.eprintf "sub=%d" sub;*)
    (*Printf.eprintf "u=%d v=%d n=%d s=%d l=%d fp=%f num=%f den=%f\n"
      u v n sub low
      (float_of_int n + 1. + fl sigma_d.(low) / fl count.(low))
      (fl sigma'_d.(sub))
      (fl (count.(0) -~ count.(sub)));*)
    float_of_int n + 1. + fl sigma_d.(low) / fl count.(low) + fl sigma'_d.(sub) / fl (count.(0) -~ count.(sub))

let () =
  let open Scanf in
  scanf "%d %d\n" @@ fun n m ->
  let edges = Array.make n [] in
  let add a i e = a.(i) <- e :: a.(i) in
  for _ = 1 to n - 1 do
    scanf "%d %d\n" @@ fun a b ->
    add edges (a - 1) (b - 1);
    add edges (b - 1) (a - 1)
  done;
  let t =
    Array.{
      verts    = make n none;
      edges    = init n (fun i -> Array.of_list edges.(i));
      parent   = make n none;
      depth    = make n none;
      t_entr   = make n none;
      t_exit   = make n none;
      sigma_d  = make n zero;
      sigma'_d = make n zero;
      count    = make n zero
    }
  in
  dfs1 t;
  dfs2 t;
  for _ = 1 to m do
    scanf "%d %d\n" @@ fun u v -> Printf.printf "%.7f\n" @@ solve t (u - 1) (v - 1)
  done

type tree = {
  verts    : int array;
  edges    : int array array;
  parent   : int array;
  depth    : int array;
  t_entr   : int array;
  t_exit   : int array;
  sigma_d  : int64 array;
  sigma'_d : int64 array;
  count    : int64 array
}

let (+~), (-~), zero, none = Int64.(add, sub, zero, -1)

let incr a i n = a.(i) <- a.(i) +~ n

let dfs1 { verts; edges; parent; depth; t_entr; t_exit; sigma_d; count } =
  let rec dfs d t p curr =
    verts.(t) <- curr;
    t_entr.(curr) <- t;
    depth.(curr) <- d;
    parent.(curr) <- p;
    incr count curr 1L;
    let t =
      Array.fold_left
        (fun t v ->
           if v <> p then begin
             let t = dfs (d + 1) (t + 1) curr v in
             incr sigma_d curr @@ sigma_d.(v) +~ count.(v);
             incr count curr @@ count.(v);
             t
           end else t)
        t
        edges.(curr)
    in
    t_exit.(curr) <- t;
    t
  in
  ignore @@ dfs 0 0 none 0

let dfs2 { edges; parent; sigma'_d; sigma_d; count } =
  let rec dfs curr =
    let p = parent.(curr) in
    sigma'_d.(curr) <-
      if p <> none then
        (if parent.(p) <> none then sigma'_d.(p) +~ count.(0) -~ count.(p) else 0L) +~
        sigma_d.(p) -~ sigma_d.(curr) -~ count.(curr)
      else
        0L;
    Array.iter (fun v -> if v <> p then dfs v) edges.(curr)
  in
  dfs 0

type data = { low : int; sub : int }

type path_kind = I of data | V

let search { verts; edges; t_entr; t_exit; depth } u v =
  let search u v =
    let rec search l r =
      if l = r then edges.(u).(l)
      else
        let m = l + (r - l) / 2 in
        if      t_entr.(edges.(u).(m)) > t_entr.(v) then search l (m - 1)
        else if t_exit.(edges.(u).(m)) < t_exit.(u) then search (m + 1) r
        else edges.(u).(m)
    in
    search 0 (Array.length edges.(u) - 1)
  in
  let kind =
    if      t_entr.(u) <= t_entr.(v) && t_exit.(u) >= t_exit.(v) then I { low = v; sub = search u v }
    else if t_entr.(v) <= t_entr.(u) && t_exit.(v) >= t_exit.(u) then I { low = u; sub = search v u }
    else V
  in
  let rec search best l r =
    (*Printf.eprintf "best=%d l=%d r=%d\n" best l r;*)
    if l > r then verts.(best)
    else
      let m = l + (r - l + 1) / 2 in
      (*Printf.eprintf "m=%d(%d) t_entr.(m)=%d t_exit.(m)=%d t_entr.(u)=%d t_entr.(v)=%d\n"
        m verts.(m) t_entr.(verts.(m)) t_exit.(verts.(m)) t_entr.(u) t_entr.(v);*)
      if      t_entr.(verts.(m)) > min t_entr.(u) t_entr.(v) then search best l (m - 1)
      else if t_exit.(verts.(m)) < max t_exit.(u) t_exit.(v) then search best (m + 1) r
      else if m = r then verts.(m)
      else search m m r
  in
  (*Printf.eprintf "For u=%d v=%d search gave %d\n" u v (search 0 0 (Array.length verts - 1));*)
  kind, depth.(u) + depth.(v) - 2 * depth.(search 0 0 (Array.length verts - 1))

let solve ({ sigma_d; sigma'_d; count } as t) u v =
  let fl, (+), (/) = Int64.to_float, (+.), (/.) in
  match search t u v with
  | V, n ->
    float_of_int n + 1. + fl sigma_d.(u) / fl count.(u) + fl sigma_d.(v) / fl count.(v)
  | I { low; sub } , n ->
    (*Printf.eprintf "u=%d v=%d n=%d s=%d l=%d fp=%f num=%f den=%f\n"
      u v n sub low
      (float_of_int n + 1. + fl sigma_d.(low) / fl count.(low))
      (fl sigma'_d.(sub))
      (fl (count.(0) -~ count.(sub)));*)
    float_of_int n + 1. + fl sigma_d.(low) / fl count.(low) + fl sigma'_d.(sub) / fl (count.(0) -~ count.(sub))

let () =
  let open Scanf in
  scanf "%d %d\n" @@ fun n m ->
  let edges = Array.make n [] in
  let add a i e = a.(i) <- e :: a.(i) in
  for _ = 1 to n - 1 do
    scanf "%d %d\n" @@ fun a b ->
    add edges (a - 1) (b - 1);
    add edges (b - 1) (a - 1)
  done;
  let t =
    Array.{
      verts    = make n none;
      edges    = init n (fun i -> Array.of_list edges.(i));
      parent   = make n none;
      depth    = make n none;
      t_entr   = make n none;
      t_exit   = make n none;
      sigma_d  = make n zero;
      sigma'_d = make n zero;
      count    = make n zero
    }
  in
  dfs1 t;
  dfs2 t;
  for _ = 1 to m do
    scanf "%d %d\n" @@ fun u v -> Printf.printf "%.7f\n" @@ solve t (u - 1) (v - 1)
  done


(**D. The Child and Sequence*)

open Scanf;;
open Num;;
open Printf;;

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

let imatch = Array.create n (num_of_int 0);;
let kmatch = ref (Num.num_of_int 0);;

for i = 0 to n-1 do
  let ni = Scanf.bscanf Scanf.Scanning.stdin "%d " ( fun x -> x) in
  imatch.(i) <- num_of_int ni; kmatch :=  (num_of_int ni) +/ !kmatch
done
;;

(*Remove the average*)
let av = div_num !kmatch (num_of_int n) in
for i = 0 to n - 1 do
  imatch.(i) <- imatch.(i) -/ av
done
;;

(*Array.iter (fun x -> print_int x; print_endline "") imatch;;*)

let sum_over i j =
  let total = ref (num_of_int 0) in
  for k = i to j do
    total := !total +/  imatch.(k)
  done; total
;;

let rec direct_cal nl nr rslt =
  if nl = nr then
    rslt +/ !(sum_over nl nr)
  else
    let mid = (nl + nr) / 2 in
    let a = !(sum_over nl mid) in
    imatch.(mid) <- imatch.(mid) -/  a;
    imatch.(mid+1)<-imatch.(mid+1) +/  a;
    rslt +/ (abs_num a) +/ (direct_cal nl mid (num_of_int 0)) +/
      (direct_cal (mid + 1) nr (num_of_int 0))
;;

let rslt = direct_cal 0 (n-1) (num_of_int 0) in
print_endline (string_of_num
                 (abs_num rslt) );;

(* earlier dubug
printf "%d %d\n" n !kmatch
*)


open String

let read_ints() = Array.map (int_of_string) (Array.of_list (Str.split (Str.regexp " +") (read_line())));;
let n = read_int();;

for i = 0 to (n - 1) do
    let size = read_int() and
        arr = read_ints() and
        cnt = ref 0 in (
        for j = 0 to (size - 1) do
            if arr.(j) mod 2 = 0
            then cnt := !cnt + 1
        done;
        print_int (min (size - !cnt) !cnt)
    );
    print_newline ()
done

(* 2x-1+2y-1=2(x+y-1)
o + o = e, o+e=o
we either need all odd
or all even

e.g if we have odd anywhere in sequence,
the next number must be odd or it must be end of seq,
if it end of seq , the numbers before must be odd
*)

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

let rec read_seq = function
| 0 -> 0
| n ->
    let item = read_int () in
    if (item mod 2 ==0) then 1 + read_seq (n-1)
    else read_seq (n-1)
;;

let run_case = function
| () ->
    let n = read_int () in
    let even_count = read_seq n in
    if (even_count<=n-even_count) then even_count
    else n-even_count
;;

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

let t= read_int () in
iter_cases t;;

open String
open Printf

let read_ints() = Array.map (int_of_string) (Array.of_list (Str.split (Str.regexp " +") (read_line())));;
let n = read_int();;

for i = 0 to (n - 1) do
    let size = read_int() and
        arr = read_ints() and
        cnt = ref 0 in (
        for j = 0 to (size - 1) do
            if arr.(j) mod 2 = 0
            then cnt := !cnt + 1
        done;
        print_int (min (size - !cnt) !cnt)
    )
done

(* 2x-1+2y-1=2(x+y-1)
o + o = e, o+e=o
we either need all odd
or all even

e.g if we have odd anywhere in sequence,
the next number must be odd or it must be end of seq,
if it end of seq , the numbers before must be odd
*)

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

let rec read_seq = function
| 0 -> 0
| n ->
    let item = read_int () in
    if (item mod 2 ==0) then 1 + read_seq (n-1)
    else read_seq (n-1)
;;

let run_case = function
| () ->
    let n = read_int () in
    let even_count = read_seq n in
    if (even_count<=n-even_count) then even_count
    else n-even_count
;;

let rec iter_cases = function
| 0 -> 0
| n ->
    print_int (run_case ());
    iter_cases (n-1)
;;

let t= read_int () in
iter_cases t;;


let split_words = Str.split (Str.regexp " ")

exception Break

let primes =
  let array = Array.make 1_000_001 true in
  array.(0) <- false;
  array.(1) <- false;
  begin try
    for i = 2 to Array.length array do
      if array.(i)
      then (
        if i * i >= Array.length array
        then (raise Break);
        for j = i to (Array.length array - 1) / i do
          array.(i * j) <- false
        done)
    done
  with
  | _ -> ()
  end;
  array
;;

let is_prime n = primes.(Int64.to_int n)

let is_t_prime n =
  let sq = Int64.of_float (sqrt (Int64.to_float n)) in
  Int64.mul sq sq = n && is_prime sq
;;

let () =
  ignore (input_line stdin);
  input_line stdin
  |> split_words
  |> List.map Int64.of_string
  |> List.iter (fun number ->
    if is_t_prime number
    then (print_endline "YES")
    else (print_endline "NO"))
;;

let sieve () =
  let nums = Array.make 1000001 true in
  nums.(0) <- false;
  nums.(1) <- false;
  for i = 2 to 1000000 do
    if nums.(i) then
      let rec walk j =
	if j > 1000000 then ()
	else begin
	  nums.(j) <- false;
	  walk (j + i)
	end in
      walk (i+i)
  done;
  nums

let main =
  let primes = sieve () in
  let n = Scanf.scanf "%d" (fun n -> n) in
  for i = 1 to n do
    let f = Scanf.scanf " %f" (fun f -> f) in
    let (ff, fi) = modf (sqrt f) in
    if ff > 0.000001 then
      Printf.printf "NO\n"
    else
      Printf.printf "%s\n" (if primes.(int_of_float fi) then "YES" else "NO")
  done;

module I64 = struct
let ( / ) = Int64.div
let ( * ) = Int64.mul
let ( + ) = Int64.add
let ( - ) = Int64.sub
let ( mod ) = Int64.rem
let zero = Int64.zero
let one = Int64.one
let two = Int64.of_int 2
end

let is_prime =
    let n = 1000000 in
    let a = Array.make (n + 1) true in
    let rec loop i =
        if i * i <= n
        then
            ((if a.(i)
            then
                let rec looper j =
                if j > n
                then
                    ()
                else
                    (Array.set a j false;
                    looper (j + i))
                in looper (i * i)
            else
                ());
            loop (i + 1))
        else
            ()
    in loop 2;
    Array.set a 0 false;
    Array.set a 1 false;

    fun i -> a.(i)

let find_sqrt n =
    let open I64 in
    let r = Pervasives.sqrt (Int64.to_float n) in
    let rec loop (+) (<) approx =
        if approx * approx < n
        then
            loop (+) (<) (approx + one)
        else
            approx
    in
    let r = loop (-) (>) (loop (+) (<) (Int64.of_float r)) in
    if r * r = n
    then
        Some (Int64.to_int r)
    else
        None

let is_tprime n =
    match (find_sqrt n) with
    | Some r -> is_prime r
    | None -> false

let () =
    let length = Scanf.scanf "%d " (fun n -> n) in
    let rec loop i =
        if i < length
        then
            let number = Scanf.scanf "%Ld " (fun n -> n) in
            (if is_tprime number
            then
                Printf.printf "YES\n"
            else
                Printf.printf "NO\n");
            loop (i + 1)
        else
            ()
    in loop 0

module I64 = struct
let ( / ) = Int64.div
let ( * ) = Int64.mul
let ( + ) = Int64.add
let ( - ) = Int64.sub
let ( mod ) = Int64.rem
let zero = Int64.zero
let one = Int64.one
let two = Int64.of_int 2
end

let is_prime =
    let n = 1000000 in
    let a = Array.make (n + 1) true in
    let rec loop i =
        if i * i <= n
        then
            if a.(i)
            then
                let rec looper j =
                if j > n
                then
                    ()
                else
                    (Array.set a j false;
                    looper (j + i))
                in looper (i * i)
        else
            ()
    in loop 2;
    Array.set a 0 false;
    Array.set a 1 false;

    fun i -> a.(i)

let find_sqrt n =
    let open I64 in
    let r = Pervasives.sqrt (Int64.to_float n) in
    let rec loop (+) (<) approx =
        if approx * approx < n
        then
            loop (+) (<) (approx + one)
        else
            approx
    in
    let r = loop (-) (>) (loop (+) (<) (Int64.of_float r)) in
    if r * r = n
    then
        Some (Int64.to_int r)
    else
        None

let is_tprime n =
    match (find_sqrt n) with
    | Some r -> is_prime r
    | None -> false

let () =
    let length = Scanf.scanf "%d " (fun n -> n) in
    let rec loop i =
        if i < length
        then
            let number = Scanf.scanf "%Ld " (fun n -> n) in
            (if is_tprime number
            then
                Printf.printf "YES\n"
            else
                Printf.printf "NO\n");
            loop (i + 1)
        else
            ()
    in loop 0


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

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

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

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

(* Codeforces contest 327B - hungry seq *)

open Filename;;

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

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

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

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

let main() =
	printseq n;;

main();;