// █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
// █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█
// █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█
// █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄▄▄█▀███▀▀▀▀▀██▀▀▀▀▄▄▄▄░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█
// █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄█▀▀░░▄▄██▀▀░░░▄█▀░░░░░░░▄█▀█▄▄░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█
// █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▄█▀▀░░░▄▄█▀█▀░░░░▄█░░░░░░░░░░░▀█░▀███▄▄░░░░░░░░░░░░░░░░░░░░░░░░░░█
// █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▄█▀░▄▄░▄█▀░░▄▀░░░░▄█░░░░░░░░░░░░░▀█░░█▄░▀█▄░░░░░░░░░░░░░░░░░░░░░░░░█
// █░░░░░░░░░░░░░▄▄▄▄▄▄▄░░░░░░░░░░█▀▄█▀▀░█▀░░▄█▀░░░░█▀░░░░░░░░░░░░░░░█░░░█░░░░▀█░░░░░░░░░░░░░░░░░░░░░░█
// █░░░░░░░░░░░░▀█▄▄▄▄▄█▀█▄░░░░░▄▀▄█▀░░░█░░░▄█░░░░░░█░░░░░░░░░░░░░░░░█░░░█░░░░░░█▄░░░░░░░░░░░░░░░░░░░░█
// █░░░░░░░░░░░▄▄▀▀░░░░▀▀░▀█░░▄███▀░░░░░█░░░█░░░░░░░█░░░░░░░░▄░░░░░░░█░░░█░░░░░█░▀█▄░░░░░░░░░░░░░░░░░░█
// █░░░░░░░░░▄█▀▄█▀░░▄█░░░░▀█▄▀▄█░░▄░░░░▀░░░░░░░░░░▄█░░░░░░░░█░░░░░░░█░░░█░░░░░█░░░█▄░░░░░░░░░░░░░░░░░█
// █░░░░░░░░██▄██▀░░█▀░░▄▄▄▀▄██▀░░░█░░▄░░░░░░░░░░░░█▀░░░░░░░█▀░░░░░░██░░░█░░░░░█░░░░█▀▄░░░░░░░░░░░░░░░█
// █░░░░░░░░▀░░█▀░▄██▄▄█▀░░▄██░░░░░█░░█░░░░░▄░░░░░░▀█░░░░░░░█░░░░░░▄█░░░░█░░░░░█░░░░░░▀█▄░░░░░░░░░░░░░█
// █░░░░░░░░░░░█▄█▀░█▀░░░░▄█▀░░░░░░█░░█░░░░░█░░░░░░░█░░░░░░░█░░░░░▄█░░░░▄█░░░░░█░░░░░░░░▀▄▄▄█▀▀█▄░░░░░█
// █░░░░░░░░░░░▀▄▄██▀▄▄▄▀▀▀█░░░░░░░█░░█░░░░░█░▄▄▄▄▄▄▀▀▀▀▀▀▀▀█▄▄▄▄▄█▄▄░░░█░░░░░░█░░░▄░░░░░█░░▄▄▄░█░░░░░█
// █░░░░░░░░░░▄█▀▄█░▀█░░░░█▀░░░░░░░█░░█░█░░░███▄█▀██████▀▀▀▀▀░░░░░░░▀▀█▄█░░░░░▄█░░░█░░░░░█░░░▀████░░░░█
// █░░░░░░░░░█▀░█▀░░░█░░░░█░░░░░░░░█░░█░█▄░█▀░░░░░▀███▄▀▀░░░░░░░░░▀▀▀█▄██▄▄▄░░█░░░░█░░░░░█░░░░░▀▀█▄░░░█
// █░░░░░░░░▄█▄░░░▄▄█░░░░░█░░░░░░░░█░░█▀▀▀▀░░░░░░░██▄██░░░░░░░░░░░░█▀███▀▀▄█▀▀▀█▄▄░█░░░░░▀█░░██▄░░█▄░░█
// █░░░░░░░█▀▄██▀██░░░░░░░█░░░░░░░░█▄░▀█░░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄███░░░▀█▄░░░▀▀█░░░█░░█░░▀█▀▀█▄█░░█
// █░░░░░░░█░▀░░▄█░░░░░░░░█░░░░░░░░░█▄░▀█▄░░░▄▄▄▄▄▄▄▄▄▄░░░░░█▀░░░░░▀▀▀▀░░░░░░▀█░░░▄█░░▄▀░░█░▄▄█░░░▀▀░░█
// █░░░░░░▄▀░░▄█▀░░░░░░░█▀█░░░░░▄░░░░█▄░░▀█▀▀▀░░░░░░░░░░░░░░░░░░░░▀█▄▄▄░░░░░░░░█▄░█░░▄█░░░██▀░░░░░░░░░█
// █░░░░░██░▄█▀█░░░░░░░░█░▀▄░░░░░█░░░▀██▄▄▀█▄░░░░░░░░░░░░░▀▀░░░░░░░░░░▀▀█▄▄░░░░░██▀░▄█░░░███░░░░░░░░░░█
// █░░░░▄█▀█▀░▄▀░░░░░░░░█░░█░░░░░░█▄░░▀▄░░▀▀██░░░░░░░▄▄▄▄▄▄▄▄▄░░░░░░░░░░░░▀▀▄▄▄▄█▄▄▀▀░░░░█░▀▄░░░░░░░░░█
// █░░░░█░░░▄█▀░░░░░░░░░█▄░█▄░░░░░░▀█▄░▀█░░░░░▄▀▀▄░█▀▀░░░░░░░▀▀▀▀█▄░░░░░░░░░░░░█▀█░░░░░░░█░░█░░░░░░░░░█
// █░░░░▀█░▄▀█░░░░░░░░░░░▀█▄██░░░░░░░░████▄░░█▀░░░▀░░░░░░░░░░░░░░░▀▀▄░░░░░░░░░░░░█░░░░░░█▀░░█▄░░░░░░░░█
// █░░░░░█▄▀░█░░░░░░░░░░░░█░░░░░░█▀█▄░█▄░░▀▀░█░░░░░░░░░░░░░░░░░░░░░░█░░░░░░░░░░░░██▀█░░░▀▄░░░█░░░░░░░░█
// █░░░░█▀░░░█▄▄░░░░░░░░░░█░░░██▄█░░▀█▄▀▄░░░░█▄░░░░░░░░░░░░░░░░░░░░░█░░░░░░░░░▄▄▀░▄█▀▀▀█░▀█▄░█░░░░░░░░█
// █░░░░▀▄▄▄▄█▄▀█░░░░░░▄▄▄██▄▄█▄██▄░░██▄██░░░░█░░░░░░░░░░░░░░░░░░░░░█░░░░░░░░░█░░▄▀░░█▀█░░░░░█░░░░░░░░█
// █░░░░░▀█▀░░░▄█▄█▀▀▀▀▀░░░░░░░█░██░░█░█▄▄▀▀▀▀▀▀▀▀▄▄▄▄▄▄░░░░░░░░░░░█▀░░░██▄░░█▀▄█░░▄█░░█░░░▄▄█░░░░░░░░█
// █░░░░░░█▄░▄█▀░░░░░░░░░░░░░░░░█░█▄░█░█░▀█░░░░░░░░░░░░█▀▀▀▀▀▀▄▄▄▄██░░░█▀░█░█▀█▀░▄▄▀░▄█▀░░▀▀░█░░░░░░░░█
// █░░░░░░░█▀▀░░░░░░░░░░░░░░░░░░█▄░█░█░█░░█░░░░░░░░░░░░█░░░░▄▄▄░░█░▀▀▀▀█░░██▀░░▄█▀░▄█▀░▀█░░░░█░░░░░░░░█
// █░░░░░░█░░░░░░▄▄████████▄░░░░░█░░░█▄█░░█░░░░░░░░░░░░█░░░░███░░█░░░░░█░▄█▀░░░░░▄██▄░░░▀▀░░█░░░░░░░░░█
// █░░░░░░█░░░░░█████████████▄░░░▀█░░░░▀░░▀▄░░░░░░░░░░░█░░░░░░░░░█░░░░░█▄▀░░░░▄░░█░░░▀█▄▄█▀▀░░░░░░░░░░█
// █░░░░░░█▄░░░░▀███████▀▀▀▀▀█▄░░░▀▄░░░░░░░█░░░░░░░░░░░█░░░░░░░░░█░░░░█▀▀░░▄█▀░░█░░░░░██░░░░░░░░░░░░░░█
// █░░░░░░░█░░░░░░███▀░░░░░░░░▀▄░░░▀█░░░░░░█░░░░░░░░░░░█░░░░░░░░░█░░░█▀░░░█▀░░░█▀░░░░▄█░░░░░░░░░░░░░░░█
// █░░░░░░░▀▄░░░░░██░░░░░░░░░░░░▀░░░█░░░░░░▀█░░▄▄░░░░░░█░░░░░░░░▄█░░░█░░▄█░░░░░█░░░░░█░░░░░░░░░░░░░░░░█
// █░░░░░░░░▀█░░▄█▀░░░░░░░░░░░░░░░░▄█░░░░░░░▀█░▀▀▀▀▀█▄▄█▄▄▄▄▄▄▄▄█▄▄▄█▀░░█░░░░░▄█░░░░░█░░░░░░░░░░░░░░░░█
// █░░░░░░░░░█░▄▀░░░░░░░░░░░░░░░▄█▀▀▀█▄░░░░░░▀█░░░░░░▀▀██████████████░░█▀░░░░░█░░░░░█▀░░░░░░░░░░░░░░░░█
// █░░░░░░░░░██▀░░░░░░░░░░░░░░▄██░░░░░█▄░░░░░░█░░░░░░░░█░░░░░▀▀▀▀▀█▀█░░█░░░░░░█░░░░░█░░░░░░░░░░░░░░░░░█
// █░░░░░░░░░██▀░░░░░░░░░░░░░░██░░░░░░░█▄░░░░░█░░░░░░░░█░░░░░░░░░░█░▀█▄█░░░░░░███▄░░▀▄░░░░░░░░░░░░░░░░█
// █░░░░░░░░░██▄▄░░░░░░░░░░░░▄██░░░░░░░░▀█▄░▄█▀░░░░░░░░█░░░░░░░░░▄█░░█▄░░░░░░░██░▀█▄░▀█░░░░░░░░░░░░░░░█
// █░░░░░░░▄██▀░▀█▄░░░░░░░░░░██▀░░░░░░░░░░▀▀█░░░░░░░░░▄▀░░░░░░░░▄█░░░██▄░░░░░▄██░░░█▄░▀█░░░░░░░░░░░░░░█
// █░░░░░░░██▀░░░░▀▀▄▄░░░░░░██▀█▄░░░░░░░░░░░▀▀▄▄▄▄▄▄▄▄█▄▄▄▄▄▄▄░░█░░░▄▀░█░░░░░▀░█░░░░▀▄░▀█░░░░░░░░░░░░░█
// █░░░░░░██▀░░░░░░░░▀█▄░░▄██▀░░░▀▄░░░░░░░░░░░░▀██████████████████▄█▀░░▀█░░░░░░█░░░░░█▄░▀▄░░░░░░░░░░░░█
// █░░░░░░██░░░░░░░░░░░▀█▄██▀░░░░░░█▄░░░░░░░░░░░▀███████████████████░░░░▀█░░░░█▀░░░░░░█░░█░░░░░░░░░░░░█
// █░░░░░██░░░░░░░░░░░░░░██▀░░░░░░░░▀█▄░░░░░░░░░░▀█████████████████▀░░░░░▀█░░▄█░░░░░░░█▄░░█░░░░░░░░░░░█
// █░░░░▄█░░░░░░░░░░░░░▄██▀░░░░░░░░░░░▀█▄░░░░░░░░░▀████████████████░░░░░░░▀▄█▀░░░░░░░█▀█░░▀▄░░░░░░░░░░█
// █░░░░█░░░░░░░░░░░░▄▄██▀░░░░░░░░░░░░░░█▄░░░░░░░░░░██▀▀▀▀▀▀██▀▀▀█▀░░░░░░░░█▀░░░░░░░▄█░█▄░░▀█▄░░░░░░░░█
// █░░░░█░░░░░░░░░░░███▀░░░░░░░░░░░░░░░░░█▄░░░░░░░░░░█▄░░░░░█░░░░█░░░░░░░▄█▀░░░░░░░▄█░░░█░░░░▀▄░░░░░░░█
// █▄▄▄▄█▄▄▄▄▄▄▄▄▄▄██▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄█▄▄▄▄▄█▄▄▄▄█▄▄▄▄▄▄▄█▄▄▄▄▄▄▄▄▄█▄▄▄▄█▄▄▄▄▄██▄▄▄▄▄▄█
#include<bits/stdc++.h>
using namespace std;
long long l,r;
int n;
long long a[1000001];
bool nt(long long x){
if(x<2)return 0;
for(long long i=2;i*i<=x;i++){
if(x%i==0)return 0;
}
return 1;
}
void process(){
n=0;
for(long long i=l;i<=r;i++){
if(nt(i))a[++n]=i;
}
long long ans=0;
long long now=1;
for(int i=1;i<n;i++){
while(now<a[i])now*=10;
for(long long j=1;1;j++){
if((j*now+a[i])%a[i+1]==0){
ans+=(j*now+a[i])%1000000007;
break;
}
}
}
cout<<ans%1000000007;
}
void init(){
cin>>l>>r;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define NAME "nazunasdish"
if(fopen(NAME".inp","r")){
freopen(NAME".inp","r",stdin);
freopen(NAME".ans","w",stdout);
}
clock_t beg=clock();
init();
process();
cerr<<double(clock()-beg)/CLOCKS_PER_SEC;
}