#include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll MOD = 1000000007; template T pow(T a, ll n) { T ans = 1; T tmp = a; for (int i = 0; i <= 60; i++) { ll m = (ll)1 << i; if (m & n) { ans *= tmp; ans %= MOD; } tmp *= tmp; tmp %= MOD; } return ans; } ll inv(ll n){ if(n == 1) return 1; else return MOD-inv(MOD%n)*(MOD/n)%MOD; } int N; ll L[100000], R[100000], D[100000]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; cin >> N; for(int i = 0; i < N; i++) cin >> L[i]; for(int i = 0; i < N; i++) cin >> R[i]; for(int i = 0; i < N; i++) cin >> D[i]; ll ans = 1; int prev = 0; for(int i = 0; i < N; i++){ if(D[i] == 0){ cout << 0 << endl; }else{ ll r = pow(10, R[i]); ll l = pow(10, L[i]); ll d = (r-l+MOD)%MOD; ll tmp = (d*inv(9))%MOD; if(D[i] == prev) tmp++; ans *= tmp; ans %= MOD; } prev = D[i]; } cout << ans << endl; }