#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int num[N];
int t, n;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    string a;
    cin >> a;
    memset(num, 0, sizeof num);
    num[0] = a[0] - '0';
    int number = 0;
    for (int i = 1; i < n; i++) {
      num[i] = (a[i] - '0') - (a[i - 1] - '0');
      if (!num[i]) number++;
    }
    if (number % 2) number++;
    cout << number / 2 << endl;
  }
  return 0;
}
