#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    int n1;
    string a;
    cin >> n1;
    cin >> a;
    int r_even = 0;
    int r_odd = 0;
    int b_even = 0;
    int b_odd = 0;
    for (int i = 0; i < a.size(); i++) {
      if (i % 2 == 0) {
        if (((a[i] - '0') % 2) == 0)
          r_even++;
        else
          r_odd++;
      } else {
        if (((a[i] - '0') % 2) == 0)
          b_even++;
        else
          b_odd++;
      }
    }
    if (n1 % 2 == 0) {
      if (b_even > 0)
        cout << 2 << endl;
      else
        cout << 1 << endl;
    }
    if (n1 % 2 != 0) {
      if (r_odd > 0)
        cout << 1 << endl;
      else
        cout << 2 << endl;
    }
  }
  return 0;
}
