#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, i;
    cin >> n;
    char s[n];
    cin >> s;
    int a1 = 0, a2 = 0;
    for (i = 0; i < n - 1; i++) {
      if ((s[i] == '1') && (s[i + 1] == '1')) a1 = a1 + 1;
      if ((s[i] == '0') && (s[i + 1] == '0')) a2 = a2 + 1;
    }
    if (a1 != 0 || a2 != 0)
      cout << max(a1, a2) << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}
