#include <iostream>
#include <set>
using namespace std;
multiset <pair <unsigned int, unsigned int>> M;
multiset <pair <unsigned int, unsigned int>>::iterator it;
int main() {
unsigned int t, n, a, b;
cin >> t;
while (t != 0) {
cin >> n;
M.clear();
for (int i = 0; i < n; i++) {
cin >> a >> b;
if ((it = M.find (make_pair(b, a))) == M.end()) {
M.insert (make_pair(a, b));
} else M.erase(it);
}
(M.empty()) ? cout << "YES" << endl : cout << "NO" << endl;
t--;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c2V0Pgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKbXVsdGlzZXQgPHBhaXIgPHVuc2lnbmVkIGludCwgdW5zaWduZWQgaW50Pj4gTTsKbXVsdGlzZXQgPHBhaXIgPHVuc2lnbmVkIGludCwgdW5zaWduZWQgaW50Pj46Oml0ZXJhdG9yIGl0OwoKaW50IG1haW4oKSB7Cgl1bnNpZ25lZCBpbnQgdCwgbiwgYSwgYjsKCWNpbiA+PiB0OwoJd2hpbGUgKHQgIT0gMCkgewoJCWNpbiA+PiBuOwoJCU0uY2xlYXIoKTsKCQlmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewoJCQljaW4gPj4gYSA+PiBiOwoJCQlpZiAoKGl0ID0gTS5maW5kIChtYWtlX3BhaXIoYiwgYSkpKSA9PSBNLmVuZCgpKSB7CgkJCQlNLmluc2VydCAobWFrZV9wYWlyKGEsIGIpKTsKCQkJfSBlbHNlIE0uZXJhc2UoaXQpOwoJCX0KCQkoTS5lbXB0eSgpKSA/IGNvdXQgPDwgIllFUyIgPDwgZW5kbCA6IGNvdXQgPDwgIk5PIiA8PCBlbmRsOwoJCXQtLTsKCX0KCQoJcmV0dXJuIDA7Cn0=