#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
string a;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    getchar();
    getline(cin, a);
    string s1 = "10", s2 = "01", s3 = "", s4 = "";
    for (int i = 0; i < n / 2; i++) {
      s3 += s1;
      s4 += s2;
    }
    int c1 = 0, c2 = 0;
    bool flag1 = 0, flag2 = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] != s3[i]) {
        if (flag1 == 0) c1++;
        flag1 = 1;
      } else
        flag1 = 0;
      if (a[i] != s4[i]) {
        if (flag2 == 0) c2++;
        flag2 = 1;
      } else
        flag2 = 0;
    }
    printf("%d\n", min(c1, c2));
  }
  return 0;
}
