#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a;
  cin >> a;
  while (a--) {
    long long b;
    cin >> b;
    long long z = 0, y = 0;
    string c;
    cin >> c;
    for (long long i = 0; i < c.size() - 1; i++) {
      if (c[i] == '1') {
        if (c[i] == c[i + 1]) {
          z++;
        }
      }
      if (c[i] == '0') {
        if (c[i] == c[i + 1]) {
          y++;
        }
      }
    }
    z = max(y, z);
    cout << z << endl;
  }
  return 0;
}
