#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class T, class S>
ostream &operator<<(ostream &o, const pair<T, S> &p) {
  return o << '(' << p.first << ", " << p.second << ')';
}
template <template <class, class...> class T, class... A>
typename enable_if<!is_same<T<A...>, string>(), ostream &>::type operator<<(
    ostream &o, T<A...> V) {
  o << '[';
  for (auto a : V) o << a << ", ";
  return o << ']';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long int tc;
  cin >> tc;
  while (tc--) {
    long long int n;
    cin >> n;
    string s;
    cin >> s;
    map<char, long long int> ct;
    for (long long int i = 1; i < (n); i++)
      if (s[i] == s[i + 1]) ct[s[i]]++;
    cout << max(ct['0'], ct['1']) << '\n';
  }
}
