#line 2 "/home/yuruhiya/programming/library/template/template.cpp" #include #line 6 "/home/yuruhiya/programming/library/template/constants.cpp" #define rep(i, n) for (int i = 0; i < (n); ++i) #define FOR(i, m, n) for (int i = (m); i < (n); ++i) #define rrep(i, n) for (int i = (n)-1; i >= 0; --i) #define rfor(i, m, n) for (int i = (m); i >= (n); --i) #define unless(c) if (!(c)) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define range_it(a, l, r) (a).begin() + (l), (a).begin() + (r) using namespace std; using ll = long long; using LD = long double; using VB = vector; using VVB = vector; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using VS = vector; using VD = vector; using PII = pair; using VP = vector; using PLL = pair; using VPL = vector; template using PQ = priority_queue; template using PQS = priority_queue, greater>; constexpr int inf = 1000000000; constexpr long long inf_ll = 1000000000000000000ll, MOD = 1000000007; constexpr long double PI = 3.14159265358979323846, EPS = 1e-12; #line 7 "/home/yuruhiya/programming/library/template/Input.cpp" using namespace std; #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #define putchar_unlocked _putchar_nolock #define fwrite_unlocked fwrite #define fflush_unlocked fflush #endif class Scanner { static int gc() { return getchar_unlocked(); } static char next_char() { char c; read(c); return c; } template static void read(T& v) { cin >> v; } static void read(char& v) { while (isspace(v = gc())) ; } static void read(bool& v) { v = next_char() != '0'; } static void read(string& v) { v.clear(); for (char c = next_char(); !isspace(c); c = gc()) v += c; } static void read(int& v) { v = 0; bool neg = false; char c = next_char(); if (c == '-') { neg = true; c = gc(); } for (; isdigit(c); c = gc()) v = v * 10 + (c - '0'); if (neg) v = -v; } static void read(long long& v) { v = 0; bool neg = false; char c = next_char(); if (c == '-') { neg = true; c = gc(); } for (; isdigit(c); c = gc()) v = v * 10 + (c - '0'); if (neg) v = -v; } static void read(double& v) { v = 0; double dp = 1; bool neg = false, after_dp = false; char c = next_char(); if (c == '-') { neg = true; c = gc(); } for (; isdigit(c) || c == '.'; c = gc()) { if (c == '.') { after_dp = true; } else if (after_dp) { v += (c - '0') * (dp *= 0.1); } else { v = v * 10 + (c - '0'); } } if (neg) v = -v; } static void read(long double& v) { v = 0; long double dp = 1; bool neg = false, after_dp = false; char c = next_char(); if (c == '-') { neg = true; c = gc(); } for (; isdigit(c) || c == '.'; c = gc()) { if (c == '.') { after_dp = true; } else if (after_dp) { v += (c - '0') * (dp *= 0.1); } else { v = v * 10 + (c - '0'); } } if (neg) v = -v; } template static void read(pair& v) { read(v.first); read(v.second); } template static void read(vector& v) { for (auto& e : v) read(e); } template static void read_tuple_impl(T& v) { if constexpr (N < tuple_size_v) { read(get(v)); read_tuple_impl(v); } } template static void read(tuple& v) { read_tuple_impl(v); } struct ReadVectorHelper { size_t n; ReadVectorHelper(size_t _n) : n(_n) {} template operator vector() { vector v(n); read(v); return v; } }; struct Read2DVectorHelper { size_t n, m; Read2DVectorHelper(const pair& nm) : n(nm.first), m(nm.second) {} template operator vector>() { vector> v(n, vector(m)); read(v); return v; } }; public: string read_line() const { string v; for (char c = gc(); c != '\n' && c != '\0'; c = gc()) v += c; return v; } template T read() const { T v; read(v); return v; } template vector read_vector(size_t n) const { vector a(n); read(a); return a; } template operator T() const { return read(); } int operator--(int) const { return read() - 1; } ReadVectorHelper operator[](size_t n) const { return ReadVectorHelper(n); } Read2DVectorHelper operator[](const pair& nm) const { return Read2DVectorHelper(nm); } void operator()() const {} template void operator()(H&& h, T&&... t) const { read(h); operator()(forward(t)...); } private: template