#include <bits/stdc++.h>
using namespace std;
void fun() {
  long long int a;
  cin >> a;
  string str;
  cin >> str;
  long long int cnt = 0;
  for (long long int i = 0; i < a;) {
    if (str[i] == '1' && str[i + 1] == '0') {
      i++;
    } else if (str[i] == '0' && str[i + 1] == '1') {
      i++;
    } else {
      cnt++;
      i++;
    }
  }
  cout << cnt / 2 << endl;
}
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    fun();
  }
}
