#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
int dat[MAXN];
inline int read() {
  int x = 0;
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
inline int readin() {
  char ch = getchar();
  while (!isdigit(ch)) ch = getchar();
  return ch == '1';
}
template <typename T1, typename T2>
inline void Max(T1 &x, T2 y) {
  if (x < y) x = y;
}
template <typename T1, typename T2>
inline void Min(T1 &x, T2 y) {
  if (x > y) x = y;
}
int main() {
  int t = read();
  while (t--) {
    int n = read(), sum = 0;
    for (int i = 1; i <= n; i++) dat[i] = readin();
    for (int i = 2; i <= n; i++)
      if (dat[i] ^ dat[i - 1]) sum++;
    printf("%d\n", (n - sum) / 2);
  }
  return 0;
}
