#include #include #include using namespace std; using ll = long long; #include using mint = atcoder::modint1000000007; ll gcd(ll a,ll b){ if(b) return gcd(b,a%b); return a; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin>>n; vector c(10,0); for(int i = 1;i<=9;i++) cin>>c[i]; { int cnt = 0; for(int i = 1;i<=9;i++) if(c[i]!=0) cnt++; if(cnt==1){ mint ans = mint(10).pow(n); ans--; ans /= 9; for(int i = 1;i<=9;i++) { if(c[i]!=0) ans *= i; } cout<=8){ ans = 1; { bool fn = true; for(int i = 1;i<=9;i++) if(i%2==1&&c[i]!=0) fn = false; if(fn) ans *= 2; } ll sum = 0; for(int i = 1;i<=9;i++) sum += i * c[i]; if(sum%27==0) ans *= 27; else if(sum%9==0) ans *= 9; else if(sum%3==0) ans *= 3; cout< all; for(int i = 1;i<=9;i++) for(int j = 0;j