#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  long long ans1 = 0;
  long long ans2 = 0;
  for (long long i = 1; i < n; i++) {
    if (s[i - 1] == '1' && s[i] == '1') ans1++;
    if (s[i - 1] == '0' && s[i] == '0') ans2++;
  }
  cout << max(ans1, ans2) << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
