open String
let () =
  Scanf.scanf " %s %s" @@ fun s t ->
  let s_len = length s in
  let t_len = length t in
  let dpl = Array.init (s_len+1) (fun _ -> Array.make (t_len+1) 0) in
  let dpp = Array.init (s_len+1) (fun _ -> Array.init (t_len+1) (fun _ -> [])) in
  for si = 0 to s_len-1 do
    for ti = 0 to t_len-1 do
      if s.[si] = t.[ti] then begin
        dpl.(si+1).(ti+1) <- dpl.(si).(ti) + 1;
        dpp.(si+1).(ti+1) <- s.[si] :: dpp.(si).(ti);
      end else
      if dpl.(si+1).(ti) > dpl.(si).(ti+1) then begin
        dpl.(si+1).(ti+1) <- dpl.(si+1).(ti);
        dpp.(si+1).(ti+1) <- dpp.(si+1).(ti);
      end else begin
        dpl.(si+1).(ti+1) <- dpl.(si).(ti+1);
        dpp.(si+1).(ti+1) <- dpp.(si).(ti+1);
      end
    done;
  done;
  dpp.(s_len).(t_len)
  |> List.rev |> List.iter print_char;
  print_newline ()

