#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w,
    x, y, z;
long long ans = 0, sum = 0, mn = 1e18, mx = 0, cnt = 0;
const long long M = 1000000007;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
int main() {
  cin >> t;
  while (t--) {
    string s;
    cin >> n;
    cin >> s;
    int one = 1;
    int zero = 1;
    for (int i = 1; i < n; i++) {
      if (s[i] == s[i - 1] && s[i] == '1')
        one++;
      else if (s[i] == s[i - 1] && s[i] == '0')
        zero++;
    }
    cout << max(one, zero) - 1 << "\n";
  }
  return 0;
}
