/*
Jackson Simoneau
SI@UCF 2026 - Intro to Competitive Programming

Solution to Specialty String (C): https://codeforces.com/contest/2200/problem/C
Explanations: https://codeforces.com/blog/entry/151625
*/

#include <bits/stdc++.h>
using namespace std;

int main() {
    //Process test cases
    int t; cin >> t;
    while(t--) {
        int n; cin >> n;
        string s;
        cin >> s;
        //Keep track of the number of remaining characters in s
        int rem = n;
        bool found = true;
        //Loop until no more operations can be performed
        while(rem > 0 && found) {
            found = false;
            for(int i = 0; i < s.size()-1; i++) {
                //If two adjacent characters match, we can remove them from the string
                if(s[i] == s[i+1]) {
                    found = true;
                    //Remove the characters by setting s to the concatenation of
                    //the substring preceding i and following i+1
                    s = s.substr(0, i) + s.substr(i+2);
                    rem -= 2;
                    break;
                }
            }
        }

        //If the string is empty after all operations are performed, it is possible to win
        if(rem == 0) cout << "YES\n";
        else cout << "NO\n";
    }
}