program bod;
var
n,m,i:integer;
x:string;
niz:array[1..6] of integer;
procedure strtoint(x:string);
          var i :integer;
          begin
          for i:=1 to m do
              begin
              if x[i]='#' then niz[i]:=-1;
              if x[i]='.' then niz[i]:=5;
              if x[i]='0' then niz[i]:=0;
              if x[i]='1' then niz[i]:=1;
              if x[i]='2' then niz[i]:=2;
              if x[i]='3' then niz[i]:=3;
              if x[i]='4' then niz[i]:=4;
              end;
              end;
begin
read(n,m);
for i:=1 to n do
begin
    read(x);
    strtoint(x);
end;
write(-1);
end.