#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e+2 + 7;
const long long MOD = 1e+9 + 7, INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
double EPS = 1e-9;
double PI = acos(-1);
long long t, n, a, b;
string s;
char temp;
int main() {
  ios::sync_with_stdio(false);
  cout << fixed;
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << setprecision(0);
  ;
  cin >> t;
  for (long long i = 0; i < t; i += 1) {
    a = 0;
    b = 0;
    s.clear();
    cin >> n;
    for (long long i = 0; i < n; i += 1) {
      cin >> temp;
      s.push_back(temp);
    }
    if (s[0] == '0')
      a++;
    else
      b++;
    for (long long j = 1; j < n; j += 1) {
      if (s[j] == '0' && s[j - 1] != '1') a += 1;
      if (s[j] == '1' && s[j - 1] != '0') b += 1;
    }
    cout << min(a, b);
    cout << "\n";
  }
}
