#include <bits/stdc++.h>
using namespace std;
const long long mo = 1e9 + 7;
const int L = 100005;
int n, m;
char a[L], b[L];
struct data {
  long long cnt, sum, pro, l, r;
  data(long long Cnt = 1, long long Sum = 0, long long Pro = 0, long long L = 0,
       long long R = 0)
      : cnt(Cnt), sum(Sum), pro(Pro), l(L), r(R) {}
  data put(long long h) {
    h %= mo;
    return data(cnt, (sum + (cnt - 1) * 2 % mo * h % mo) % mo,
                (pro + (cnt - 1) * h % mo * h % mo + sum * h % mo) % mo,
                (l + h) % mo, (r + h) % mo);
  }
} x, y, z;
data operator+(const data &a, const data &b) {
  return data((a.cnt + b.cnt) % mo, (a.sum + b.sum + a.r + b.l) % mo,
              (a.pro + b.pro + a.r * b.l) % mo, a.l, b.r);
}
int main() {
  scanf("%s%s", a, b);
  n = strlen(a);
  reverse(a, a + n);
  reverse(b, b + n);
  for (m = n; a[m - 1] == b[m - 1]; m--)
    ;
  long long w = 1;
  for (int i = 0; i < m - 1; i++, (w *= 10) %= mo) {
    x = x.put((a[i] - '0') * w);
    y = y.put((b[i] - '0') * w);
    if (a[i] == '4') x = x + z.put(7 * w);
    if (b[i] == '7') y = z.put(4 * w) + y;
    z = z.put(4 * w) + z.put(7 * w);
  }
  x = x.put((a[m - 1] - '0') * w);
  y = y.put((b[m - 1] - '0') * w);
  x = x + y;
  (w *= 10) %= mo;
  for (int i = m; i < n; i++, (w *= 10) % mo) x = x.put((a[i] - '0') * w);
  printf("%I64d\n", x.pro);
}
