{$R+,Q+}

{$APPTYPE CONSOLE}

const
  NMAX = 100;
  MMAX = 100;
  TMAX = 100;
  ES = '#';

var
  n,m: Integer; //размеры кроссворда
  i,j,k,l,i1,j1: Integer;
  s,s1: ShortString;

  cross: array[0..NMAX+1,0..MMAX+1] of char;
    
  cwords: array[1..NMAX*MMAX*2] of String;
  cN: Integer;

  tn,tm: Integer; //размеры таблички
  tbl: array[1..TMAX,1..TMAX] of char;

  twords: array[1..TMAX*TMAX*TMAX*6] of String;
  tCnt: Integer;

  moves: array[1..2,1..4] of Integer;

procedure QuickSort(Lo, Hi: Integer);

procedure Sort(l, r: Integer);
var
  i, j: integer;
  x,y: String;
begin
  i := l; j := r; x := twords[(l+r) DIV 2];
  repeat
    while twords[i] < x do i := i + 1;
    while x < twords[j] do j := j - 1;
    if i <= j then
    begin
      y := twords[i]; twords[i] := twords[j]; twords[j] := y;
      i := i + 1; j := j - 1;
    end;
  until i > j;
  if l < j then Sort(l, j);
  if i < r then Sort(i, r);
end;

begin {QuickSort};
  Sort(Lo,Hi);
end;

procedure swap(var s: ShortString);
var
  i,m,l: Integer;
  c: char;
begin
  m:=length(s) div 2;
  l:=length(s);
  for i:=1 to m do 
  begin
    c:=s[i];
    s[i]:=s[l-i+1];
    s[l-i+1]:=c;
  end;
end;

function find(var s: String):boolean;
var
  l,r,m: Integer;
begin
  l:=1; r:=tCnt;
  repeat
    m := (l+r) div 2;
    if twords[m]=s then begin find:=true;exit;end;
    if s<twords[m] then r:=m-1 else l:=m+1;
  until l>r;
  find:=false;
end;

begin

//  assign(input,'input.txt'); reset(input);
//  assign(output,'output.txt'); rewrite(output);

  readln(n,m);
  fillchar(cross,sizeof(cross),ES);
  for i:=1 to n do 
  begin
    readln(s);
    for j:=1 to length(s) do cross[i,j]:=s[j];
  end;

  //считываем слова кроссворда
  cN:=0;
  for i:=1 to n do
    for j:=1 to m do
      if cross[i,j]<>ES then
      begin
        //слева направо
        if (cross[i,j-1]=ES)and(cross[i,j+1]<>ES) then
        begin
          inc(cN);
          cwords[cN]:='';
          k:=j;
          while cross[i,k]<>ES do 
          begin
            cwords[cN] := cwords[cN] + cross[i,k];
            inc(k);
          end;
        end;
        //сверху вниз
        if (cross[i-1,j]=ES)and(cross[i+1,j]<>ES) then
        begin
          inc(cN);
          cwords[cN]:='';
          k:=i;
          while cross[k,j]<>ES do 
          begin
            cwords[cN] := cwords[cN] + cross[k,j];
            inc(k);
          end;
        end;
      end;

  //считываем табличку
  readln(tn,tm);
  for i:=1 to tn do
  begin
    readln(s);
    for j:=1 to length(s) do tbl[i,j]:=s[j];
  end;

  //считываем слова из таблички
  moves[1,1]:=1; moves[2,1]:=0; {  \/  }
  moves[1,2]:=0; moves[2,2]:=1; {  ->  }
  moves[1,3]:=1; moves[2,3]:=1; {  \  }
  moves[1,4]:=1; moves[2,4]:=-1;{  /  }
  tCnt := 0;
  for i:=1 to tn do
    for j:=1 to tm do
      for l:=1 to 4 do
      begin
        //встали на начало слова и выбрали направление движения
        s:=''; i1:=i; j1:=j;
        while (i1>=1) and (i1<=tn) and (j1>=1) and (j1<=tm) do
        begin
          s := s + tbl[i1,j1];
          inc(tCnt);
          twords[tCnt] := s;
          s1:=s; swap(s1);
          inc(tCnt);
          twords[tCnt] := s1;
          i1 := i1 + moves[1,l];
          j1 := j1 + moves[2,l];
        end;
      end;


  //сортируем таблицу
  QuickSort(1,tCnt);

  //выполняем поиск слова, которое отсутствует в таблице
  for i:=1 to cN do
    if not find(cwords[i]) then
    begin
      writeln(cwords[i]);
      break;
    end;

end.
