#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const long double pi = 3.14159265358979323846;
const long long INF = 1e18;
int tc = 1;
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  string b = s;
  s = "1" + s;
  s = s + "0";
  b = b + "1";
  b = "0" + b;
  int cnt = 0, cnt2 = 0;
  for (int i = (1); i < (n + 2); i++) {
    if (s[i] == s[i - 1]) cnt++;
    if (b[i - 1] == b[i]) cnt2++;
  }
  int ans = min(cnt, cnt2) / 2;
  cout << ans << "\n";
}
int main() {
  clock_t clk = clock();
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> tc;
  while (tc--) solve();
  cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC
       << '\n';
  return 0;
}
