#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    bool b1 = true;
    if (n % 2 == 0) {
      for (int i = 0; i < n; i = i + 2) {
        if ((s[i + 1] - '0') % 2 == 0) {
          b1 = false;
          break;
        }
      }
      if (b1) {
        cout << 1 << endl;
      } else {
        cout << 2 << endl;
      }
    } else {
      for (int i = 0; i < n; i = i + 2) {
        if ((s[i] - '0') % 2 != 0) {
          b1 = false;
          break;
        }
      }
      if (b1) {
        cout << 2 << endl;
      } else {
        cout << 1 << endl;
      }
    }
  }
}
