#include <bits/stdc++.h>
using namespace std;
void printv(vector<long long int> v) {
  long long int sz = v.size();
  for (long long int i = 0; i < sz; i++) {
    if (i == sz - 1)
      cout << v[i] << "\n";
    else
      cout << v[i] << " ";
  }
}
void input(long long int a[], long long int sz) {
  for (long long int i = 0; i < sz; i++) cin >> a[i];
}
void print(long long int a[], long long int sz) {
  for (long long int i = 0; i < sz; i++) {
    if (i == sz - 1)
      cout << a[i] << "\n";
    else
      cout << a[i] << " ";
  }
}
long long int dx1[] = {1, 1, 0, -1, -1, -1, 0, 1};
long long int dy1[] = {0, 1, 1, 1, 0, -1, -1, -1};
long long int dx2[] = {1, 0, -1, 0};
long long int dy2[] = {0, 1, 0, -1};
long long int mul(long long int a, long long int b,
                  long long int p = 1000000007) {
  return ((a % p) * (b % p)) % p;
}
long long int add(long long int a, long long int b,
                  long long int p = 1000000007) {
  return (a % p + b % p) % p;
}
long long int power(long long int x, long long int y,
                    long long int p = 1000000007) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int modInverse(long long int n, long long int p = 1000000007) {
  return power(n, p - 2, p);
}
long long int ncrMod(long long int n, long long int r,
                     long long int p = 1000000007) {
  if (r == 0) return 1;
  long long int fac[n + 1];
  fac[0] = 1;
  for (long long int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % p;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
bool ispeed2ime(long long int n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}
bool isPowerof2(long long int n) {
  while (n > 1) {
    if (n % 2 != 0) {
      return true;
    }
    n /= 2;
  }
  return false;
}
string reverse(string str, int len, int l, int r) {
  if (l < 0 || r >= len || l > r) return str;
  while (l < r) {
    char c = str[l];
    str[l] = str[r];
    str[r] = c;
    l++;
    r--;
  }
  return str;
}
void solve() {
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  string temp = "";
  long long int maxi1 = 0, maxi2 = 0;
  for (int i = 0; i < n - 1; i++) {
    temp += s[i];
    temp += s[i + 1];
    if (temp == "10") {
      maxi1++;
    } else if (temp == "01") {
      maxi2++;
    }
    temp = "";
  }
  long long int maxi = max(maxi1, maxi2);
  long long int cnt = n / 2 - (maxi);
  cout << cnt << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
