#include using namespace std; #define int long long #define rep(i,a,b) for (int i = (a); i < (b);++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; #define cerr if(false) cerr signed main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); int n; cin >> n; vi xs(n); vi ys(n); vi rs(n); vector nbs(n); rep(i,0,n) cin >> xs[i] >> ys[i] >> rs[i]; rep(i,0,n) rep(j,i+1,n) { int ydiff = abs(ys[i]-ys[j]); int xdiff = abs(xs[i]-xs[j]); int rsum = rs[i] + rs[j]; if (rsum * rsum == xdiff * xdiff + ydiff * ydiff) { nbs[i].push_back(j); nbs[j].push_back(i); } } rep(i,0,n) { cerr << "===" << i << ":" << endl; for(auto j : nbs[i]) { cerr << j << " "; } cerr << endl; } vi colors(n); vi comps(n); vi invalid(n); rep(i,0,n) { if (colors[i]) continue; cerr << "got" << i << endl; cerr << colors[i]; queue q; q.push({i,1}); while(!q.empty()) { auto blah = q.front(); int j = blah.first; int c = blah.second; cerr << j << " " << c << " " << colors[j] << endl; q.pop(); if (colors[j] != 0) { if (colors[j] != c) { invalid[i] = 1; } continue; } colors[j] = c; comps[i] += c; for (auto nb : nbs[j]) { q.push({nb, -1 * c}); } } } rep(i,0,n) { cerr << i << " comps:" << comps[i] << " inv:" << invalid[i] << " col:" << colors[i] << endl; } string ans = "NO"; rep(i,0,n) { if (!invalid[i] && comps[i]) ans = "YES\n"; } cout << ans << endl; return 0; }