#include <bits/stdc++.h>
using namespace std;
const int N = 2e2 + 10;
int t, f, n;
int cnt[2];
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    int n;
    cin >> n >> s;
    cnt[0] = 0;
    cnt[1] = 0;
    f = s[0] - '0';
    for (int w = 0; w < n; w++) {
      if (w == 0) {
        cnt[f]++;
        continue;
      }
      if (s[w] != s[w - 1]) {
        f = abs(f - 1);
        cnt[f]++;
      }
    }
    cout << max(n / 2 - cnt[0], n / 2 - cnt[1]) << "\n";
  }
}
