#include <bits/stdc++.h>
using namespace std;
void warm_up() {}
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int c0 = 0;
  int c0_max = 0;
  int c1 = 0;
  int c1_max = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] == '0') {
      if (s[i - 1] == '0') {
        c0++;
        c0_max++;
      } else {
        c0 = 0;
      }
    } else {
      if (s[i - 1] == '1') {
        c1++;
        c1_max++;
      } else {
        c1 = 0;
      }
    }
  }
  cout << max(c0_max, c1_max) << "\n";
}
int main() {
  warm_up();
  int q;
  cin >> q;
  while (q--) {
    solve();
  }
  return 0;
}
