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