#include #include using namespace std; struct circle { int x, y, r; }; circle Circles[1005]; bool tangent(circle a, circle b) { long long radi_sum = 1LL * (a.r + b.r) * (a.r + b.r); long long dist = 1LL * (a.x - b.x) * (a.x - b.x) + 1LL * (a.y - b.y) * (a.y - b.y); return radi_sum == dist; } vector graph[1005]; int val[1005]; bool set_value(int nod, int value) { if (val[nod] != 0) { if (val[nod] == value) { return true; } else { return false; } } val[nod] = value; bool ok = true; for (auto el : graph[nod]) { if (!set_value(el, -value)) { ok = false; } } return ok; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { cin >> Circles[i].x >> Circles[i].y >> Circles[i].r; } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (tangent(Circles[i], Circles[j])) { graph[i].push_back(j); graph[j].push_back(i); } } } bool ok = false; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { val[j] = 0; } if (set_value(i, -1)) { int sum = 0; for (int j = 0; j < n; j++) { sum += val[j]; } if (sum < 0) { ok = true; } } } if (ok) { cout <<"YES\n"; } else { cout << "NO\n"; } return 0; }