#include <bits/stdc++.h>
char str[100005];
int main() {
  int t, n, ans1, ans0;
  scanf("%d", &t);
  while (t--) {
    ans1 = ans0 = 0;
    scanf("%d", &n);
    scanf("%s", str);
    for (int i = 1; i < n; i++) {
      while (str[i] == str[i - 1] && i < n) {
        if (str[i] == '1') {
          ans1++;
        } else {
          ans0++;
        }
        i++;
      }
    }
    if (ans0 < ans1) {
      ans0 = ans1;
    }
    printf("%d\n", ans0);
  }
}
