#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> cnts;
  int cnt = 0, ans0 = 0, ans1 = 0;
  for (int i = 0; i < (n); i++) {
    if ((i & 1) ^ (s[i] & 1)) {
      cnt++;
    } else if (cnt) {
      ans0++;
      cnt = 0;
    }
  }
  if (cnt) {
    ans0++;
    cnt = 0;
  }
  for (int i = 0; i < (n); i++) {
    if ((i & 1) == (s[i] & 1)) {
      cnt++;
    } else if (cnt) {
      ans1++;
      cnt = 0;
    }
  }
  if (cnt) ans1++;
  cout << min(ans0, ans1) << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) solve();
}
