#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using llong = long long;
using vi    = vector<int>;
using vvi   = vector<vi >;
using vvvi  = vector<vvi >;
using pii   = pair<int,int>;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

int main(){//Refering other editorials.
	int h,w;
	cin>>h>>w;
	
	vector<string> vs(h);
	REP(i,h) cin>>vs[i];
	
	int all=0;//散らかってない箇所の数の合計.
	vvi num(h,vi(w,0));//(y,x)を照らすことができる照明の数.
	REP(i,h){
		int cnt=1;
		REP(j,w){
			if(vs[i][j]=='.'){
				all++;
				num[i][j]+=cnt;
				cnt++;
			}else cnt=1;
		}
		cnt=0;
		for(int j=w-1;j>=0;--j){
			if(vs[i][j]=='.'){
				num[i][j]+=cnt;
				cnt++;
			}else cnt=0;
		}
	}
	REP(j,w){
		int cnt=0;
		REP(i,h){
			if(vs[i][j]=='.'){
				num[i][j]+=cnt;
				cnt++;
			}else cnt=0;
		}
		cnt=0;
		for(int i=h-1;i>=0;--i){
			if(vs[i][j]=='.'){
				num[i][j]+=cnt;
				cnt++;
			}else cnt=0;
		}
	}
	//debug(all);
	
	vector<llong> mem(all+1,1);//mem[i]:=2^i;
	for(int i=1;i<=all;++i) mem[i]=mem[i-1]*2%MOD;
	
	llong ans=all*mem[all]%MOD;//全事象.
	REP(i,h)REP(j,w){
		if(vs[i][j]=='.'){
			llong tmp=mem[all-num[i][j]];
			ans=(ans-tmp+MOD)%MOD;
		}
	}
	
	cout<<ans<<endl;
	return 0;
}

// coded by zeffy
#include <bits/stdc++.h> 
using namespace std;
#define hello cout<<"hello"<<"\n"
#define forr(i,a,b) for(int i=a;i<b;i++)
#define dbg(s)	cout<<#s<<"= "<<s<<endl;
typedef long long int lli;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
		
	int n;cin>>n;
	string s;int q;cin>>s>>q;
	string s1,s2;
	for(int i=0;i<n;i++) s1+=s[i];
	for(int i=n;i<2*n;i++) s2+=s[i];
	while(q--)
	{
		int ch;cin>>ch;
		if(ch==1)
		{
			int a,b;cin>>a>>b;a--;b--;if(a>=n) {a-=n;b-=n;char temp=s2[a];s2[a]=s2[b];s2[b]=temp;}
			else if(b>=n) {b-=n;char temp=s1[a];s1[a]=s2[b];s2[b]=temp;}
			else {char temp=s1[a];s1[a]=s1[b];s1[b]=temp;}
		}
		else
		{
			int a,b;cin>>a>>b;
			swap(s1,s2);
		}
	}
	cout<<s1<<s2<<"\n";






    
    return 0;
}
