#include <bits/stdc++.h>
using namespace std;
int main() {
  size_t t;
  cin >> t;
  while (t > 0) {
    size_t n;
    string stroka;
    cin >> n;
    int count = 0;
    int res1 = 0;
    int res0 = 0;
    int tmp = 0;
    int dig;
    for (size_t i = 0; i < n; i++) {
      char c_dig;
      cin >> c_dig;
      dig = c_dig - '0';
      if (i == 0)
        tmp = dig;
      else {
        if (tmp == dig)
          count++;
        else {
          if (count != 0 && tmp == 1) {
            res1 += count;
            count = 0;
          } else if (count != 0 && tmp == 0) {
            res0 += count;
            count = 0;
          }
        }
        tmp = dig;
      }
    }
    if (count != 0 && tmp == 1) {
      res1 += count;
      count = 0;
    } else if (count != 0 && tmp == 0) {
      res0 += count;
      count = 0;
    }
    cout << max(res1, res0) << endl;
    res1 = 0;
    res0 = 0;
    t--;
  }
}
