#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

const ll INF=1e19;

const ll mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(ll n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (ll i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (ll i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(ll n, ll k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(ll n, ll k) {
    return fact[n]*ifact[n-k];
  }
} c(1000005);


int main(){
    ll h,w;
    cin >> h >> w;
    vector<string> s(h);
    vector<vector<ll>> a(h,vector<ll>(w)),b(h,vector<ll>(w));
    vector<vector<ll>> num(h,vector<ll>(w));
    rep(i,h){
        cin>> s[i];
    }
    ll k=0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.') k++;
        }
    }
    rep(i,h){
        ll cnt=0;
        rep(j,w){
            if(s[i][j]=='.') cnt++;
            else cnt=0;
            a[i][j]=cnt;
        }
        ll now=0;
        bool none=true;
        for(ll j=w-1;j>=0;j--){
            if(a[i][j]!=0 && none){
                now=a[i][j];
                none=false;
            }
            if(a[i][j]==0){
                none=true;
                now=0;
            }
            a[i][j]=now;
        }
    }
    
    rep(i,w){
        ll cnt=0;
        rep(j,h){
            if(s[j][i]=='.') cnt++;
            else cnt=0;
            b[j][i]=cnt;
        }
        ll now=0;
        bool none=true;
        for(ll j=h-1;j>=0;j--){
            if(b[j][i]!=0 && none){
                now=b[j][i];
                none=false;
            }
            if(b[j][i]==0){
                none=true;
                now=0;
            }
            b[j][i]=now;
        }
    }
    
    rep(i,h){
        rep(j,w){
            num[i][j]=a[i][j]+b[i][j]-1;
            //cout << num[i][j] << endl;
        }
    }
    mint two=2;
    mint ans=0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='#') continue;
            mint x=num[i][j];
            mint y=k;
            y-=x;
            mint z=two.pow(x.x);
            mint u=two.pow(y.x);
            z-=1;
            mint tot=z*u;
            ans+=tot;
        }
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll=long long;
using ld=long double;
using pll=pair<ll, ll>;
//using mint = modint1000000007;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo 2e18
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
//priority_queue<ll, vector<ll>, greater<ll>> Q;
/*
bが入ったら、aの、それ未満を上書き。　それ以上は関係ない
aが入ったら、bの未満を上書き
BIT2つかな

*/
// BIT,index = 1 ~ (0を投げるととまる）
// https://atcoder.jp/contests/abc174/submissions/21572028
//indexにする・・・？ちょうたいへん

#define M 200010
ll dat1[M], dat2[M], dat3[M], dat4[M]; //34=累積いれとく？

void add(ll i, ll x, ll id){
  if (id==1)
    for(; i<M; i += i&-i) dat1[i] += x;
  if (id==2)
    for(; i<M; i += i&-i) dat2[i] += x;
  if (id==3)
    for(; i<M; i += i&-i) dat3[i] += x;
  if (id==4)
    for(; i<M; i += i&-i) dat4[i] += x;
}

ll sum(ll i, ll id){
  ll res = 0;
  if (id==1)
    for(; i>0; i -= i&-i) res += dat1[i];
  if (id==2)
    for(; i>0; i -= i&-i) res += dat2[i];
  if (id==3)
    for(; i>0; i -= i&-i) res += dat3[i];
  if (id==4)
    for(; i>0; i -= i&-i) res += dat4[i];
  return res;
}

ll rangesum(ll L, ll R, ll id){
  return sum(R, id) - sum(L-1, id);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  ll n, m, q;
  cin >> n >> m >> q;
  ll used[3][200010]; //t, x
  rep(i, 3) rep(j, 200010) used[i][j]=1;
  ll ans = n*m;
  add(1, n, 1); //1->0
  add(1, m, 2);
  add(1, n, 3); //1->0
  add(1, m, 4);
  //34が累積和
  ll T[200010];
  ll X[200010];
  ll Y[200010];
  map<ll, ll> mp1; // val->id
  map<ll, ll> mp2; // id->val
  set<ll> se;
  se.insert(1);
  rep(i, q){
    cin >> T[i] >> X[i] >> Y[i];
    Y[i]++;
    se.insert(Y[i]);
  }
  ll cnt = 1;
  for(auto v: se){
    mp1[v] = cnt++;
  }
  cnt=1;
  for(auto v: se){      
    mp2[cnt++]=v;
  }
  rep(i, q){
    ll t=T[i];
    ll x=X[i];
    ll y=Y[i];
    ll z=used[t][x]; //val
    //まず除く
    ll zz=mp1[z];//id
    ans -= z*sum(zz, t^3); // もとあった値をなかったことに
    ans += sum(zz, (t^3)+2); // なかった場合の復元
    add(zz, -1, t);
    add(zz, -z, t+2);//累積
    used[t][x]=y;
    ll yy=mp1[y]; //id
    ans -= sum(yy, (t^3)+2);
    ans += y*sum(yy, (t^3));
    add(yy, 1, t);
    add(yy, y, t+2);
    cout << ans -n*m<< endl;
  }
}