#include <bits/stdc++.h>
const long long big = 998244353;
using namespace std;
long long power(long long a, long long n) {
  if (n == 0) return 1;
  if (n % 2 == 1)
    return (power(a, n - 1) * a) % big;
  else {
    long long b = power(a, n / 2);
    return (b * b) % big;
  }
}
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int t[1000000];
void build(int a[], int v, int tl, int tr) {
  if (tl >= tr)
    t[v] = a[tl];
  else {
    int tm = (tl + tr) / 2;
    build(a, v * 2, tl, tm);
    build(a, v * 2 + 1, tm + 1, tr);
  }
}
void update(int v, int tl, int tr, int l, int r, int add) {
  if (l > r) return;
  if (l == tl && tr == r)
    t[v] += add;
  else {
    int tm = (tl + tr) / 2;
    update(v * 2, tl, tm, l, min(r, tm), add);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, add);
  }
}
int get(int v, int tl, int tr, int pos) {
  if (tl == tr) return t[v];
  int tm = (tl + tr) / 2;
  if (pos <= tm)
    return t[v] + get(v * 2, tl, tm, pos);
  else
    return t[v] + get(v * 2 + 1, tm + 1, tr, pos);
}
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans1 = 0, ans2 = 0;
  for (int i = 0; i < n - 1; ++i) {
    if (s[i] == '1' && s[i + 1] == '1') ++ans1;
  }
  for (int i = 0; i < n - 1; ++i) {
    if (s[i] == '0' && s[i + 1] == '0') ++ans2;
  }
  cout << max(ans1, ans2) << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
