#include<bits/stdc++.h>
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define int long long
#define sz(x) (ll)(x.size())
using namespace std;


const int mod = 1e9+7;

int expo_pow(int x,int y){
 if(y == 0) return 1;
  y=y%(mod-1);
  x%=mod;
  if(y==0) y=mod-1;
  int res=1;
  while(y){
    if(y&1) res=(res*x)%mod;
    x=(x*x)%mod;
    y>>=1; 
  }
  return res;
}

ll add()
{
    return 0;
}

template <typename T, typename... Types>
T add(T var1, Types... var2){
    return (((((ll)(var1)) % mod + (ll)(add(var2...))) % mod) + mod) % mod;
}

ll mul(){
    return 1;
}

template <typename T, typename... Types>
T mul(T var1, Types... var2){
    return (((ll)(var1)) % mod * (ll)(mul(var2...))) % mod;
}

const int inf = 1e18;

void solve(){
  int n,x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];

  vector<vector<int>> dp_ways(n,vector<int>(2));
  vector<vector<int>> dp_val(n,vector<int>(2,-inf));


  int v1 = (x + a[n-1] - 1)/a[n-1];
  v1 *= a[n-1];
  v1 -= x;
  int v2 = v1 - a[n-1];

  dp_val[n-1][0] = v1;
  dp_ways[n-1][0] = 1;

  if (abs(v2) < a[n-1]) {
    dp_val[n-1][1] = v2;
    dp_ways[n-1][1] = 1;
  }

  for (int i = n-2; i >= 0; --i) {
    int high = a[i+1]/a[i];
    int low = -high;

    v1 = (x+a[i] - 1)/a[i];
    v1 *= a[i];
    v1 -= x;
    v2 = v1 - a[i];

    dp_val[i][0] = v1;

    // 0-0
    int req = (dp_val[i][0] - dp_val[i+1][0])/a[i];
    if (req > low and req < high) {
      dp_ways[i][0] += dp_ways[i+1][0];
    }

    // 1-1
    if (dp_val[i][1] != inf) {
      int req = (dp_val[i][0] - dp_val[i+1][1])/a[i];
      if (req > low and req < high) {
        dp_ways[i][0] += dp_ways[i+1][1];
      }
    }

    if (abs(v2) <  a[i]) {
      dp_val[i][1] = v2;

      int req = (dp_val[i][1] - dp_val[i+1][0])/a[i];
      if (req > low and req < high) {
        dp_ways[i][1] += dp_ways[i+1][0];
      }

      if (dp_val[i][1] != inf) {
        int req = (dp_val[i][1] - dp_val[i+1][1])/a[i];
        if (req > low and req < high) {
          dp_ways[i][1] += dp_ways[i+1][1];
        }
      }
      
    }

  }

  cout << dp_ways[0][1] + dp_ways[0][0] << "\n";
  

}


signed main(){
  fast;
  int test = 1;
  int i=1;
  while(test--){
    solve();
  }
}




#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

template <int mod>
struct ModInt {
  int64_t x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
  ModInt &operator+=(const ModInt &p) {
    if ((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if ((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int)(1LL * x * p.x % mod);
    return *this;
  }
  ModInt &operator/=(const ModInt &p) { return *this *= p.inverse(); }
  ModInt operator-() const { return ModInt() - *this; }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while (b) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v);
    return ModInt(u);
  }
  ModInt pow(int64_t e) const {
    ModInt ret(1);
    for (ModInt b = *this; e; e >>= 1, b *= b)
      if (e & 1) ret *= b;
    return ret;
  }
  friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; }
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt<mod>(t);
    return (is);
  }
  static int modulo() { return mod; }
  int get() const { return x; }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  using Mint = ModInt<int(1e9 + 7)>;
  int H, W;
  cin >> H >> W;
  string S[H];
  for (int i = 0; i < H; i++) cin >> S[i];
  Mint ans = 0;
  int u[H][W], l[H][W];
  int K = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      u[i][j] = 0;
      l[i][j] = 0;
      if (S[i][j] == '#') continue;
      u[i][j] = 1;
      l[i][j] = 1;
      K++;
      if (i > 0) u[i][j] += u[i - 1][j];
      if (j > 0) l[i][j] += l[i][j - 1];
    }
  }
  int d[H][W], r[H][W];
  for (int i = H - 1; i >= 0; i--) {
    for (int j = W - 1; j >= 0; j--) {
      d[i][j] = 0;
      r[i][j] = 0;
      if (S[i][j] == '#') continue;
      d[i][j] = 1;
      r[i][j] = 1;
      if (i + 1 < H) d[i][j] += d[i + 1][j];
      if (j + 1 < W) r[i][j] += r[i][j + 1];
    }
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#') continue;
      int k = u[i][j] - 1 + d[i][j] - 1 + l[i][j] - 1 + r[i][j] - 1 + 1;
      ans += (Mint(2).pow(k) - 1) * Mint(2).pow(K - k);
    }
  }
  cout << ans << '\n';
  return 0;
}
