#include <bits/stdc++.h>
using namespace std;
long long ceill(long long x, long long y) {
  if (x % y == 0) {
    return x / y;
  }
  return (x / y) + 1;
}
long long prime(long long n) {
  vector<long long> v;
  while (n % 2 == 0) {
    v.push_back(2);
    n /= 2;
  }
  for (long long i = 3; i < sqrt(n); i += 1) {
    while (n % i == 0) {
      v.push_back(i);
      n /= i;
    }
  }
  if (n > 2) {
    v.push_back(n);
  }
  return v.size();
}
int min_sum(int n) {
  if (n == 0)
    return 0;
  else if (n == 1)
    return 2;
  return (n + 1 + min_sum(n / 2) + min_sum(n - n / 2 - 1));
}
void printDivisors(long long n) {
  vector<long long> v;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        v.push_back(i);
      } else {
        v.push_back(i);
        v.push_back(n / i);
      }
    }
  }
  cout << v.size() << "\n";
}
bool numis(string s) {
  for (int i = 0; i < s.length(); i++)
    if (isdigit(s[i]) == false) return false;
  return true;
}
long long fact(long long n) {
  if (n < 1) {
    return 1;
  }
  return n * fact(n - 1);
}
int sub(string s, string s2) {
  int l1 = s.size();
  int l2 = s2.size();
  int l = l1 - l2;
  for (int i = 0; i <= l; i++) {
    int j;
    for (j = 0; j < l2; j++) {
      if (s[i + j] != s2[j]) {
        break;
      }
    }
    if (j == l2) {
      s.erase(i, 1);
      return sub(s, s2);
    }
  }
  return s.size();
}
pair<string, int> findEntryWithLargestValue(map<string, int> m) {
  pair<string, int> mm = make_pair("", 0);
  map<string, int>::iterator itr;
  for (itr = m.begin(); itr != m.end(); ++itr) {
    if (itr->second > mm.second) {
      mm = make_pair(itr->first, itr->second);
    }
  }
  return mm;
}
vector<long long> v;
long long pri(long long n) {
  long long res = 0, step = 1;
  while (n > 0) {
    long long sin = n % 10;
    if (sin != 0) {
      res += (sin * step);
      step *= 10;
    }
    n /= 10;
  }
  return res;
}
const int xx = 4e5 + 2;
long long a[xx];
vector<long long> factor(long long n) {
  vector<long long> v;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      if (n / i == i) {
        v.push_back(i);
      } else {
        v.push_back(i);
        v.push_back(n / i);
      }
    }
  }
  sort(v.begin(), v.end());
  return v;
}
long long b_Search(long long a[], long long left, long long right,
                   long long x) {
  long long answer = 0;
  while (left <= right) {
    long long middle = (left + right) / 2;
    if (a[middle] > x) {
      return (a, left, middle - 1, x);
    } else {
      answer = middle + 1;
      return (a, middle + 1, right, x);
    }
  }
  return answer;
}
vector<long long> vvv;
void count_number(long long n) {
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) {
        vvv.push_back(i);
      } else {
        vvv.push_back(i);
        vvv.push_back(n / i);
      }
    }
  }
}
void body() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  long long cnt = 0, mx = 0, dnt = 0, mxx = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] == '1' && s[i + 1] == '1') {
      cnt++;
    } else if (s[i] == '0' && s[i + 1] == '0') {
      dnt++;
    }
  }
  cout << max(cnt, dnt) << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    body();
  }
  return 0;
}
