#include using namespace std; typedef long long ll; #define P pair #define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I) #define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I) #define TO(x,t,f) ((x)?(t):(f)) #define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9 #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v x is sorted #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v x is sorted #define NUM(x,v) (POSU(x,v)-POSL(x,v)) //x is sorted #define REV(x) (reverse(x.begin(),x.end())) //reverse ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);} ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*b);} #define NEXTP(x) next_permutation(x.begin(),x.end()) const ll INF=ll(1e16)+ll(7); const ll MOD=1000000007LL; #define out(a) cout< f,fr; ll MOD_; public: //a^(p-1) = 1 (mod p)(p->Prime numbers) //a^(p-2) = a^(-1) ll calc(ll a,ll b,ll p){//a^(b) mod p if(b==0)return 1; ll y = calc(a,b/2,p);y=(y*y)%p; if(b & 1) y = (y * a) % p; return y; } void init(ll n,ll mod){//input max_n MOD_ = mod; f.resize(n+1); fr.resize(n+1); f[0]=fr[0]=1; for(ll i=1;i=0;i--){ fr[i] = fr[i+1] * (i+1) % mod; } } ll nCr(ll n,ll r){ if(n<0||r<0||n> T; FOR(t,0,T){ modll N; vector A(3),B(3); cin >> N.v; N.m = MOD; FOR(i,0,3) cin >> A[i].v >> B[i].v; FOR(i,0,3) A[i].m = B[i].m = MOD; modll only0 = (A[0] / B[0]) ^ N; modll only1 = (A[1] / B[1]) ^ N; modll only2 = (A[2] / B[2]) ^ N; modll not0 = (modll(1,MOD) - (A[0] / B[0])) ^ N; modll not1 = (modll(1,MOD) - (A[1] / B[1])) ^ N; modll not2 = (modll(1,MOD) - (A[2] / B[2])) ^ N; modll ans = not0+not1+not2-only1-only1-only0-only0-only2-only2;; ans = modll(1,MOD) - ans; cout << ans.v << endl; } }