#include <bits/stdc++.h>
using namespace std;
void input(vector<long long int> &arr) {
  for (int i = 0; i < arr.size(); i++) cin >> arr[i];
}
void output(vector<long long int> arr) {
  for (int i = 0; i < arr.size(); i++) cout << arr[i] << " ";
  cout << "\n";
}
long long int gcd(long long int a, long long int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long int power(long long int a, long long int b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  long long int smallans = power(a, b / 2);
  long long int myans = (smallans * smallans) % 1000000007;
  if ((b & 1)) myans = (myans * a) % 1000000007;
  return myans;
}
long long int multiply(long long int a, long long int b) {
  long long int ans = ((a % 1000000007) * (b % 1000000007)) % 1000000007;
  return ans;
}
long long int add(long long int a, long long int b) {
  long long int ans = ((a % 1000000007) + (b % 1000000007)) % 1000000007;
  return ans;
}
long long int subtract(long long int a, long long int b) {
  long long int ans = ((a % 1000000007) - (b % 1000000007)) % 1000000007;
  if (ans < 0) ans += 1000000007;
  return ans;
}
long long int divide(long long int a, long long int b) {
  return multiply(a, power(b, 1000000007 - 2));
}
struct hash_pair {
  template <class T1, class T2>
  size_t operator()(const pair<T1, T2> &p) const {
    auto hash1 = hash<T1>{}(p.first);
    auto hash2 = hash<T2>{}(p.second);
    return hash1 ^ hash2;
  }
};
void update(vector<long long int> &tree, long long int index,
            long long int val) {
  index++;
  while (index < tree.size()) {
    tree[index] = (tree[index] + val) % 1000000007;
    index += index & (-index);
  }
}
long long int calculate(vector<long long int> &tree, long long int index) {
  long long int sum = 0;
  index++;
  while (index > 0) {
    sum = (sum + tree[index]) % 1000000007;
    index -= index & (-index);
  }
  return sum;
}
long long int findpar(long long int p, vector<long long int> &parent) {
  if (parent[p] == p) return p;
  parent[p] = findpar(parent[p], parent);
  return parent[p];
}
void merge(long long int a, long long int b, vector<long long int> &parent,
           vector<long long int> &size_) {
  a = findpar(a, parent);
  b = findpar(b, parent);
  if (a != b) {
    if (size_[a] < size_[b]) swap(a, b);
    parent[b] = a;
    size_[a] += size_[b];
  }
}
void solve() {
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  long long int zero = 0;
  long long int one = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] == s[i - 1] && s[i - 1] == '1') one++;
    if (s[i] == s[i - 1] && s[i - 1] == '0') zero++;
  }
  cout << max(zero, one) << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
