import java.io.*;
import java.util.*;

public class famine_vd_wa2 {
	BufferedReader in;
	StringTokenizer str;
	PrintWriter out;
	String SK;

	String next() throws IOException {
		while ((str == null) || (!str.hasMoreTokens())) {
			SK = in.readLine();
			if (SK == null)
				return null;
			str = new StringTokenizer(SK);
		}
		return str.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	static final int MOD = (int) (1e+9 + 7);

	int countAns(char[][] a, int n, int m) {
		int cur = 1;
		for (int i = 0; i < n; i++) {
			boolean[] type = new boolean[2];
			for (int j = 0; j < m; j++) {
				if (a[i][j] == '+') {
					type[(j % 2) ^ 1] = true;
				}
				if (a[i][j] == '-') {
					type[j % 2] = true;
				}
			}
			if (type[0] && type[1]) {
				cur = 0;
			}
			if (!type[0] && !type[1]) {
				cur = (cur * 2) % MOD;
			}
		}
		return cur;
	}

	void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		char[][] a = new char[n][m];
		char[][] b = new char[m][n];
		for (int i = 0; i < n; i++) {
			a[i] = next().toCharArray();
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				b[j][i] = a[i][j];
			}
		}

		int res = (countAns(a, n, m) + countAns(b, m, n)) % MOD;

		int[] add = new int[2];
		Arrays.fill(add, MOD - 1);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (a[i][j] == '+') {
					add[(i + j) % 2] = 0;
				}
				if (a[i][j] == '-') {
					add[(i + j) % 2 ^ 1] = 0;
				}

			}
		}
		out.println((res + (MOD -2) % MOD) % MOD);

	}

	void run() throws IOException {
		in = new BufferedReader(new FileReader("famine.in"));
		out = new PrintWriter("famine.out");
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new famine_vd_wa2().run();
	}

}