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