#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans, ans1, ans3, ans4;
    ans = ans1 = ans3 = ans4 = 0, ans1 = 0;
    string s1 = "1", s2 = "0";
    s1 += s, s2 += s;
    s1 += "0", s2 += "1";
    for (int i = 1; i < n + 2; i++) {
      if (s1[i] == '1' && s1[i - 1] == '1') ans++;
      if (s1[i] == '0' && s1[i - 1] == '0') ans1++;
      if (s2[i] == '1' && s2[i - 1] == '1') ans3++;
      if (s2[i] == '0' && s2[i - 1] == '0') ans4++;
    }
    cout << min((ans + ans1) / 2, (ans3 + ans4) / 2) << endl;
  }
}
