#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ;
  int t;
  cin >> t;
  for (int i = 0; i < int(t); i++) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt1 = 0, cnt2 = 0, cmp1 = 0, cmp2 = 0;
    for (int j = 0; j < int(n); j++) {
      if (((s[j] - '0') & 1) != (j & 1)) {
        cnt1++;
        if (cnt2) cmp2++;
        cnt2 = 0;
      } else {
        cnt2++;
        if (cnt1) cmp1++;
        cnt1 = 0;
      }
    }
    if (cnt2) cmp2++;
    if (cnt1) cmp1++;
    cout << min(cmp1, cmp2) << '\n';
  }
  return 0;
}
