#include #include using namespace std; #define ll long long int #define mod 1000000007 ll fact[100007]; ll vsum(vector v) { ll i,ln = v.size(),sum = 0; for(i = 0;i>s; fact[0] = 1; for(i = 1;i<100000;i++) { fact[i] = (i*fact[i-1])%mod; } ll ln = s.length(); ll arr[ln+1][26]; for(i = 0;i<26;i++) { arr[0][i] = 0; } j = s[0]-'a'; arr[0][j] = 1; for(i = 1;i>q; while(q--) { int l,r; cin>>l>>r; l--; r--; vector even,odd; if(l == 0) { for(j = 0;j<26;j++) { if(arr[r][j]>0&&arr[r][j]%2 == 0) { even.push_back(arr[r][j]); } else if(arr[r][j]%2 == 1) { odd.push_back(arr[r][j]); } } } else { for(j = 0;j<26;j++) { num = arr[r][j]-arr[l-1][j]; if(num>0&&num%2 == 0) { even.push_back(num); } else if(num%2 == 1) { odd.push_back(num); } } } vector p; ll le = even.size(); ll lo = odd.size(); for(i = 0;i1) p.push_back(odd[i]/2); } ans = fact[vsum(p)]; lk = p.size(); ll prod = 1; for(i = 0;i1) ans = (ans*lo)%mod; cout<