let cv c = int_of_char c - int_of_char 'a';;
let vc i = char_of_int (i + int_of_char 'a');;

let inp = open_in "aplusb.in";;
let out = open_out "aplusb.out";;

let ln = input_line inp;;
let (n,v) = Scanf.sscanf ln "%d%[ ]%d" (fun i _ j -> (i,j));;
let vv = Array.make n (Array.to_list (Array.init 26 vc));;

let pos c i = List.fold_left (fun n c' -> if c' < c then n+1 else n) 0 vv.(i);;
let mval v i = List.nth vv.(i) v;;

for i = 1 to v do
  let ln = input_line inp in
  for j = 0 to n-1 do vv.(j) <- List.filter (fun c -> c != ln.[j]) vv.(j) done
done;;

let a = input_line inp;;
let b = input_line inp;;

let rec sum i carry res =
  if i >= 0 then (
    let wt = List.length vv.(i) in
    let s = (pos a.[i] i) + (pos b.[i] i) + carry in
    sum (i-1) (s / wt) (mval (s mod wt) i :: res)
  )
  else res
in List.iter (Printf.fprintf out "%c") (sum (n-1) 0 []);;

close_in inp;;
close_out out;;
