#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  long long int a = 0, b = 0;
  char prev = 'a';
  prev = s[0];
  for (int i = 1; i < n; i++) {
    if (s[i] == s[i - 1]) {
      if (s[i] == '0') {
        a++;
      } else {
        b++;
      }
    }
  }
  cout << max(a, b) << "\n";
}
int main() {
  int test = 1;
  cin >> test;
  while (test-- > 0) {
    solve();
  }
  return 0;
}
