text: b) return true; return min(l1.a.x, l1.b.x) <= max(l2.a.x, l2.b.x) && min(l2.a.x, l2.b.x) <= max(l1.a.x, l1.b.x) && min(l1.a.y, l1.b.y) <= max(l2.a.y, l2.b.y) && min(l2.a.y, l2.b.y) <= max(l1.a.y, l1.b.y) && sgn(det(l1.a, l2.a, l2.b)) * sgn(det(l1.b, l2.a, l2.b)) <= 0 && sgn(det(l2.a, l1.a, l1.b)) * sgn(det(l2.b, l1.a, l1.b)) <= 0; } inline double dist_sqr(Seg l1, Seg l2) { if (isIntersect(l1, l2)) return 0; else return min(dist_sqr(l1.a, l2), dist_sqr(l1.b, l2), dist_sqr(l2.a, l1), dist_sqr(l2.b, l1)); } inline bool isOnSide(const Po &p, const Seg &l) { return p == l.a || p == l.b; } inline bool isOnSeg(const Po &p, const Seg &l) { return sgn(det(p, l.a, l.b)) == 0 && sgn(l.a.x, p.x) * sgn(l.b.x, p.x) <= 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) <= 0; } inline bool isOnSegg(const Po &p, const Seg &l) { return sgn(det(p, l.a, l.b)) == 0 && sgn(l.a.x, p.x) * sgn(l.b.x, p.x) < 0 && sgn(l.a.y, p.y) * sgn(l.b.y, p.y) < 0; } inline Po intersect(const Line &l1, const Line &l2) { return l1.a + (l1.b - l1.a) * (det(l2.a, l1.a, l2.b) / det(l2, l1)); } inline Po intersect(const Po &p, const Line &l) { return intersect(Line(p, p + Po(l.a.y - l.b.y, l.b.x - l.a.x)), l); } inline Po rotate(Po p, double alpha, Po o = Po()) { p.x -= o.x, p.y -= o.y; return Po(p.x * cos(alpha) - p.y * sin(alpha), p.y * cos(alpha) + p.x * sin(alpha)) + o; } inline int rand32() { return (bool(rand() & 1) << 30) | (rand() << 15) + rand(); } inline int random32(int l, int r) { return rand32() % (r - l + 1) + l; } inline int random(int l, int r) { return rand() % (r - l + 1) + l; } int dice() { return rand() % 6; } bool coin() { return rand() % 2; } template <class T> inline T &RD(T &x) { scanf("%d", &x); return x; } int ____Case; template <class T> inline void OT(const T &x) { cout << x << endl; } const int N = 2e5; set<pair<int, int> > vis; map<pair<int, int>, int> step; queue<pair<int, int> > q; const int dir[][2] = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}}; pair<int, int> st, ed; int n, a, b, r; void solve() { vis.clear(); step.clear(); while (!q.empty()) q.pop(); step[st] = 0; cin >> n; vis.insert(st); vis.