#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, c1 = 0, c2 = 0;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 1; i < n; i++) {
      if (s[i] != s[i - 1]) {
        if (s[i] == '1')
          c1++;
        else
          c2++;
      }
    }
    if (s.back() == '1')
      c2++;
    else
      c1++;
    cout << max(n / 2 - c1, n / 2 - c2) << "\n";
  }
  return 0;
}
