#include <bits/stdc++.h>
using namespace std;
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cout << '{';
  __print(x.first);
  cout << ',';
  __print(x.second);
  cout << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cout << '{';
  for (auto &i : x) cout << (f++ ? "," : ""), __print(i);
  cout << "}";
}
void _print() { cout << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cout << ", ";
  _print(v...);
}
int32_t main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string s;
    cin >> s;
    long long int cnt0 = 0, cnt1 = 0;
    for (long long int i = 0; i < s.size() - 1; i++) {
      if (s[i] == s[i + 1]) {
        if (s[i] == '1')
          cnt0++;
        else
          cnt1++;
      }
    }
    cout << max(cnt0, cnt1) << endl;
  }
}
