#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  int n;
  cin >> n >> s;
  int c0 = 0, c1 = 0;
  for (int i = 0; i < n - 1; i++) {
    if (s[i] == '0' && s[i + 1] == '0') c0++;
    if (s[i] == '1' && s[i + 1] == '1') c1++;
  }
  cout << max(c0, c1) << '\n';
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
