#include #include #include #include #include #include #include #define M 1000000007 using namespace std; string s; int n; int val[1<<16]; int mark[1<<16]; bool vis[11][1<<16][16]; int dp[11][1<<16][16]; void pre() { for ( int i = 0; i < (1<<16); i++ ) { val[i] = 0; for ( int j = 0; j < 16; j++ ) { if ( !(i & (1<= M ) ans -= M; } dp[idx][mask][pre_xor] = ans; return ans; } int f(int idx, int tight, int mask, int pre_xor) { if ( idx == n ) return val[mask]; int ans; if ( tight == 0 ) ans = cal(n - idx, mask, pre_xor); else { ans = 0; for ( int i = 0; i <= s[idx] - 49; i++ ) { ans += f(idx + 1, 0, mask | (1 << (pre_xor ^ i)), pre_xor ^ i); if ( ans >= M ) ans -= M; } ans += f(idx + 1, 1, mask | (1 << (pre_xor ^ (s[idx] - 48))), pre_xor ^ (s[idx] - 48)); if ( ans >= M ) ans -= M; } return ans; } int get(int x) { stringstream ss; ss.clear(); ss << x; s = ss.str(); n = (int)s.size(); return f(0,1,(1<<0),0); } int main() { // freopen("inp8.txt", "r", stdin); // freopen("out8.txt", "w", stdout); pre(); int t; int a,b; cin >> t; assert(t >= 1 && t <= 10); while ( t-- ) { cin >> a >> b; assert(a >= 1 && a <= 1000000000); assert(b >= 1 && b <= 1000000000); assert(a <= b); cout << (get(b) - get(a - 1) + M) % M << endl; } return 0; }