#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long res = 1;
  a = a % 1000000007;
  while (b) {
    if (b & 1) res = (res * a) % 1000000007;
    a = (a * a) % 1000000007;
    b /= 2;
  }
  return res;
}
long long invmod(long long a) { return power(a, 1000000007 - 2); }
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string s;
    int n;
    cin >> n;
    cin >> s;
    int ans1 = 0, i = 0, ans = 0;
    while (i < n) {
      if (s[i] != '1') {
        i++;
        continue;
      }
      int j = i + 1;
      while (j < n && s[j] == '1') j++, ans1++;
      i = j;
    }
    i = 0;
    while (i < n) {
      if (s[i] != '0') {
        i++;
        continue;
      }
      int j = i + 1;
      while (j < n && s[j] == '0') j++, ans++;
      i = j;
    }
    cout << max(ans1, ans) << '\n';
  }
  return 0;
}
