#include <bits/stdc++.h>
using namespace std;
int coo(string s) {
  int a(0), b(0);
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == '0' && s[i + 1] == '0')
      a++;
    else if (s[i] == '1' && s[i + 1] == '1')
      b++;
  }
  return max(a, b);
}
void solve() {
  int n;
  string s;
  cin >> n >> s;
  cout << coo(s) << endl;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
