#include <bits/stdc++.h>
using namespace std;
using VI = vector<long long>;
using VLL = vector<long long>;
using PII = pair<long long, long long>;
using PLL = pair<long long, long long>;
using VPII = vector<PII>;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
template <typename T>
T abs(T a) {
  return a < 0 ? -a : a;
}
void solve() {
  long long n;
  cin >> n;
  string p;
  cin >> p;
  long long cnt1 = 0, cnt2 = 0;
  for (auto i = 0; i < (n - 1); ++i) {
    if (p[i] == p[i + 1] && p[i] == '1') {
      cnt1++;
    }
    if (p[i] == p[i + 1] && p[i] == '0') {
      cnt2++;
    }
  }
  cout << max(cnt1, cnt2) << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
