#include using namespace std; using ll = long long; using ld = long double; using pii = pair; using vi = vector; using vvi = vector; #define rep(i, a, b) for(ll i = (a); i < (b); i++) #define all(x) begin(x),end(x) #define sz(x) (int)(x).size() struct circ { ll x, y, r; }; void solve() { ll n; cin >> n; vector circs(n); for(auto& [x, y, r] : circs) { cin >> x >> y >> r; } vector adj(n); rep(from, 0, n) rep(to, from+1, n) { auto [x1, y1, r1] = circs[from]; auto [x2, y2, r2] = circs[to]; if ((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) == (r1 + r2) * (r1 + r2)) { adj[from].push_back(to); adj[to].push_back(from); } } vi color(n, -1); bool foundOne = false; rep(i, 0, n) if (color[i] == -1) { ll count0 = 1, count1 = 0; color[i] = 0; queue todo; for(todo.push(i); sz(todo); todo.pop()) { ll v = todo.front(); for(auto u : adj[v]) { if (color[u] == color[v]) { cout << "NO" << endl; return; } if (color[u] == -1) { if (color[v] == 1) { count0++; color[u] = 0; } else { count1++; color[u] = 1; } todo.push(u); } } } if (count0 != count1) { foundOne = true; } } if (foundOne) { cout << "YES" << endl; } else { cout << "NO" << endl; } } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); //ll t; cin >> t; while(t--) solve(); }