#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    string str;
    cin >> str;
    int res0 = 0, res1 = 0;
    for (int i = 1; i < n; i++) {
      if (str[i] == str[i - 1]) {
        if (str[i] == '0')
          res0++;
        else
          res1++;
      }
    }
    cout << max(res0, res1) << "\n";
  }
  return 0;
}
