#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int main() {
  int t, n;
  cin >> t;
  string s;
  while (t--) {
    cin >> n >> s;
    int res = n / 2;
    for (int i = 1; i < s.length(); i++)
      if (s[i] == '0' && s[i - 1] == '1') res--;
    int ans = n / 2;
    for (int i = 1; i < s.length(); i++)
      if (s[i] == '1' && s[i - 1] == '0') ans--;
    cout << min(ans, res) << endl;
  }
  return 0;
}
