#line 1 "/home/siro53/kyo-pro/compro_library/template/template.cpp"
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) { os << ','; }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]: ", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define FOR(i, a, b) for(int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------
#line 2 "f.cpp"

ll A, B, N;

vector<int> p;

bool is_prime(int n) {
    if(n <= 1) return false;
    for(int i=2;i*i<=n;i++){
        if(n % i == 0) return false;
    }
    return true;
}

void init() {
    for(int i=2;i<=72;i++) {
        if(is_prime(i)) p.push_back(i);
    }
}

int main() {
    init();
    cin >> A >> B;
    N = B - A + 1;
    int n = p.size();

    vector<vector<ll>> dp(N+1, vector<ll>(1 << n, 0));
    dp[0][0] = 1;

    vector<int> pre_bit(N, 0);
    REP(i, N) {
        ll num = A + i;
        REP(j, n) if(num % p[j] == 0) pre_bit[i] |= (1 << j);
    }

    REP(i, N) {
        REP(S, 1 << n) {
            // 追加しない
            dp[i+1][S] += dp[i][S];
            // 追加する
            ll num = i+A;
            if(S & pre_bit[i]) continue;
            int nS = S | pre_bit[i];
            dp[i+1][nS] += dp[i][S];
        }
    }

    ll ans = 0;
    REP(S, 1 << n) ans += dp[N][S];

    cout << ans << endl;
}

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk make_pair
#define pb push_back
#define eb emplace_back
#define ins insert
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
//inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
inline char gc(){return getchar();}
inline int read(){
	int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;if(nc<0)return nc;
	x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48);return x*ny;
}
int n;char s[MAXN];
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	for(int t=read();t--;){
		n=read(),scanf("%s%s%s",s+1,s+1,s+1);
		Rep(i,1,n)cout<<'0';Rep(i,1,n)cout<<'1';cout<<'0';puts("");
	}
	return 0;
}

