#include <bits/stdc++.h>
using namespace std;
long long check(string s) {
  long long n = s.length();
  string s1, s2;
  for (long long i = 0; i < n; i++) {
    if (i % 2 == 0) s1 += '1';
    if (i % 2) s1 += '0';
  }
  for (long long i = 0; i < n; i++) {
    if (i % 2) s2 += '1';
    if (i % 2 == 0) s2 += '0';
  }
  vector<long long> v1, v2;
  long long x1 = 0, y1 = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] != s1[i]) v1.push_back(i);
    if (s[i] != s2[i]) v2.push_back(i);
  }
  long long i = 0;
  while (i < v1.size()) {
    long long x = v1[i];
    x1++;
    while (i < v1.size() && v1[i] == x) {
      i++;
      x++;
    }
  }
  i = 0;
  while (i < v2.size()) {
    long long x = v2[i];
    y1++;
    while (i < v2.size() && v2[i] == x) {
      i++;
      x++;
    }
  }
  return min(x1, y1);
}
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  long long x1 = check(s);
  cout << x1 << endl;
}
int32_t main() {
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
