#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int mod = 1e9 + 7;
ll n,m;
vector<char>a[1000006];
int fa[10000005];
// 初始化
void init(int n)
{
for (int i = 1; i <= n; i++)
fa[i] = i;
}
// 找父节点,路径压缩
int find(int i)
{
if (fa[i] == i)
return i;
else
{
fa[i] = find(fa[i]); // 路径压缩
return fa[i];
}
}
// 合并
void bing(int i, int j)
{
int i_fa = find(i);
int j_fa = find(j);
fa[i_fa] = j_fa;
}
ll quickp(ll a,ll b){
ll ans = 1;
while(b > 0){
if(b&1){
ans = ans * a %mod;
}
b >>= 1;
a = a*a%mod;
}
return ans%mod;
}
void solve()
{
cin >> n >> m;
init(n);
for(int i = 1;i <= n;i++){
a[i].clear();
a[i].push_back(0);
for(int j = 1;j <= m;j++){
char x;cin >> x;
a[i].push_back(x);
}
}
// cout << a[1][2] << "?";
for(int j = 1;j <= (m-1)/2+1;j++){
ll cnt1 = 0;
ll x,y;
for(int i = 1;i <= n;i++){
if(a[i][j] == '1'){
cnt1++;
if(cnt1 == 1)x = i;
if(cnt1 == 2)y = i;
if(cnt1 > 2){
cout << "0\n";
return ;
}
}
}
// cout << "cnt " << cnt1 << "\n";
for(int i = 1;i <= n;i++){
if(a[i][m-j+1] == '1'){
cnt1++;
if(cnt1 == 1)x = i;
if(cnt1 == 2)y = i;
if(cnt1 > 2){
cout << "0\n";
return ;
}
}
}
if(cnt1 == 2)
bing(x,y);
}
ll cnt2=0;
for(int i = 1;i <= n;i++){
if(fa[i] == i){
cnt2++;
}
}
cout << quickp(2,cnt2) << "\n";
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);