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