#include <iostream>

using ll = long long;

int const nmax = 100000;
int const modulo = 1000000007;
std::pair<int,int> dp[5 + nmax][2];
int v[5 + nmax];

std::pair<int,int> add(std::pair<int,int> f1, std::pair<int, int> f2) {
  return {(f1.first + f2.first) % modulo,
          (f1.second + f2.second) % modulo};
}

std::pair<int,int> append(std::pair<int,int> f1, int val) {
  return {f1.first, (f1.second + 1LL * f1.first * val) % modulo};
}

int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);

  int n;
  std::cin >> n;

  for(int i = 1;i <= n; i++)
    std::cin >> v[i];
  dp[1][0] = {1, v[1]};
  for(int i = 2; i <= n; i++) {
    dp[i][0] = append(add(dp[i - 1][0], dp[i - 1][1]), v[i]);
    dp[i][1] = append(dp[i - 1][0], modulo -v[i]);
  }
  std::cout << add(dp[n][0], dp[n][1]).second;
  return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define rng(i,l,r) for (int i=l; i<r; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define endl "\n"
#define INF 1000000007 // 1e9+7
#define LINF 1152921504606846976 // 1LL<<60
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> using V = vector<T>;
template<class T> bool chmin(T& a, T b){ if (a > b){ a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b){ if (a < b){ a = b; return true; } return false; }
struct in { template <class T> operator T() { T t; std::cin >> t; return t; } };
int dx[8] = {0,1,0,-1,1,1,-1,-1};
int dy[8] = {1,0,-1,0,1,-1,1,-1};

auto solve() {
   ll n = in();
   int m = in();

   V<string> ss(n);
   rep(i,n) {
      cin >> ss[i];
   }

   ll ans = n * (n-1) / 2;

   ll c = 1;
   int di = -1;
   rng(j,1,n) {
      int d = 0;
      rep(k,m) {
         if (ss[0][k] != ss[j][k]) d++;
      }
      if (d % 2 == 0) c++;
      else di = j;
   }

   ans -= c * (c-1) / 2;
   if (di != -1) {
      c = 1;
      rep(j,n) {
         if (j == di) continue;
         int d = 0;
         rep(k,m) {
            if (ss[di][k] != ss[j][k]) d++;
         }
         if (d % 2 == 0) c++;
      }
      ans -= c * (c-1) / 2;
   }

   return ans;
}

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   cout << solve() << endl;
}
