#include <bits/stdc++.h>
using namespace std;
int T;
int n, m;
char s[111111];
int main() {
  scanf("%d", &T);
  while (T--) {
    int cnt = 0, cnt2 = 0;
    scanf("%d", &n);
    scanf("%s", s + 1);
    int x = 0;
    for (int i = 1; i <= n; i++) {
      if (s[i] == s[i - 1] && s[i] == '1') cnt++;
      if (s[i] == s[i - 1] && s[i] == '0') cnt2++;
    }
    printf("%d\n", max(cnt2, cnt));
  }
  return 0;
}
