#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int P = 1000000009;
void Add(int &a,int b){
a += b;
if(a >= P) a -= P;
}
int n;
int f[5005][1050][2],sum[5005][1050][2];
const int M = (1 << 10) - 1;
int calc(string s){
memset(f,0,sizeof(f));
memset(sum,0,sizeof(sum));
f[0][0][1] = 1;
for(int i = 1;i <= n;i ++){
for(int S = 0;S < (1 << 10);S ++){
for(int id = 0;id < 2;id ++){
for(int cur = 0;cur <= (id ? s[i] - '0' : 9);cur ++){
int val = (i == 1 ? 10 - cur : 10);
if(((1 << (cur + 1)) - 1) & S) val = 0;
if(cur == 0) val = 0;
Add(f[i][(S | (1 << cur)) & (M << cur)][id && cur == s[i] - '0'],f[i - 1][S][id]);
Add(sum[i][(S | (1 << cur)) & (M << cur)][id && cur == s[i] - '0'],(1ll * f[i - 1][S][id] * val % P + sum[i - 1][S][id]) % P);
}
}
}
}
int ret = 0;
for(int S = 0;S < (1 << 10);S ++){
for(int id = 0;id < 2;id ++){
Add(ret,sum[n][S][id]);
}
}
return ret;
}
void solve(){
cin >> n;
string s,t;
cin >> s >> t;
s = ' ' + s; t = ' ' + t;
int fl = 1;
for(int i = 1;i <= n;i ++){
if(s[i] > '0') fl = 0;
}
if(fl) cout << calc(t) << '\n';
else{
s[n] --;
for(int i = n;i >= 1;i --){
if(s[i] < '0'){
s[i] += 10;
s[i - 1] --;
}
}
cout << calc(t) - calc(s) << '\n';
}
}
int main(){
ios::sync_with_stdio(false);
solve();
return 0;
}
\cecececece