#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^8 -> 8回
// double pi = M_PI or acos(-1)
// printf("%.10f\n", ans);

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i, n) cin >> x[i] >> y[i];
    auto dist = [&](int i, int j) {
        double dx = x[i] - x[j];
        double dy = y[i] - y[j];
        return sqrt(dx * dx + dy * dy);
    };
    vector<int> p(n);
    rep(i, n) p.at(i) = i;
    double len = 0;
    int cnt = 0;
    do {
        rep(i, n - 1) {
            len += dist(p.at(i), p.at(i + 1));
        }
        cnt++;
    } while (next_permutation(p.begin(), p.end()));
    double ans = len / cnt;
    printf("%.10f\n", ans);

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()



int main(){
  ll T;
  cin >> T;
  rep(w,T){
    ll N;
    cin >> N;
    vec A(N);
    rep(i,N){
      cin >> A.at(i);
    }
    string S;
    cin >> S;
    set<ll> B;
    B.insert(0);
    rep(i,N){
      set<ll> C;
      auto b=B.end();
      ll a=A.at(N-1-i);
      rep(j,(ll)B.size()){
        b--;
        a=min(a,a^*b);
      }
      if(S.at(N-1-i)=='0'){
        if(a!=0){
          B.insert(a);
        }
      }else{
        if(a!=0){
          B=C;
          break;
        }
      }
    }
    if(B.size()==0){
      cout << 1 << endl;
    }else{
      cout << 0 << endl;
    }
  }
        
   
}