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

public class famine_pk {

	PrintWriter out;
	BufferedReader br;
	StringTokenizer st;

	String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

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

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

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

	public void solve() throws IOException {
		long modulo = (long) (1e9 + 7);
		int n = nextInt();
		int m = nextInt();
		String[] a = new String[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextToken();
		}
		
		char[] x = new char[m];
		char[] y = new char[m];
		for (int i = 0; i < m; i++) {
			if (i % 2 == 0) {
				x[i] = '+';
				y[i] = '-';
			} else {
				x[i] = '-';
				y[i] = '+';
			}
		}
		
		long ans = 0;
		boolean p1 = true;
		boolean p2 = true;
		int cnt = 0;
		boolean pos = true;
		for (int i = 0; i < n; i++) {
			boolean mx = true;
			boolean my = true;
			for (int j = 0; j < m; j++) {
				if (a[i].charAt(j) == '.') {
					continue;
				}
				if (a[i].charAt(j) != x[j])
					mx = false;
				if (a[i].charAt(j) != y[j])
					my = false;
			}
			if (mx && my) {
				cnt++;
			}
			
			if (i % 2 == 0) {
				p1 &= mx;
				p2 &= my;
			} else {
				p1 &= my;
				p2 &= mx;
			}
			
			if (!mx && !my)
				pos = false;
		}
		if (pos) {
			ans = ans + pow(cnt, modulo);
		}
		
		
		x = new char[n];
		y = new char[n];
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				x[i] = '+';
				y[i] = '-';
			} else {
				x[i] = '-';
				y[i] = '+';
			}
		}
		
		cnt = 0;
		pos = true;
		for (int i = 0; i < m; i++) {
			boolean mx = true;
			boolean my = true;
			for (int j = 0; j < n; j++) {
				if (a[j].charAt(i) == '.') {
					continue;
				}
				if (a[j].charAt(i) != x[j])
					mx = false;
				if (a[j].charAt(i) != y[j])
					my = false;
			}
			if (mx && my) {
				cnt++;
			}
			if (!mx && !my)
				pos = false;
		}
		if (pos) {
			ans = ans + pow(cnt, modulo);
		}
		
		if (p1)
			ans--;
		if (p2)
			ans--;
		
		ans = (ans + modulo) % modulo;
		out.println(ans);
	}

	private long pow(int cnt, long modulo) {
		long ans = 1;
		for (int i = 0; i < cnt; i++) {
			ans = ans * 2;
			ans = ans % modulo;
		}
		return ans;
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			br = new BufferedReader(new FileReader("famine.in"));
			out = new PrintWriter("famine.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

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