#include <iostream>
#include <iomanip> //<<setprecision(12), or <<fixed
#include <algorithm>
#include <functional>
#include <map>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
 
using namespace std;
 
using ll=long long;
using ull=unsigned long long;
using pll=pair<ll,ll>;
 
int main()
{
    ll N,M;
    cin>>N>>M;
    vector<string> S(N);
    for(auto& s:S) cin>>s;
    
    vector<ll> cnt(N,0);
    for(ll i=0; i<N; i++)
    {
        for(auto c:S[i]) if(c=='1') cnt[i]++;
        //cout<<cnt[i]<<endl;
    }
    
    vector<ll> oddsum(N+1,0), evensum(N+1,0);
    for(ll i=0; i<N; i++)
    {
        oddsum[i+1]=oddsum[i]+cnt[i]%2;
        evensum[i+1]=evensum[i]+(cnt[i]+1)%2;
        //cout<<oddsum[i+1]<<" "<<evensum[i+1]<<endl;
    }
    
    ll res=0;
    for(ll i=0; i<N; i++)
    {
        if(cnt[i]%2){ res+=evensum[N]-evensum[i]; }
        else{ res+=oddsum[N]-oddsum[i]; }
    }
    
    cout<<res<<endl;
    // Find a CounterExample.
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007;
ll fexp(ll b, ll e){
    ll res = 1;
    for(;e;e>>=1){
        if(e&1)res = (res*b)%MOD;
        b = (b*b)%MOD;
    }
    return res;
}

// INVERSO MOLTIPLICATIVO

ll inv(ll a){
    return fexp(a,MOD-2);
}
int T = 1;
ll N;
ll a;
int main(){
    cin >> N;
    ll S=N,M;
    cin >> M;
    for(int i = 0; i < N; i++){
        cin >> a;
        S+=a;
    }
    M+=N-1;
    ll r = 1;
    for(int i = 1; i <= S; i++){
        r *= (M-i+2); r%=MOD;
        r *= inv(i); r %= MOD;
    }
    cout << r << "\n";
    return 0;
}
