#include <bits/stdc++.h>
using namespace std;
const double Pi = acos(-1.0);
const int MAXN = 1e6 + 5;
int n, m, t;
int v[MAXN];
char s[MAXN];
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> s + 1;
    int sum1 = 0, sum2 = 0, now = 0;
    for (int i = 1; i <= n * 2; i++) {
      if (s[i] == '1')
        now++;
      else {
        sum1 += max(now - 1, 0);
        now = 0;
      }
    }
    if (now) sum1 += now - 1;
    now = 0;
    for (int i = 1; i <= n * 2; i++) {
      if (s[i] == '0')
        now++;
      else {
        sum2 += max(now - 1, 0);
        now = 0;
      }
    }
    if (now) sum2 += now - 1;
    cout << max(sum1, sum2) << endl;
  }
}
