#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n % 2) {
      bool k = true;
      for (int i = 0; i < n; i += 2) {
        if ((s[i] - '0') % 2) {
          cout << 1 << endl;
          k = false;
          break;
        }
      }
      if (k) {
        cout << 2 << endl;
      }
    } else {
      bool k = true;
      for (int i = 1; i < n; i += 2) {
        if ((s[i] - '0') % 2 == 0) {
          cout << 2 << endl;
          k = false;
          break;
        }
      }
      if (k) {
        cout << 1 << endl;
      }
    }
  }
  return 0;
}
