let () =
  let s = read_line () in
  let t = read_line () in
  let lss = Array.make_matrix (String.length s + 1) (String.length t + 1) 0 in
  let css = Array.make_matrix (String.length s + 1) (String.length t + 1) [] in
  for i = 1 to String.length s do
    for j = 1 to String.length t do
      if s.[i - 1] = t.[j - 1] then begin
        lss.(i).(j) <- 1 + lss.(i - 1).(j - 1);
        css.(i).(j) <- s.[i - 1] :: css.(i - 1).(j - 1)
      end else if lss.(i).(j - 1) <= lss.(i - 1).(j) then begin
        lss.(i).(j) <- lss.(i - 1).(j);
        css.(i).(j) <- css.(i - 1).(j)
      end else begin
        lss.(i).(j) <- lss.(i).(j - 1);
        css.(i).(j) <- css.(i).(j - 1)
      end
    done
  done;
  (List.iter print_char @@ List.rev @@ css.(String.length s).(String.length t));
  print_newline () 

