#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define nl "\n"
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vvl vector<vl>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctzll(x)
#define all(a) (a).begin(), (a).end()
#define allr(a) (a).rbegin(), (a).rend()
#define ps(num, pre) fixed << setprecision(pre) << num
#define py cout << "Yes" << nl;
#define pn cout << "No" << nl;
ll mod = 1e9 + 7;
void ans1(bool x)
{
if (x)
cout << "Yes" << nl;
else
cout << "No" << nl;
}
ll power(ll a, ll b, ll m)
{
a %= m;
if (a == 0)
return 0;
ll res = 1;
while (b > 0)
{
if (b & 1)
res = (res * a) % m;
a = (a * a) % m;
b >>= 1;
}
return res;
}
///////////////////////////////////////Working Area///////////////////////////////////////
void solve()
{
// Check Constrains. Do you need to take long long insteed of int?
// Go and check Bold statements
int n;
cin >> n;
string a, b;
cin >> a >> b;
ll equal = 1, less = 1, greater = 1;
ll cnt = 0;
for (int i = 0; i < n; i++)
{
if (a[i] == '?' && b[i] == '?')
{
cnt += 2;
equal = (equal * 10) % mod;
greater = (greater * 55) % mod;
less = (less * 55) % mod;
}
else if (a[i] == '?')
{
cnt++;
int y = b[i] - '0';
greater = (greater * (10 - y)) % mod;
less = (less * (y + 1)) % mod;
}
else if (b[i] == '?')
{
cnt++;
int x = a[i] - '0';
greater = (greater * (x + 1)) % mod;
less = (less * (10 - x)) % mod;
}
else
{
int x = a[i] - '0', y = b[i] - '0';
if (x > y)
{
equal = 0;
less = 0;
}
else if (x < y)
{
equal = 0;
greater = 0;
}
}
}
cout << (power(10, cnt, mod) + equal - less - greater + 3 * mod) % mod << endl;
}
////////////////////////////////////////////////////////////////////////////////////////
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// int t;
// cin >> t;
// for (int i = 0; i < t; i++)
solve();
return 0;
}
732B - Cormen --- The Best Friend Of a Man | 1369A - FashionabLee |
1474B - Different Divisors | 1632B - Roof Construction |
388A - Fox and Box Accumulation | 451A - Game With Sticks |
768A - Oath of the Night's Watch | 156C - Cipher |
545D - Queue | 459B - Pashmak and Flowers |
1538A - Stone Game | 1454C - Sequence Transformation |
165B - Burning Midnight Oil | 17A - Noldbach problem |
1350A - Orac and Factors | 1373A - Donut Shops |
26A - Almost Prime | 1656E - Equal Tree Sums |
1656B - Subtract Operation | 1656A - Good Pairs |
1367A - Short Substrings | 87A - Trains |
664A - Complicated GCD | 1635D - Infinite Set |
1462A - Favorite Sequence | 1445B - Elimination |
1656C - Make Equal With Mod | 567A - Lineland Mail |
1553A - Digits Sum | 1359B - New Theatre Square |