#include <bits/stdc++.h>
using namespace std;
int t;
long long i, j;
long long n, k, p, m, c, x;
long long mx = LLONG_MIN, mn = LLONG_MAX;
string s, s1, s2;
char ch;
long long a[100001], deg[100001];
map<long long, long long> mp;
vector<long long> vc, vc1, v[100001], w[100001];
set<long long> st;
priority_queue<pair<long long, long long>, vector<pair<long long, long long> >,
               greater<pair<long long, long long> > >
    q;
long long mod = 1e9 + 7;
bool r;
void solve();
int main() {
  t = 1;
  cin >> t;
  x = t;
  while (t--) {
    solve();
  }
  return 0;
}
void solve() {
  long long n, c = 0, d = 0, i;
  string s;
  cin >> n >> s;
  for (i = 0; i < n - 1; i++) {
    if (s[i] == '1') {
      if (s[i] == s[i + 1]) {
        c++;
      }
    }
    if (s[i] == '0') {
      if (s[i] == s[i + 1]) {
        d++;
      }
    }
  }
  cout << max(c, d) << endl;
  return;
}
