#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long inf = 0x3f3f3f3f;
const long long llinf = 1e18;
const long long nax = 0;
void solve() {
  int n, satu = 0, nol = 0;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i + 1 < n; ++i) {
    if (s[i] == s[i + 1]) {
      if (s[i] == '1')
        satu++;
      else
        nol++;
    }
  }
  cout << max(satu, nol) << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
