#include <bits/stdc++.h>
using namespace std;
void khela() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string p = "";
  if (s[0] == '0') {
    for (int i = 0; i < n / 2; i++) {
      p += '0';
      p += '1';
    }
  } else {
    for (int i = 0; i < n / 2; i++) {
      p += '1';
      p += '0';
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != p[i]) {
      while (s[i] != p[i]) i++;
      cnt++;
    }
  }
  cout << cnt << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    khela();
  }
}
