#ifdef __LOCAL #include // プリコンパイル済みヘッダ ~/local/include/mytemplate.hpp.gch #else #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #endif #pragma GCC target "no-avx" // gcc12.2のバグ回避用。少し実行速度が落ちる using namespace std; #include using bint = boost::multiprecision::cpp_int; using int128 = __int128_t; using ll = long long; using vl = vector; using vvl = vector; using vb = vector; using vvb = vector; using vd = vector; using vvd = vector; using vc = vector; using vvc = vector; using pll = pair; #define REP1(i, n) REP3(i, 0, n, 1) #define REP2(i, s, n) REP3(i, s, n, 1) #define REP3(i, s, n, d) for(ll i = (ll)(s); i < (ll)(n); i += (d)) #define REP_OVERLOAD(e1, e2, e3, e4, NAME,...) NAME #define rep(...) REP_OVERLOAD(__VA_ARGS__, REP3, REP2, REP1)(__VA_ARGS__) #define DEP1(i, n) DEP3(i, n, -1, 1) #define DEP2(i, n, s) DEP3(i, n, s, 1) #define DEP3(i, n, s, d) for(ll i = (ll)(n); (ll)(s) < i; i -= (d)) #define DEP_OVERLOAD(e1, e2, e3, e4, NAME,...) NAME #define dep(...) DEP_OVERLOAD(__VA_ARGS__, DEP3, DEP2, DEP1)(__VA_ARGS__) #define fore(e, a) for (auto&& e: (a)) #define len(a) (ll)(a).size() #define all(a) (a).begin(), (a).end() #define rall(a) (a).rbegin(), (a).rend() #define pb push_back #define eb emplace_back #define fi first #define se second #define th third /********* C O N S T A N T **********/ constexpr ll INF = LONG_LONG_MAX / 2 - 10000LL; // 4,611,686,018,427,377,903 ~= 4.6e+18, 19桁 const double PI = acos(-1); /********* P A I R **********/ template inline pair& operator+=(pair& a, const pair b); template inline pair& operator-=(pair& a, const pair b); template inline pair& operator*=(pair& a, const pair b); template inline pair& operator/=(pair& a, const pair b); template inline pair& operator%=(pair& a, const pair b); template inline pair& operator+=(pair& a, const V b); template inline pair& operator-=(pair& a, const V b); template inline pair& operator*=(pair& a, const V b); template inline pair& operator/=(pair& a, const V b); template inline pair& operator%=(pair& a, const V b); template inline pair operator+(pair a, const V& b); template inline pair operator-(pair a, const V& b); template inline pair operator*(pair a, const V& b); template inline pair operator/(pair a, const V& b); template inline pair operator%(pair a, const V& b); template inline pair operator+(pair a); template inline pair operator-(pair a); template istream& operator >>(istream& stream, pair& a); template ostream& operator <<(ostream &stream, const pair& a); /********* V E C T O R **********/ template inline vector& operator+=(vector& a, const vector b); template inline vector& operator-=(vector& a, const vector b); template inline vector& operator*=(vector& a, const vector b); template inline vector& operator/=(vector& a, const vector b); template inline vector& operator%=(vector& a, const vector b); template inline vector& operator+=(vector& a, const U b); template inline vector& operator-=(vector& a, const U b); template inline vector& operator*=(vector& a, const U b); template inline vector& operator/=(vector& a, const U b); template inline vector& operator%=(vector& a, const U b); template inline vector operator+(vector a, const U& b); template inline vector operator-(vector a, const U& b); template inline vector operator*(vector a, const U& b); template inline vector operator/(vector a, const U& b); template inline vector operator%(vector a, const U& b); template inline vector operator+(vector a); template inline vector operator-(vector a); template istream& operator >>(istream& stream, vector& a); template ostream& operator <<(ostream& stream, const vector& v); template ostream& operator <<(ostream& stream, const vector>& vv); template inline T Sum(const vector& v) {return reduce(all(v));} // v.size() == 0 のとき T() を返す template inline T Max(const vector& v) {assert(v.size()); return *max_element(all(v));} template inline T Min(const vector& v) {assert(v.size()); return *min_element(all(v));} template inline ll Argmax(const vector& v) {assert(v.size()); return max_element(all(v)) - v.begin();} template inline ll Argmin(const vector& v) {assert(v.size()); return min_element(all(v)) - v.begin();} template inline bool Contains(const vector& v, const U& a) {return find(all(v), a) != v.end();} template inline void Unique(vector& v) {sort(all(v)); v.erase(unique(all(v)), v.end());} // ソートされたユニーク値のvectorに書き換える, O(NlogN). template vector make_vector(int n, U v) { return vector(n, v); } template auto make_vector(int n, Args... args) {auto val = make_vector(args...); return make_vector(n, move(val));} /********* S E T **********/ template istream& operator >>(istream& stream, set& st); template ostream& operator <<(ostream& stream, const set& st); template inline T Max(const set& st) {assert(st.size()); return *prev(st.end());} template inline T Min(const set& st) {assert(st.size()); return *st.begin();} /********* M U L T I S E T **********/ template istream& operator >>(istream& stream, multiset& st); template ostream& operator <<(ostream& stream, const multiset& st); template inline T Max(const multiset& st) {assert(st.size()); return *prev(st.end());} template inline T Min(const multiset& st) {assert(st.size()); return *st.begin();} template inline bool EraseOne(multiset& st, T x) {auto it=st.find(x); if (it!=st.end()) {st.erase(it); return true;} else return false;} // 要素xを1つ削除. 消せたらtrueを返す. /********* S T R I N G **********/ inline string ToUpper(const string& s) {string t; t.resize(s.size()); std::transform(all(s), t.begin(), ::toupper); return t; } inline string ToLower(const string& s) {string t; t.resize(s.size()); std::transform(all(s), t.begin(), ::tolower); return t; } inline char ToUpper(const char& c) {string s{c}, t; t.resize(s.size()); std::transform(all(s), t.begin(), ::toupper); return t[0]; } inline char ToLower(const char& c) {string s{c}, t; t.resize(s.size()); std::transform(all(s), t.begin(), ::tolower); return t[0]; } /********* T R I O **********/ template struct trio { T1 first; T2 second; T3 third; // コンストラクタ・代入演算子 trio() {first=T1(); second=T2(); third=T3();} trio(const T1& x) : first(x), second(x), third(x) {} trio(const T1& x, const T2& y, const T3& z) : first(x), second(y), third(z) {} trio(const trio& t) {first=t.first; second=t.second; third=t.third;} // コピーコンストラクタ trio& operator =(const trio& t) {first=t.first; second=t.second; third=t.third; return *this;} // 比較演算子 auto operator <=>(const trio&) const = default; // 単項演算子(+ -) trio operator +() const { return *this; } trio operator -() const { return (-1) * (*this); } // 複合代入演算子 trio& operator +=(const trio& t) {first += t.first; second += t.second; third += t.third; return *this;} trio& operator -=(const trio& t) {first -= t.first; second -= t.second; third -= t.third; return *this;} trio& operator *=(const trio& t) {first *= t.first; second *= t.second; third *= t.third; return *this;} trio& operator /=(const trio& t) {first /= t.first; second /= t.second; third /= t.third; return *this;} trio& operator %=(const trio& t) {first %= t.first; second %= t.second; third %= t.third; return *this;} // 算術演算子 friend trio operator +(const trio& lhs, const trio& rhs) {return trio(lhs) += rhs;} friend trio operator -(const trio& lhs, const trio& rhs) {return trio(lhs) -= rhs;} friend trio operator *(const trio& lhs, const trio& rhs) {return trio(lhs) *= rhs;} friend trio operator /(const trio& lhs, const trio& rhs) {return trio(lhs) /= rhs;} friend trio operator %(const trio& lhs, const trio& rhs) {return trio(lhs) %= rhs;} // 入出力 template friend istream& operator >>(istream&, trio&); template friend ostream& operator <<(ostream&, const trio&); operator tuple() {return tie(first, second, third);} }; using tll = trio; /********* R A N D O M **********/ struct Random { mt19937_64 rnd; Random() { random_device seed_gen; rnd.seed(seed_gen()); } ll randint(ll a, ll b) { // [a, b] uniform_int_distribution dist(a, b); return dist(rnd); } double randreal(double a, double b) { uniform_real_distribution dist(a, b); return dist(rnd); } char randchar(char a, char b) { // [a, b] uniform_int_distribution dist(a, b); return dist(rnd); } }; /********* P R I N T **********/ template inline void print(const T& e); template inline void print(const H& h, const T&... t); template inline void End(const T&... t); /********* D E B U G **********/ #ifdef __LOCAL #define debug(...) if(DEBUG) do{cout << '[' << #__VA_ARGS__ << "] ";debug_(__VA_ARGS__);}while(0) #else #define debug(...) #endif void dbg_(const long long& e); template void dbg_(const T& e); template void dbg_(const pair& p); template void dbg_(const trio& t); template void debug_(const T& e); template void debug_(const vector& v); template void debug_(const vector>& vv); template void debug_(const map& mp); template void debug_(const vector>& vm); template void debug_(const set& st); template void debug_(const multiset& st); template void debug_(const vector>& vs); template void debug_(const vector>& vs); template void debug_(const H& h, const T&... t); /********* O T H E R S **********/ template inline bool chmin(T& a, U b) {if (a > b) {a = b; return true;} return false;} // bは値渡し! template inline bool chmax(T& a, U b) {if (a < b) {a = b; return true;} return false;} template inline auto Mod(const T& a, const U& m) {return (a % m + m) % m;} // 負もOK template inline auto Ceil(const T& x, const U& y) {return x < 0 ? x/y : (x + y - 1) / y;} // 負もOK template inline auto Floor(const T& x, const U& y) {return -(Ceil(-x, y)); } // 負もOK inline ll Isqrt(ll n) {assert(n >= 0); ll x = round(sqrt(n)); while(x * x > n) --x; return x;} inline ll Comb(ll n, ll r) {if (r < 0 || n < r) return 0; r = min(r, n - r); ll ret = 1; rep(i, r) {ret *= n - i; ret /= i + 1;} return ret;} // n=60, r=30までOK template inline T Pow(T x, ll n) {assert(n >= 0); T ret = 1; while(1) {if (n % 2) ret *= x; n /= 2; if(!n) return ret; x = x * x;}} // べき乗 mintもOK template inline T Aseries(T a, T d, ll n) {assert(n >= 0); return a * n + n * (n - 1) / 2 * d;} // 等差級数 mintもOK template inline T Gseries(T a, T r, ll n) {assert(n >= 0); if (r == 1) return a * n; else return a * (1 - Pow(r, n)) / (1 - r);} // 等比級数 mintもOK template using min_priority_queue = priority_queue, greater>; inline bool Bit(ll b, int i) {assert(0 <= i && i < 64); return (b >> i) & 1;} inline ll Popcount(ll b) {return __builtin_popcountll(b);} inline ll Mask(ll n) {assert(0 <= n && n < 63); return (1LL << n) - 1LL;} // [0, n)のbitが立った64bit整数を返す。 inline ll Mask(ll n, ll m) {assert(n >= m); return Mask(n) ^ Mask(m);} // [m, n)のbitが立った64bit整数を返す。 inline void PrintYesNo(bool b) {b ? print("Yes") : print("No");} /********* M O D **********/ // #include // https://atcoder.github.io/ac-library/production/document_ja/ // using namespace atcoder; // using mint = modint998244353; // modint1000000007; // istream& operator >>(istream& stream, mint& e) {ll n; stream >> n; e = n; return stream; } // ostream& operator <<(ostream& stream, const mint& e) { stream << e.val(); return stream; } // using vm = vector; // using vvm = vector; /***************************************/ constexpr bool DEBUG = true; /************** デ カ ル ト 座 標 構 造 体 **************/ template struct Point { T x, y; // コンストラクタ・代入演算子 Point() { x = T(); y = T(); } Point(const T& x_) : x(x_), y(x_) { } Point(const T& x_, const T& y_) : x(x_), y(y_) { } Point(const pair p) : x(p.first), y(p.second) {} Point (const Point& p) { x = p.x; y = p.y; } // コピーコンストラクタ Point& operator =(const Point& p) { x = p.x; y = p.y; return *this; } // // 比較演算子(Pairと同じ) bool operator <(const Point& other) const { if (x < other.x) return true; else if (x == other.x && y < other.y) return true; else return false; } // 単項演算子(+ -) Point operator +() const { return *this; } Point operator -() const { return Point(-x, -y); } // 複合代入演算子 Point& operator +=(const Point& p) { x += p.x; y += p.y; return *this; } Point& operator -=(const Point& p) { x -= p.x; y -= p.y; return *this; } Point& operator *=(const Point& p) { x *= p.x; y *= p.y; return *this; } Point& operator /=(const Point& p) { x /= p.x; y /= p.y; return *this; } Point& operator %=(const Point& p) { x %= p.x; y %= p.y; return *this; } // 算術演算子(+ - * /) friend Point operator +(const Point& lhs, const Point& rhs) { return Point(lhs) += rhs; } friend Point operator -(const Point& lhs, const Point& rhs) { return Point(lhs) -= rhs; } friend Point operator *(const Point& lhs, const Point& rhs) { return Point(lhs) *= rhs; } friend Point operator /(const Point& lhs, const Point& rhs) { return Point(lhs) /= rhs; } friend Point operator %(const Point& lhs, const Point& rhs) { return Point(lhs) %= rhs; } // // 二乗 (x^2, y^2) Point sq() const { return Point(x * x, y * y); } // 絶対値 (|x|, |y|) Point abs() const { return Point(std::abs(x), std::abs(y)); } // 大きさの二乗 x^2 + y^2 T mag2() const { return x * x + y * y; } // // 入出力、型変換 friend istream& operator >>(istream &stream, Point& p) {return stream >> p.x >> p.y; } friend ostream& operator <<(ostream &stream, const Point& p) {return stream << p.x << ' ' << p.y; } template operator pair() const { pair p{x, y}; return p; } }; // 内積 x1x2 + y1y2 template T Dot(const Point& p1, const Point& p2) { return p1.x * p2.x + p1.y * p2.y; } // クロス積 x1y2 - x2y1 template T Cross(const Point& p1, const Point& p2) { return p1.x * p2.y - p2.x * p1.y; } // 距離の二乗 (x2-x1)^2 + (y2-y1)^2 template T Dist2(const Point& p1, const Point& p2) { return (p2 - p1).mag2(); } // p1ベクトルに対するp2ベクトルのなす角[0, 2π) template T Angle(const Point& p1, const Point& p2) { T cos = Dot(p1, p2) / sqrt(p1.mag2() * p2.mag2()); T theta = acos(cos); if (Cross(p1, p2) >= 0) return theta; else return 2 * acos((T)(-1)) - theta; } // pベクトルの偏角 [0, 2π) template T Angle(const Point& p) { return Angle(Point(1, 0), p); } // pベクトルを theta [rad]回転 template Point Rotate(const Point& p, T theta) { T x = cos(theta) * p.x - sin(theta) * p.y; T y = sin(theta) * p.x + cos(theta) * p.y; return Point(x, y); } // rad -> deg template T Degrees(T rad) { return rad / acos((T)(-1)) * 180; } // deg -> rad template T Radians(T deg) { return acos((T)(-1)) * deg / 180; } // ベクトルpに対してqのなす角θが 0° < θ < 90° を満たすか template bool Acute(const Point& p, const Point& q) {return (Dot(p, q) > 0) && (Cross(p, q) > 0);} // ベクトルpに対してqのなす角θが θ = 90° を満たすか template bool Deg90(const Point& p, const Point& q) {return (Dot(p, q) == 0) && (Cross(p, q) > 0);} // ベクトルのなす角のうち小さい方(2: 0°, 1: 鋭角, 0: 直角, -1:, 鈍角, -2: 180°) template ll TypeOfAngle(const Point& p1, const Point& p2) { if (Dot(p1, p2) > 0) return Cross(p1, p2) == 0 ? 2 : 1; else if (Dot(p1, p2) == 0) return 0; else return Cross(p1, p2) == 0 ? -2 : -1; } // 偏角による比較関数. 原点(0, 0)は不可. Arg(p1) < Arg(p2)ならtrue. template bool CompareByArg(const Point& p1, const Point& p2) { assert((p1.x != 0 || p1.y != 0) && (p2.x != 0 || p2.y != 0)); if (Cross(p1, p2) == 0 && Dot(p1, p2) > 0) { // なす角が0°のとき、ソート結果を一意にするためベクトルの大きさで比較する return p1.mag2() < p2.mag2(); } else { auto& [x1, y1] = p1; auto& [x2, y2] = p2; if (y1 == 0 && y2 == 0) return x1 > 0 && x2 < 0; // p1が0°, p2が180°でtrue else if (y1 >= 0 && y2 < 0) return true; // p1 <= 180° < p2 else if (y1 < 0 && y2 >= 0) return false; // p2 <= 180° < p1 else return x1 * y2 > x2 * y1; // p1, p2 <= 180° or 180° < p1, p2 } } // 凸多角形かどうか template bool IsConvex(const vector>& vec) { ll n = vec.size(); for(ll i = 0; i < n; i++) { ll j = (i + 1) % n; ll k = (i - 1 + n) % n; if (Cross(vec[j] - vec[i], vec[k] - vec[i]) <= 0) return false; } return true; } // 分数構造体 // 利用可能演算子:+ - * / == != < > <= >= // 利用可能関数:sq(), inv(), abs(), val() // Examples: // Rational r(-6, 20); // -6/20 = -3/10 // Rational s(4, 30); // 4/30 = 2/15 // cout << ((r + s) * 2 / 3) << endl; // (-3/10 + 2/15) * 2 / 3 = -1/9 // cout << s.val() << endl; // 2/15 = 0.1333333333 template struct Rational { private: T num, den; // 分子, 分母 public: T get_num() { return num; } T get_den() { return den; } // コンストラクタ Rational() { num = 0; den = 1; } Rational(const T& num_) { num = num_; den = 1; } Rational(const Rational& r) {num = r.num; den = r.den; } // コピーコンストラクタ Rational(const T& num_, const T& den_) { assert(num_ != 0 || den_ != 0); if (num_ == 0) { num = 0; den = 1; } else { // 分母 > 0にする & 約分する T sign = den_ < 0 ? -1 : 1; T g = gcd(num_, den_); num = sign * num_ / g; den = sign * den_ / g; } } // 代入演算子 Rational& operator =(const Rational& other) { num = other.num; den = other.den; return *this; } // 比較演算子(== != < > <= >=) bool operator <(const Rational& other) const { T num2 = other.num; T den2 = other.den; if (*this == other) { // 両辺が(+/-infも含めて)同一のとき return false; } else if ((num == -1 && den == 0) || (other.num == 1 && other.den == 0)) { // 左辺が-inf か、右辺が+inf return true; } else if ((num == 1 && den == 0) || (other.num == -1 && other.den == 0)) { // 左辺が+infか、右辺が-inf return false; } else { return num * den2 < num2 * den; } } bool operator ==(const Rational& other) const { return (num == other.num) && (den == other.den); } bool operator !=(const Rational& other) const { return !(*this == other); } bool operator >(const Rational& other) const { return !(*this < other) && (*this != other); } bool operator <=(const Rational& other) const { return !(*this > other); } bool operator >=(const Rational& other) const { return !(*this < other); } // 単項演算子(+ -) Rational operator +() const { return *this; } Rational operator -() const { return Rational(-num, den); } // 算術演算子(+ - * /) Rational operator +(const Rational& other) const { T num2 = other.num; T den2 = other.den; // (マイナス)無限大との和の返り値は(マイナス)無限大 // ただし無限大とマイナス無限大の和は未定義 if (den == 0) { return Rational(num, 0); } else if (den2 == 0) { return Rational(num2, 0); } T num_ans = num * den2 + num2 * den; T den_ans = den * den2; return Rational(num_ans, den_ans); } Rational operator -(const Rational& other) const { return *this + (-other); } Rational operator *(const Rational& other) const { return Rational(num * other.num, den * other.den); } // ゼロ * infはエラー Rational operator /(const Rational& other) const { return *this * other.inv(); } // 二乗、絶対値、逆数 Rational sq() const { return Rational(num * num, den * den); } Rational abs() const { if (num < 0) return Rational(-num, den); else return *this; } Rational inv() const { return Rational(den, num); } // double型に変換 double val() const { return (double)num / (double)den; } // 入出力。参考:https://stackoverflow.com/questions/4039817/friend-declaration-declares-a-non-template-function template friend istream& operator >>(istream&, Rational&); // 入力時はインスタンスを生成 & 変更するのでconstをつけない template friend ostream& operator <<(ostream&, const Rational&); // 出力時は変更しないのでconstをつける // 整数型との演算 template Rational operator +(const U& x) const { return *this + Rational((T)x); } template Rational operator -(const U& x) const { return *this - Rational((T)x); } template Rational operator *(const U& x) const { return *this * Rational((T)x); } template Rational operator /(const U& x) const { return *this / Rational((T)x); } }; template istream& operator >>(istream &stream, Rational& r) { stream >> r.num; return stream; } template ostream& operator <<(ostream &stream, const Rational& r) { stream << r.num << '/' << r.den; return stream; } template Rational operator +(const U& x, const Rational& r) { return Rational((T)x) + r; } template Rational operator -(const U& x, const Rational& r) { return Rational((T)x) - r; } template Rational operator *(const U& x, const Rational& r) { return Rational((T)x) * r; } template Rational operator /(const U& x, const Rational& r) { return Rational((T)x) / r; } using R = Rational; // using R = long double; int main() { cin.tie(nullptr); cout << fixed << setprecision(10); ll Q; cin >> Q; vector> P(3); cin >> P; sort(all(P)); // auto a1 = Rational(P[1].y - P[0].y, P[1].x - P[0].x); // auto a2 = Rational(P[2].y - P[0].y, P[2].x - P[0].x); auto a1 = (P[1].y - P[0].y) / (P[1].x - P[0].x); auto a2 = (P[2].y - P[0].y) / (P[2].x - P[0].x); // ll a1 = 1; // ll a2 = 3; if (a1.abs() == a2.abs()) { auto C = Point((P[0].x + P[2].x) / 2, (P[0].y + P[2].y) / 2); R d2 = (C.x - P[0].x).sq() + (C.y - P[0].y).sq(); rep(q, Q) { Point pt; cin >> pt; R d = (C.x - pt.x).sq() + (C.y - pt.y).sq(); if (d <= d2) print("Yes"); else print("No"); } } else { vector X(2), Y(2); vector A(2); ll cnt = 0; rep(i1, 3) { if (cnt == 2) break; ll i2 = (i1 + 1) % 3; auto [x1, y1] = P[i1]; auto [x2, y2] = P[i2]; if (y1 == y2) continue; A[cnt] = -(x2 - x1) / (y2 - y1); X[cnt] = (x1 + x2) / 2; Y[cnt] = (y1 + y2) / 2; cnt++; } assert(cnt == 2); R cx = (-Y[0] + Y[1] + A[0] * X[0] - A[1] * X[1]) / (A[0] - A[1]); R cy = A[0] * (cx - X[0]) + Y[0]; auto C = Point(cx, cy); R d2 = (C.x - P[0].x).sq() + (C.y - P[0].y).sq(); rep(q, Q) { Point pt; cin >> pt; R d = (C.x - pt.x).sq() + (C.y - pt.y).sq(); if (d <= d2) print("Yes"); else print("No"); } } } /********* P A I R **********/ template inline pair& operator+=(pair& a, const pair b) {a.fi += b.fi; a.se += b.se; return a;} template inline pair& operator-=(pair& a, const pair b) {a.fi -= b.fi; a.se -= b.se; return a;} template inline pair& operator*=(pair& a, const pair b) {a.fi *= b.fi; a.se *= b.se; return a;} template inline pair& operator/=(pair& a, const pair b) {a.fi /= b.fi; a.se /= b.se; return a;} template inline pair& operator%=(pair& a, const pair b) {a.fi %= b.fi; a.se %= b.se; return a;} template inline pair& operator+=(pair& a, const V b) {a.fi += b; a.se += b; return a;} template inline pair& operator-=(pair& a, const V b) {a.fi -= b; a.se -= b; return a;} template inline pair& operator*=(pair& a, const V b) {a.fi *= b; a.se *= b; return a;} template inline pair& operator/=(pair& a, const V b) {a.fi /= b; a.se /= b; return a;} template inline pair& operator%=(pair& a, const V b) {a.fi %= b; a.se %= b; return a;} template inline pair operator+(pair a, const V& b) {a += b; return a;} template inline pair operator-(pair a, const V& b) {a -= b; return a;} template inline pair operator*(pair a, const V& b) {a *= b; return a;} template inline pair operator/(pair a, const V& b) {a /= b; return a;} template inline pair operator%(pair a, const V& b) {a %= b; return a;} template inline pair operator+(pair a) {return a;} template inline pair operator-(pair a) {return a * (-1);} template istream& operator >>(istream& stream, pair& a) {stream >> a.fi >> a.se; return stream;} template ostream& operator <<(ostream &stream, const pair& a) { stream << a.fi << " " << a.se; return stream; } /********* V E C T O R **********/ template inline vector& operator+=(vector& a, const vector b) {assert(a.size() == b.size()); rep(i, 0, a.size()) a[i] += b[i]; return a;} template inline vector& operator-=(vector& a, const vector b) {assert(a.size() == b.size()); rep(i, 0, a.size()) a[i] -= b[i]; return a;} template inline vector& operator*=(vector& a, const vector b) {assert(a.size() == b.size()); rep(i, 0, a.size()) a[i] *= b[i]; return a;} template inline vector& operator/=(vector& a, const vector b) {assert(a.size() == b.size()); rep(i, 0, a.size()) a[i] /= b[i]; return a;} template inline vector& operator%=(vector& a, const vector b) {assert(a.size() == b.size()); rep(i, 0, a.size()) a[i] %= b[i]; return a;} template inline vector& operator+=(vector& a, const U b) {fore(e, a) e += b; return a;} template inline vector& operator-=(vector& a, const U b) {fore(e, a) e -= b; return a;} template inline vector& operator*=(vector& a, const U b) {fore(e, a) e *= b; return a;} template inline vector& operator/=(vector& a, const U b) {fore(e, a) e /= b; return a;} template inline vector& operator%=(vector& a, const U b) {fore(e, a) e %= b; return a;} template inline vector operator+(vector a, const U& b) {a += b; return a;} template inline vector operator-(vector a, const U& b) {a -= b; return a;} template inline vector operator*(vector a, const U& b) {a *= b; return a;} template inline vector operator/(vector a, const U& b) {a /= b; return a;} template inline vector operator%(vector a, const U& b) {a %= b; return a;} template inline vector operator+(vector a) {return a;} template inline vector operator-(vector a) {return a * (-1);} template istream& operator >>(istream& stream, vector& a) {fore(e, a) stream >> e; return stream;} template ostream& operator <<(ostream& stream, const vector& v) {if(v.size()){stream << v[0]; rep(i, 1, v.size()) cout << " " << v[i];} return stream;} template ostream& operator <<(ostream& stream, const vector>& vv) {if(vv.size()){stream << vv[0]; rep(i, 1, vv.size()) cout << '\n' << vv[i];} return stream;} /********* S E T **********/ template istream& operator >>(istream& stream, set& st) {T e; stream >> e; st.insert(e); return stream;} template ostream& operator <<(ostream& stream, const set& st) {if(st.size()){auto it=st.begin(); stream << *it++; for(; it!=st.end(); it++) cout << " " << *it;} return stream;} /********* M U L T I S E T **********/ template istream& operator >>(istream& stream, multiset& st) {T e; stream >> e; st.insert(e); return stream;} template ostream& operator <<(ostream& stream, const multiset& st) {if(st.size()){auto it=st.begin(); stream << *it++; for(; it!=st.end(); it++) cout << " " << *it;} return stream;} /********* P R I N T **********/ template inline void print(const T& e) {cout << e << '\n';} template inline void print(const H& h, const T&... t) {cout << h << ' '; print(t...);} template inline void End(const T&... t) {print(t...); exit(0);} /********* D E B U G **********/ void dbg_(const long long& e) {if (e == INF) cout << "INF"; else if (e == -INF) cout << "-INF"; else cout << e;} template void dbg_(const T& e) {cout << e;} template void dbg_(const pair& p) {cout << '('; dbg_(p.first); cout << ' '; dbg_(p.second); cout << ')';} template void dbg_(const trio& t) {cout << '('; dbg_(t.first); cout << ' '; dbg_(t.second); cout << ' '; dbg_(t.third); cout << ')';} template void debug_(const T& e) {dbg_(e); cout << '\n';} template void debug_(const vector& v) {if (v.size()){auto it=v.begin(); dbg_(*it++); for(; it!=v.end(); ++it){cout << ' '; dbg_(*it);}} cout << '\n';} template void debug_(const vector>& vv) {cout << '\n'; ll cnt=0; for(auto&& v : vv){cout << cnt++ << ": "; debug_(v);}} template void debug_(const map& mp) {if (mp.size()) {auto it = mp.begin(); dbg_(*it++); for(; it != mp.end(); ++it) {cout << ' '; dbg_(*it);}} cout << '\n';} template void debug_(const vector>& vm){cout << '\n'; ll cnt=0; for(auto&& mp : vm){cout << cnt++ << ": "; debug_(mp);}} template void debug_(const set& st) {if(st.size()){auto it=st.begin(); dbg_(*it++); for(; it!=st.end(); ++it) {cout << ' '; dbg_(*it);}}cout << '\n';} template void debug_(const multiset& st) {if(st.size()) {auto it=st.begin(); dbg_(*it++); for(; it != st.end(); ++it) {cout << ' '; dbg_(*it);}} cout << '\n';} template void debug_(const vector>& vs) {cout << '\n'; ll cnt=0; for(auto&& st : vs){cout << cnt++ << ": "; debug_(st);}} template void debug_(const vector>& vs) {cout << '\n'; ll cnt=0;for(auto&& st : vs){cout << cnt++ << ": "; debug_(st);}} template void debug_(const H& h, const T&... t) {dbg_(h); cout << ", "; debug_(t...);} /********* T R I O **********/ template istream& operator >>(istream &stream, trio& t) {return stream >> t.first >> t.second >> t.third;} template ostream& operator <<(ostream &stream, const trio& t) {return stream << t.first << " " << t.second << " " << t.third;}