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