#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int s0, s1, n, t;
char s[N];
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> s;
    int len = strlen(s);
    s0 = s1 = 0;
    for (int i = 0; i + 1 < len; i++) {
      if (s[i] == s[i + 1] && s[i] == '0')
        s0++;
      else if (s[i] == s[i + 1] && s[i] == '1')
        s1++;
    }
    cout << max(s0, s1) << endl;
  }
  return 0;
}
