#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

long power_mod(long a, long b, long m)
{
    int k = 0;
    long c = b;
    long n = 1L;
    while (c >= 1)
    {
        c >>= 1;
        ++k;
    }
    for (int i = k; i >= 0; --i)
    {
        n = ((b >> i) & 1) ? (n * n * a) % m : (n * n) % m;
    }
    return n;
}

int main()
{
    const long P = 1000000007;
    int H, W;
    cin >> H >> W;
    //string *S = new string[H];
    bool **S = new bool *[H];
    string Str;
    int K = 0;
    int **illuminate = new int *[H];
    for (int i = 0; i < H; ++i)
    {
        cin >> Str;
        S[i] = new bool[W];
        illuminate[i] = new int[W];
        for (int j = 0; j < W; j++)
        {
            S[i][j] = (Str.at(j) == '.');
            K += (S[i][j] ? 1 : 0);
            illuminate[i][j] = 0;
        }
    }

    //horizontal
    for (int i = 0; i < H; i++)
    {
        int j = 0;
        while (j < W)
        {
            int len = 0;
            while (j < W && !S[i][j])
            {
                j++;
            }
            while (j + len < W && S[i][j + len])
            {
                len++;
            }
            for (int k = 0; k < len; ++k)
            {
                illuminate[i][j + k] += len;
            }
            j = j + len;
        }
    }

    //vertical
    for (int j = 0; j < W; j++)
    {
        int i = 0;
        while (i < H)
        {
            int len = 0;
            while (i < H && !S[i][j])
            {
                i++;
            }
            while (i + len < H && S[i + len][j])
            {
                len++;
            }
            for (int k = 0; k < len; ++k)
            {
                illuminate[i + k][j] += len;
            }
            i = i + len;
        }
    }

    long sum = 0;
    long C = power_mod(2, K, P);

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (illuminate[i][j] > 0)
            {
                sum += C - power_mod(2, K - illuminate[i][j] + 1, P);
            }
        }
    }

    cout << (sum % P + P) % P;

    return 0;
}
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define INT(n) int n;assert(0<scanf("%d",&n))

static const int MAXP = 1000000;
vector<int> ps, fs;
void init(){
  fs.reserve(1 + MAXP);
  for(int i = 0; i <= MAXP; i++){fs.push_back(i);}
  for(int i = 2; i <= MAXP; i++){
    if (fs[i] == i){
      ps.push_back(i);
      for (int j = i; j <= MAXP; j += i){
        fs[j] = min(fs[j], i);
      }
    }
  }
}
bool isprime(const long long& n){
  if (n <= MAXP){
    return (1 < n && fs[n] == n);
  } else {
    for(int p: ps){
      if (n % p == 0){return false;}
    }
    return true;
  }
}
vector<pair<long long, int>> factor(long long n){
  vector<pair<long long, int>> v;
  long long i = n;
  if (MAXP < i){
    for(int p: ps){
      int r = 0;
      while (i % p == 0){r++; i /= p;}
      if (0 < r){v.push_back(make_pair(p, r));}
      if (i <= MAXP){break;}
    }
    if (MAXP < i){
      v.push_back(make_pair(i, 1));
      i = 1;
    }
  }
  while(1 < i){
    if (v.empty() || (*v.rbegin()).first != fs[i]){
      v.push_back(make_pair(fs[i], 1));
    } else {
      (*v.rbegin()).second++;
    }
    i /= fs[i];
  }
  return v;
}

int moebius(long long n){
  int m = 1;
  for(auto pr: factor(n)){
    if (pr.second == 1){
      m *= -1;
    } else {m = 0; break;}
  }
  return m;
}

int main(){
  ll ans = 0;
  init();
  INT(l); INT(r);
  REP(i, 2, r / 2 + 1){
    int n = r / i - (l - 1) / i;
    ans += (ll) -moebius(i) * n * (n - 1);
    if (l <= i){ans -= 2*(n - 1);}
  }
  printf("%lld\n", ans);
  return 0;
}
