#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

const long mod=1000000007;
long long modinv(long long a,long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    long N,M,tmp,ans;
    ans=1;
    cin>>N>>M;
    long S=0;
    for(int i=0;i<N;++i){
        cin>>tmp;
        S+=tmp;
    }
    for(long i=1;i<=S+N;++i){
        ans=(((ans*(M+N+1-i))%mod)*modinv(i,mod))%mod;
    }
    if(ans<0){
        ans+=mod;
    }
    cout<<ans<<endl;
    return 0;
}
#include <bits/stdc++.h>

using namespace std;

int main(void) {
    int n, m;
    cin >> n >> m;

    vector<string> g(n);
    for (int i = 0; i < n; ++i) cin >> g[i];

    int ans = 0;
    for (int i = 1; i < n; ++i)
        for (int j = 1; j < m; ++j) {
            int cnt = 0;
            cnt += g[i][j] == '#';
            cnt += g[i - 1][j] == '#';
            cnt += g[i][j - 1] == '#';
            cnt += g[i - 1][j - 1] == '#';

            if (cnt & 1) ans++;
        }

    cout << ans;
}
