#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long max(long long x, long long y) { return (x > y) ? x : y; }
void dfs(long long u, vector<long long> adj[], vector<bool> &visited) {
  visited[u] = true;
  for (long long v : adj[u]) {
    if (!visited[v]) dfs(v, adj, visited);
  }
}
long long gcd(long long a, long long b) {
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
void fillDepth(long long parent[], long long i, long long depth[]) {
  if (depth[i]) return;
  if (parent[i] == -1) {
    depth[i] = 1;
    return;
  }
  if (depth[parent[i]] == 0) fillDepth(parent, parent[i], depth);
  depth[i] = depth[parent[i]] + 1;
}
long long findHeight(long long parent[], long long n) {
  long long depth[n];
  for (long long i = 0; i < n; i++) depth[i] = 0;
  for (long long i = 0; i < n; i++) fillDepth(parent, i, depth);
  long long ht = depth[0];
  for (long long i = 1; i < n; i++)
    if (ht < depth[i]) ht = depth[i];
  return ht;
}
string fun(string ans, string s, long long n, long long k, long long c0,
           long long c1, long long cQ) {
  for (long long i = k; i < n; i++) {
    if (s[i] == '1')
      c1++;
    else if (s[i] == '0')
      c0++;
    if (s[i - k] == '1')
      c1--;
    else if (s[i - k] == '0')
      c0--;
    if (s[i] == '?') {
      if (s[i - k] == '1') {
        s[i] = '1';
        c1 = 0;
        c0 = 0;
      } else if (s[i - k] == '0') {
        s[i] = '0';
        c1 = 0;
        c0 = 0;
      } else {
        ans = "NO";
        break;
      }
    }
    if (c1 != c0) {
      long long diff = abs(c1 - c0);
      if (diff > cQ) {
        ans = "NO";
        break;
      }
    }
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    long long ans = 0;
    if (n == 2) {
      cout << ans << "\n";
      continue;
    } else {
      long long ans = 0, c1 = 0, c2 = 0;
      for (long long i = 0; i < n; i++) {
        if (s[i] == s[i + 1] && s[i] == '1')
          c1++;
        else if (s[i] == s[i + 1] && s[i] == '0')
          c2++;
      }
      ans = max(c1, c2);
      cout << ans << "\n";
    }
  }
  return 0;
}
