#include using namespace::std; #define ll long long #define ull unsigned ll #define LD long double #define mp make_pair #define bs binary_search #define gcd __gcd #define pb push_back #define pp pop_back #define ff first #define ss second #define PI acos(-1.0) #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL int cnt[100025][257]; int c[257]; template struct ModInt { static const int Mod = MOD; unsigned x; ModInt(): x(0) { } ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt &operator/=(ModInt that) { return *this *= that.inverse(); } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } ModInt operator/(ModInt that) const { return ModInt(*this) /= that; } ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0; while(b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return ModInt(u); } bool operator==(ModInt that) const { return x == that.x; } bool operator!=(ModInt that) const { return x != that.x; } ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; } }; const int MOD = 1e9+7; typedef ModInt mint; template ModInt operator^(ModInt a, unsigned long long k) { ModInt r = 1; while(k) { if(k & 1) r *= a; a *= a; k >>= 1; } return r; } ll Fact[100125]; ll ModInverse[100125]; void pre(ll N){ ModInverse[1]=1; for(ll i=2;i> s; s = "$" + s; for(int i='a';i<='z';i++) cnt[0][i] = 0; for(int i=1;i> Q; while(Q--){ int L,R; cin >> L >> R; mint res = 0; int has = 0; for(int i='a';i<='z';i++){ c[i] = cnt[R][i] - cnt[L-1][i]; } int len = R-L+1; if(len == 1){ for(int i='a';i<='z';i++){ if(c[i]>=1) res = res +1; } } else if(len == 2){ for(int i='a';i<='z';i++){ if(c[i] >= 2 && c[i] %2 == 0) res = res + 1; } } else if(len == 3){ for(int i='a';i<='z';i++){ if(c[i]%2 == 1){ c[i]--; for(int i='a';i<='z';i++){ if(c[i] >= 2 && c[i] %2 == 0) res = res + 1; } c[i]++; } } } cout << res.get() << endl; } return 0; }