Yaroslav thinks that two strings s and w, consisting of digits and having length n are non-comparable if there are two numbers, i and j (1 ≤ i, j ≤ n), such that s_{i} > w_{i} and s_{j} < w_{j}. Here sign s_{i} represents the i-th digit of string s, similarly, w_{j} represents the j-th digit of string w.

A string's template is a string that consists of digits and question marks ("?").

Yaroslav has two string templates, each of them has length n. Yaroslav wants to count the number of ways to replace all question marks by some integers in both templates, so as to make the resulting strings incomparable. Note that the obtained strings can contain leading zeroes and that distinct question marks can be replaced by distinct or the same integers.

Help Yaroslav, calculate the remainder after dividing the described number of ways by 1000000007 (10^9 + 7).


-----Input-----

The first line contains integer n (1 ≤ n ≤ 10^5) — the length of both templates. The second line contains the first template — a string that consists of digits and characters "?". The string's length equals n. The third line contains the second template in the same format.


-----Output-----

In a single line print the remainder after dividing the answer to the problem by number 1000000007 (10^9 + 7).


-----Examples-----
Input
2
90
09

Output
1

Input
2
11
55

Output
0

Input
5
?????
?????

Output
993531194



-----Note-----

The first test contains no question marks and both strings are incomparable, so the answer is 1.

The second test has no question marks, but the given strings are comparable, so the answer is 0.

Difficulty: interview

Starter code:

Solutions:
n, s = int(input()), 0
s1, s2 = str(input()), str(input())
b1, b2 = False, False
for i in range(n):
  if s1[i] != '?' and s2[i] != '?':
    if ord(s1[i]) < ord(s2[i]):
      b1 = True
    if ord(s1[i]) > ord(s2[i]):
      b2 = True
  s += (s1[i] == '?') + (s2[i] == '?')
ans1, ans2, ans3 = 1, 1, 1
for i in range(n):
  if s1[i] == '?' and s2[i] == '?':
    ans1 = (ans1 * 55) % 1000000007
    ans2 = (ans2 * 55) % 1000000007
    ans3 = (ans3 * 10) % 1000000007
  elif s1[i] == '?':
    ans1 = (ans1 * (ord(s2[i]) - ord('0') + 1)) % 1000000007
    ans2 = (ans2 * (10 - ord(s2[i]) + ord('0'))) % 1000000007
  elif s2[i] == '?':
    ans1 = (ans1 * (10 - ord(s1[i]) + ord('0'))) % 1000000007
    ans2 = (ans2 * (ord(s1[i]) - ord('0') + 1)) % 1000000007
print((10 ** s - (not b2) * ans1 - (not b1) * ans2 + (not b1 and not b2) * ans3) % 1000000007)

from functools import reduce
n = int(input())
s1, s2 = str(input()), str(input())
b1 = reduce(lambda x, y: x or y, [s1[i] != '?' and s2[i] != '?' and ord(s1[i]) < ord(s2[i]) for i in range(n)], False)
b2 = reduce(lambda x, y: x or y, [s1[i] != '?' and s2[i] != '?' and ord(s1[i]) > ord(s2[i]) for i in range(n)], False)
s = sum([(s1[i] == '?') + (s2[i] == '?') for i in range(n)])
ans1 = reduce(lambda x, y: (x * y) % 1000000007, [55 if s1[i] == '?' and s2[i] == '?' else (ord(s2[i]) - ord('0') + 1) if s1[i] == '?' else (10 - ord(s1[i]) + ord('0')) if s2[i] == '?' else 1 for i in range(n)], 1)
ans2 = reduce(lambda x, y: (x * y) % 1000000007, [55 if s1[i] == '?' and s2[i] == '?' else (10 - ord(s2[i]) + ord('0')) if s1[i] == '?' else (ord(s1[i]) - ord('0')) + 1 if s2[i] == '?' else 1 for i in range(n)], 1)
ans3 = reduce(lambda x, y: (x * y) % 1000000007, [10 if s1[i] == '?' and s2[i] == '?' else 1 for i in range(n)], 1)
print((10 ** s - (not b2) * ans1 - (not b1) * ans2 + (not b1 and not b2) * ans3) % 1000000007)

from functools import reduce

n = int(input())

s1, s2 = str(input()), str(input())

b1 = reduce(lambda x, y: x or y, [s1[i] != '?' and s2[i] != '?' and ord(s1[i]) < ord(s2[i]) for i in range(n)], False)

b2 = reduce(lambda x, y: x or y, [s1[i] != '?' and s2[i] != '?' and ord(s1[i]) > ord(s2[i]) for i in range(n)], False)

s = sum([(s1[i] == '?') + (s2[i] == '?') for i in range(n)])

ans1 = reduce(lambda x, y: (x * y) % 1000000007, [55 if s1[i] == '?' and s2[i] == '?' else (ord(s2[i]) - ord('0') + 1) if s1[i] == '?' else (10 - ord(s1[i]) + ord('0')) if s2[i] == '?' else 1 for i in range(n)], 1)

ans2 = reduce(lambda x, y: (x * y) % 1000000007, [55 if s1[i] == '?' and s2[i] == '?' else (10 - ord(s2[i]) + ord('0')) if s1[i] == '?' else (ord(s1[i]) - ord('0')) + 1 if s2[i] == '?' else 1 for i in range(n)], 1)

ans3 = reduce(lambda x, y: (x * y) % 1000000007, [10 if s1[i] == '?' and s2[i] == '?' else 1 for i in range(n)], 1)

print((10 ** s - (not b2) * ans1 - (not b1) * ans2 + (not b1 and not b2) * ans3) % 1000000007)



# Made By Mostafa_Khaled


n = int(input())
a = input()
b = input()
mod = int(1e9+7)
x, y, z = 1, 1, 1
for i in range(n):
    if a[i] == '?' and b[i] == '?':
        x = (x * 55) % mod
        y = (y * 55) % mod
        z = (z * 10) % mod
    elif a[i] == '?':
        x = (x * (10 - int(b[i]))) % mod
        y = (y * (int(b[i]) + 1)) % mod
    elif b[i] == '?':
        x = (x * (int(a[i]) + 1)) % mod
        y = (y * (10 - int(a[i]))) % mod
    else:
        if int(a[i]) < int(b[i]): x = 0
        if int(a[i]) > int(b[i]): y = 0
        if a[i] != b[i]: z = 0
res = pow(10, a.count('?') + b.count('?'), mod)
print((res - x - y + z) % mod)


n = int(input())
C = 10**9+7
a = input()
s = input()
d = [[0, 0, 0, 1]]
for q in range(n):
    d.append(d[-1][::])
    if a[q] != '?' and s[q] != '?':
        if int(a[q]) < int(s[q]):
            d[-1][1] = d[-1][3] = 0
            d[-1][0] += d[-2][3]
            d[-1][2] += d[-2][1]
        elif int(a[q]) > int(s[q]):
            d[-1][0] = d[-1][3] = 0
            d[-1][1] += d[-2][3]
            d[-1][2] += d[-2][0]
    elif s[q] != '?':
        d[-1][2] *= 10
        d[-1][0] += d[-2][3]
        d[-1][1] += d[-2][3]
        d[-1][0] *= int(s[q])+1
        d[-1][1] *= 10-int(s[q])
        d[-1][0] -= d[-2][3]
        d[-1][1] -= d[-2][3]
        d[-1][2] += d[-2][0]*(9-int(s[q]))+d[-2][1]*int(s[q])
    elif a[q] != '?':
        d[-1][2] *= 10
        d[-1][0] += d[-2][3]
        d[-1][1] += d[-2][3]
        d[-1][1] *= int(a[q]) + 1
        d[-1][0] *= 10 - int(a[q])
        d[-1][0] -= d[-2][3]
        d[-1][1] -= d[-2][3]
        d[-1][2] += d[-2][1] * (9 - int(a[q])) + d[-2][0] * int(a[q])
    else:
        d[-1][3] *= 10
        d[-1][2] *= 100
        d[-1][0] *= 55
        d[-1][1] *= 55
        d[-1][0] += d[-2][3]*45
        d[-1][1] += d[-2][3]*45
        d[-1][2] += d[-2][0]*45+d[-2][1]*45
    d[-1][0] %= C
    d[-1][1] %= C
    d[-1][2] %= C
    d[-1][3] %= C
print(d[-1][2])


3

def build(n, s, t):
    ans = 1
    for i in range(n):
        if s[i] == '?' and t[i] == '?':
            ans = (55 * ans) % (10 ** 9 + 7)
        elif s[i] == '?':
            ans = ((ord(t[i]) - ord('0') + 1) * ans) % (10 ** 9 + 7)
        elif t[i] == '?':
            ans = ((ord('9') - ord(s[i]) + 1) * ans) % (10 ** 9 + 7)
    return ans


n = int(input())
s = input()
t = input()

sltt = True
tlts = True
qm = 0
cqm = 0
for i in range(n):
    if t[i] == '?':
        qm += 1
    if s[i] == '?':
        qm += 1
    if t[i] == '?' and s[i] == '?':
        cqm += 1
    if t[i] == '?' or s[i] == '?':
        continue
    if ord(s[i]) < ord(t[i]):
        tlts = False
    if ord(t[i]) < ord(s[i]):
        sltt = False


if not sltt and not tlts:
    print(pow(10, qm, 10 ** 9 + 7))
elif sltt and tlts:
    print((pow(10, qm, 10 ** 9 + 7) - build(n, s, t) - build(n, t, s) + pow(10, cqm, 10 ** 9 + 7)) % (10 ** 9 + 7))
elif sltt:
    print((pow(10, qm, 10 ** 9 + 7) - build(n, s, t)) % (10 ** 9 + 7))
else:
    print((pow(10, qm, 10 ** 9 + 7) - build(n, t, s)) % (10 ** 9 + 7))


mod = 1000000007
n = int(input())
s1 = input()
s2 = input()
ans = 1
tc = 1
for i in range(n):
	if s1[i] == '?':
		ans *= 10
		ans %= mod
	if s2[i] == '?':
		ans *= 10
		ans %= mod
for i in range(n):
	if s1[i] != '?' and s2[i] != '?' and s1[i] > s2[i]:
		break
	if s1[i] == '?' and s2[i] == '?':
		tc *= 55 
		tc %= mod
	if s1[i] == '?' and s2[i] != '?':
		tc = tc * (int(s2[i]) + 1)
		tc %= mod
	if s1[i] != '?' and s2[i] == '?':
		tc = tc * (10 - int(s1[i]))
		tc %= mod
	if i == n - 1:
		ans -= tc
		ans = (ans + mod) % mod
tc = 1
for i in range(n):
	if s1[i] != '?' and s2[i] != '?' and s2[i] > s1[i]:
		break;
	if s1[i] == '?' and s2[i] == '?':
		tc *= 55
		tc %= mod
	if s1[i] != '?' and s2[i] == '?':
		tc = tc * (int(s1[i]) + 1)
		tc %= mod
	if s1[i] == '?' and s2[i] != '?':
		tc = tc * (10 - int(s2[i]))
		tc %= mod
	if i == n - 1:
		ans -= tc 
		ans = (ans + mod) % mod
tc = 1
for i in range(n):
	if s1[i] != '?' and s2[i] != '?' and s1[i] != s2[i]:
		break
	if s1[i] == '?' and s2[i] == '?':
		tc *= 10
		tc %= mod
	if i == n - 1:
		ans += tc
		ans = (ans + mod) % mod
print(ans)



import sys
mod = 1000000007
n = int(input())
s1 = input()
s2 = input()
flag1 = 0
flag2 = 0
for i in range(n):
	if s1[i] != "?" and s2[i] != "?" and s1[i] > s2[i]:
		flag1 = 1
	if s1[i] != "?" and s2[i] != "?" and s1[i] < s2[i]:
		flag2 = 1
if flag1 and flag2:
	ans = 1
	for i in range(n):
		if s1[i] == "?":
			ans *= 10
			ans %= mod
	for i in range(n):
		if s2[i] == "?":
			ans *= 10
			ans %= mod
	print(ans % mod)
	return
if not(flag1) and not(flag2):
	ans1 = 1
	ans2 = 1
	x = 0
	al = 1
	for i in range(n):
		if s1[i] == "?" and s2[i] == "?":
			x += 1
	for i in range(n):
		if s1[i] == "?":
			al *= 10
			al %= mod
	for i in range(n):
		if s2[i] == "?":
			al *= 10
			al %= mod
	for i in range(n):
		if s1[i] == "?" and s2[i] == "?":
			ans1 *= 55
			ans1 %= mod
		elif s1[i] == "?":
			ans1 *= 10 - int(s2[i])
			ans1 %= mod
		elif s2[i] == "?":
			ans1 *= int(s1[i]) + 1
			ans1 %= mod
	s1, s2 = s2, s1
	for i in range(n):
		if s1[i] == "?" and s2[i] == "?":
			ans2 *= 55
			ans2 %= mod
		elif s1[i] == "?":
			ans2 *= 10 - int(s2[i])
			ans2 %= mod
		elif s2[i] == "?":
			ans2 *= int(s1[i]) + 1
			ans2 %= mod
	y = 1
	for i in range(x):
		y *= 10
		y %= mod
	print((al - (ans1 + ans2 - y)) % mod)
	return
if flag2:
	s1, s2 = s2, s1
ans = 1
al = 1
for i in range(n):
	if s1[i] == "?":
		al *= 10
		al %= mod
for i in range(n):
	if s2[i] == "?":
		al *= 10
		al %= mod
for i in range(n):
	if s1[i] == "?" and s2[i] == "?":
		ans *= 55
		ans %= mod
	elif s1[i] == "?":
		ans *= 10 - int(s2[i])
		ans %= mod
	elif s2[i] == "?":
		ans *= int(s1[i]) + 1
		ans %= mod
print((al - ans) % mod)











import sys
mod = 1000000007
n = int(input())
s1 = input()
s2 = input()
flag1 = 0
flag2 = 0
for i in range(n):
	if s1[i] != "?" and s2[i] != "?" and s1[i] > s2[i]:
		flag1 = 1
	if s1[i] != "?" and s2[i] != "?" and s1[i] < s2[i]:
		flag2 = 1
if flag1 and flag2:
	ans = 1
	for i in range(n):
		if s1[i] == "?":
			ans *= 10
			ans %= mod
	for i in range(n):
		if s2[i] == "?":
			ans *= 10
			ans %= mod
	print(ans % mod)
	return
if not(flag1) and not(flag2):
	ans1 = 1
	ans2 = 1
	x = 0
	al = 1
	for i in range(n):
		if s1[i] == "?" and s2[i] == "?":
			x += 1
	for i in range(n):
		if s1[i] == "?":
			al *= 10
			al %= mod
	for i in range(n):
		if s2[i] == "?":
			al *= 10
			al %= mod
	for i in range(n):
		if s1[i] == "?" and s2[i] == "?":
			ans1 *= 55
			ans1 %= mod
		elif s1[i] == "?":
			ans1 *= 10 - int(s2[i])
			ans1 %= mod
		elif s2[i] == "?":
			ans1 *= int(s1[i]) + 1
			ans1 %= mod
	s1, s2 = s2, s1
	for i in range(n):
		if s1[i] == "?" and s2[i] == "?":
			ans2 *= 55
			ans2 %= mod
		elif s1[i] == "?":
			ans2 *= 10 - int(s2[i])
			ans2 %= mod
		elif s2[i] == "?":
			ans2 *= int(s1[i]) + 1
			ans2 %= mod
	y = 1
	for i in range(x):
		y *= 10
		y %= mod
	print((al - (ans1 + ans2 - y)) % mod)
	return
if flag2:
	s1, s2 = s2, s1
ans = 1
al = 1
for i in range(n):
	if s1[i] == "?":
		al *= 10
		al %= mod
for i in range(n):
	if s2[i] == "?":
		al *= 10
		al %= mod
for i in range(n):
	if s1[i] == "?" and s2[i] == "?":
		ans *= 55
		ans %= mod
	elif s1[i] == "?":
		ans *= 10 - int(s2[i])
		ans %= mod
	elif s2[i] == "?":
		ans *= int(s1[i]) + 1
		ans %= mod
print((al - ans) % mod)











from sys import stdin
input = stdin.readline
n = int(input())
s1, s2 =  input(), input()
mod = 1000000007
flag1 = flag2 = flag3 = ans1 = ans2 = ans3 = cnt = 1
for i in range(n):
    if s1[i] == '?' and s2[i] == '?':
        ans1 *= 55
        ans2 *= 55
        ans3 *= 10
        cnt *= 100
    elif s1[i] == '?':
        ans1 *= 10 - int(s2[i])
        ans2 *= int(s2[i]) + 1
        cnt *= 10
    elif s2[i] == '?':
        ans2 *= 10 - int(s1[i])
        ans1 *= int(s1[i]) + 1
        cnt *= 10
    elif s1[i] < s2[i]:
        flag1 = flag3 = 0
    elif s1[i] > s2[i]:
        flag2 = flag3 = 0
    cnt %= mod
    ans1 %= mod
    ans2 %= mod
    ans3 %= mod
print(cnt - (ans1 * flag1 + ans2 * flag2 - ans3 * flag3) % mod)