
uses Math;
 
const MD = 1000000007;
 
var ans : int64;
    col: array[0 .. 1000, 0 .. 2] of longint;
    dp : array[0 .. 1000, 0 .. 2] of longint;
    a : array[0 .. 1000, 0 .. 1000] of longint;
    t, n, m : longint;
 
 
procedure solve;
var i, j, last, cur : longint;
    begin  
        for j := 1 to m do begin
            col[j][0] := 0;
            col[j][1] := 0;
            col[j][2] := 0;
        end;
        for i := 1 to n do begin
            for j := 1 to m do begin
                if a[i][j] = 0 then continue;
                if i and 1 = 1 then
                    inc(col[j][a[i][j]])
                else
                    inc(col[j][3 - a[i][j]]);
            end;
        end;
        dp[0][1] := 1;
        dp[0][2] := 1;
        for i := 1 to m do begin
            for last := 1 to 2 do begin
                cur := 0;
                for j := i downto 1 do begin
                    if col[j][3 - last] > 0 then
                        break;
                    inc(cur, dp[j - 1][3 - last]);
                    cur := cur mod MD;
                end;
                dp[i][last] := cur;
            end;
        end;
        ans := ans + dp[m][1] + dp[m][2];
        ans := ans mod MD;
    end;
 
var i, j, c : longint;
    ok : boolean;
    ch : char;
 
begin
    assign(input, 'famine.in');
    assign(output, 'famine.out');
    reset(input);
    rewrite(output);
    readln(n, m);
    for i := 1 to n do begin
        for j := 1 to m do begin
            read(ch);
            if ch = '.' then a[i][j] := 0 else
            if ch = '-' then a[i][j] := 1 else
                a[i][j] := 2;
        end;
        readln;
    end;
    ans := 0;
    solve();
    t := n;
    n := m;
    m := t;
    for i := 1 to max(n, m) do
        for j := i + 1 to max(n, m) do begin
            t := a[i][j];
            a[i][j] := a[j][i];
            a[j][i] := t;
        end;
    solve();
    for c := 0 to 1 do begin
        ok := true;
        for i := 1 to n do
            for j := 1 to m do begin
                if a[i][j] = 0 then
                    continue;
                if ((i xor j xor c) and 1) + 1 <> a[i][j] then
                    ok := false;
            end;
        if ok then
            dec(ans);    // bug detected, but got accepted
    end;         
    writeln(ans);
end.
