#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
const long long maxn = 100005;
const long long mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t, n, i, j, k;
  cin >> t;
  while (t--) {
    cin >> n;
    string s;
    cin >> s;
    int ans1 = 0, e = 0, o = 0, ans2 = 0, cnt = 0;
    for (i = 0; i < n; i++) {
      if (i % 2 && s[i] == '0') {
        if (cnt > 0) ++ans1;
        cnt = 0;
      } else if (i % 2 && s[i] == '1') {
        ++cnt;
      }
      if (i % 2 == 0 && s[i] == '1') {
        if (cnt > 0) ++ans1;
        cnt = 0;
      } else if (i % 2 == 0 && s[i] == '0') {
        ++cnt;
      }
    }
    if (cnt > 0) ++ans1;
    cnt = 0;
    for (i = 0; i < n; i++) {
      if (i % 2 && s[i] == '1') {
        if (cnt > 0) ++ans2;
        cnt = 0;
      } else if (i % 2 && s[i] == '0') {
        ++cnt;
      }
      if (i % 2 == 0 && s[i] == '0') {
        if (cnt > 0) ++ans2;
        cnt = 0;
      } else if (i % 2 == 0 && s[i] == '1') {
        ++cnt;
      }
    }
    if (cnt > 0) ++ans2;
    cout << min(ans1, ans2) << "\n";
  }
}
