#include <bits/stdc++.h>
using namespace std;
int t, n;
char s[100010];
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    getchar();
    scanf("%s", &s);
    int sum1 = 0, sum2 = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] - '0' == (i % 2)) continue;
      while (i < n && s[i] - '0' != (i % 2)) i++;
      sum1++;
    }
    for (int i = 0; i < n; i++) {
      if (s[i] - '0' == ((i + 1) % 2)) continue;
      while (i < n && s[i] - '0' != ((i + 1) % 2)) i++;
      sum2++;
    }
    printf("%d\n", min(sum1, sum2));
  }
  return 0;
}
