#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int count1 = 0, count0 = 0, max_no = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] == '0' && s[i] == s[i - 1])
      count0++;
    else if (s[i] == '1' && s[i] == s[i - 1])
      count1++;
  }
  max_no = max(count0, count1);
  cout << max_no << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
