#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n == 1) {
      int num = s[0] - '0';
      if (num % 2 == 0)
        cout << 2 << endl;
      else
        cout << 1 << endl;
    } else if (n % 2 != 0) {
      int flag = 0;
      for (int i = 0; i < s.length(); i += 2) {
        if ((s[i] - '0') % 2 != 0) {
          flag = 1;
          break;
        }
      }
      if (flag == 0)
        cout << 2 << endl;
      else
        cout << 1 << endl;
    } else {
      int flag = 0;
      for (int i = 1; i < s.length(); i += 2) {
        if ((s[i] - '0') % 2 == 0) {
          flag = 1;
          break;
        }
      }
      if (flag == 1)
        cout << 2 << endl;
      else
        cout << 1 << endl;
    }
  }
  return 0;
}
