#include using namespace std; #define int long long templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b 0){ if(m & 1) ans = (ans * n) % MOD; n = (n * n) % MOD; m >>= 1; } return ans; } int get(int i){ int a = (MOD + pow_mod(10, i)-1)%MOD; return a*pow_mod(9, MOD-2) % MOD; } signed main(){ int n; 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+1]; d[0] = 0; int dp[100010] = {}; dp[0] = 1; for(int x = 0;x < n;x++){ for(int i = 0;i < 10;i++){ int num = d[x] + i % 9; if(num == 0 && (d[x] != 0 || i != 0)){ num = 9; } if(num == d[x+1]){ if(i == 0){ dp[x+1] += dp[x]; dp[x+1] %= MOD; }else{ int num = (MOD+get(r[x])-get(l[x]))%MOD; dp[x+1] += dp[x] * num %MOD; dp[x+1] %= MOD; } } } } cout << dp[n] << endl; return 0; }