#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt0 = 0, cnt1 = 0, one = 0, zero = 0;
    for (int i = 0; i < s.length(); i++) {
      if (s[i] == '0') {
        zero++;
        if (one != 0) cnt0 += one - 1;
        one = 0;
      } else if (s[i] == '1') {
        one++;
        if (zero != 0) cnt1 += zero - 1;
        zero = 0;
      }
    }
    cout << max(cnt0, cnt1) << "\n";
  }
}
