You are given a graph with $$$3 \cdot n$$$ vertices and $$$m$$$ edges. You are to find a matching of $$$n$$$ edges, or an independent set of $$$n$$$ vertices.A set of edges is called a matching if no two edges share an endpoint.A set of vertices is called an independent set if no two vertices are connected with an edge.

The first line contains a single integer $$$T \ge 1$$$ — the number of graphs you need to process. The description of $$$T$$$ graphs follows. The first line of description of a single graph contains two integers $$$n$$$ and $$$m$$$, where $$$3 \cdot n$$$ is the number of vertices, and $$$m$$$ is the number of edges in the graph ($$$1 \leq n \leq 10^{5}$$$, $$$0 \leq m \leq 5 \cdot 10^{5}$$$). Each of the next $$$m$$$ lines contains two integers $$$v_i$$$ and $$$u_i$$$ ($$$1 \leq v_i, u_i \leq 3 \cdot n$$$), meaning that there is an edge between vertices $$$v_i$$$ and $$$u_i$$$. It is guaranteed that there are no self-loops and no multiple edges in the graph. It is guaranteed that the sum of all $$$n$$$ over all graphs in a single test does not exceed $$$10^{5}$$$, and the sum of all $$$m$$$ over all graphs in a single test does not exceed $$$5 \cdot 10^{5}$$$.

Print your answer for each of the $$$T$$$ graphs. Output your answer for a single graph in the following format. If you found a matching of size $$$n$$$, on the first line print "Matching" (without quotes), and on the second line print $$$n$$$ integers — the indices of the edges in the matching. The edges are numbered from $$$1$$$ to $$$m$$$ in the input order. If you found an independent set of size $$$n$$$, on the first line print "IndSet" (without quotes), and on the second line print $$$n$$$ integers — the indices of the vertices in the independent set. If there is no matching and no independent set of the specified size, print "Impossible" (without quotes). You can print edges and vertices in any order. If there are several solutions, print any. In particular, if there are both a matching of size $$$n$$$, and an independent set of size $$$n$$$, then you should print exactly one of such matchings or exactly one of such independent sets.

Matching
2
IndSet
1
IndSet
2 4
Matching
1 15

NoteThe first two graphs are same, and there are both a matching of size 1 and an independent set of size 1. Any of these matchings and independent sets is a correct answer.The third graph does not have a matching of size 2, however, there is an independent set of size 2. Moreover, there is an independent set of size 5: 2 3 4 5 6. However such answer is not correct, because you are asked to find an independent set (or matching) of size exactly $$$n$$$.The fourth graph does not have an independent set of size 2, but there is a matching of size 2.

/+ dub.sdl:
    name "C"
    dependency "dunkelheit" version="1.0.1"
+/

import std.stdio, std.algorithm, std.range, std.conv;
// import dkh.foundation, dkh.scanner, dkh.datastructure.segtree;

void solve(Scanner sc) {

    int n, m;
    sc.read(n, m);

    int[] edges;
    int[] used = new int[3 * n];
    foreach (i; 0..m) {
        int a, b;
        sc.read(a, b);
        a--; b--;

        if (edges.length.to!int < n) {
            if (used[a] || used[b]) continue;
            used[a] = used[b] = true;
            edges ~= i + 1;
        }
    }

    if (edges.length == n) {
        writeln("Matching");
        edges.map!(to!string).join(" ").writeln;
    } else {
        writeln("IndSet");
        iota(3 * n).filter!(i => !used[i]).take(n).map!(i => (i + 1).to!string).join(" ").writeln;
    }

}

int main() {
    Scanner sc = new Scanner(stdin);
    scope(exit) assert(!sc.hasNext);

    int t;
    sc.read(t);

    foreach (i; 0..t) {
        solve(sc);
    }
    return 0;
}
/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/datastructure/segtree.d */
// module dkh.datastructure.segtree;

import std.conv : to;
import std.functional : binaryFun;
import std.traits : isInstanceOf;

struct SegTree(alias E, Args...) {
    import std.traits : ReturnType;
    alias Engine = E!Args;
    alias T = Engine.DataType;
    alias L = Engine.LazyType;

    Engine eng;

    this(size_t n) { eng = Engine(n.to!uint); }
    this(T[] first) { eng = Engine(first); }

    @property size_t length() const { return eng.length(); }
    @property size_t opDollar() const { return eng.length(); }

    struct Range {
        Engine* eng;
        size_t start, end;
        @property const(T) sum() {
            return eng.sum(start.to!uint, end.to!uint);
        }
    }
    const(T) opIndex(size_t k) {
        assert(0 <= k && k < eng.length());
        return eng.single(k.to!uint);
    }
    void opIndexAssign(T x, size_t k) {
        assert(0 <= k && k < eng.length());
        eng.singleSet(k.to!uint, x);
    }
    size_t[2] opSlice(size_t dim : 0)(size_t start, size_t end) {
        assert(0 <= start && start <= end && end <= eng.length());
        return [start, end];
    }
    Range opIndex(size_t[2] rng) {
        return Range(&eng, rng[0].to!uint, rng[1].to!uint);
    }
    static if (!is(L == void)) {
        void opIndexOpAssign(string op : "+")(L x, size_t[2] rng) {
            eng.add(rng[0].to!uint, rng[1].to!uint, x);
        }
    }
}

ptrdiff_t binSearchLeft(alias pred, TR)(TR t, ptrdiff_t a, ptrdiff_t b)
if (isInstanceOf!(SegTree, TR)) {
    return TR.Engine.BinSearch!(false, pred)(t.eng, a.to!int, b.to!int);
}

ptrdiff_t binSearchRight(alias pred, TR)(TR t, ptrdiff_t a, ptrdiff_t b)
if (isInstanceOf!(SegTree, TR)) {
    return TR.Engine.BinSearch!(true, pred)(t.eng, a.to!int, b.to!int);
}

alias SimpleSeg(T, alias opTT, T eT, alias Engine = SimpleSegEngine) =
    SegTree!(Engine, T, binaryFun!opTT, eT);

struct SimpleSegEngine(T, alias opTT, T eT) {
    alias DataType = T;
    alias LazyType = void;
    alias BinSearch = binSearchSimple;
    uint n, sz, lg;
    T[] d;
    @property uint length() const {return n;}
    this(uint n) {
        import std.algorithm : each;
        this.n = n;
        if (n == 0) return;
        while ((2^^lg) < n) lg++;
        sz = 2^^lg;
        d = new T[](2*sz);
        d.each!((ref x) => x = eT);
    }
    this(T[] first) {
        import std.conv : to;
        import std.algorithm : each;
        n = first.length.to!uint;
        if (n == 0) return;
        while ((2^^lg) < n) lg++;
        sz = 2^^lg;
        d = new T[](2*sz);
        d.each!((ref x) => x = eT);
        foreach (i; 0..n) {
            d[sz+i] = first[i];
        }
        foreach_reverse (i; 1..sz) {
            update(i);
        }
    }
    pragma(inline):
    void update(uint k) {
        d[k] = opTT(d[2*k], d[2*k+1]);
    }
    T single(uint k) {
        return d[k+sz];
    }
    void singleSet(uint k, T x) {
        k += sz;
        d[k] = x;
        foreach (uint i; 1..lg+1) {
            update(k>>i);
        }
    }
    T sum(uint a, uint b) {
        assert(0 <= a && a <= b && b <= n);
        T sml = eT, smr = eT;
        a += sz; b += sz;
        while (a < b) {
            if (a & 1) sml = opTT(sml, d[a++]);
            if (b & 1) smr = opTT(d[--b], smr);
            a >>= 1; b >>= 1;
        }
        return opTT(sml, smr);
    }
}

int binSearchSimple(bool rev, alias pred, TR)(TR t, int a, int b) {
    import std.traits : TemplateArgsOf;
    alias args = TemplateArgsOf!TR;
    alias opTT = args[1];
    auto x = args[2];
    with (t) {
        static if (!rev) {

            if (pred(x)) return a-1;
            int pos = a;
            void f(int a, int b, int l, int r, int k) {
                if (b <= l || r <= a) return;
                if (a <= l && r <= b && !pred(opTT(x, d[k]))) {
                    x = opTT(x, d[k]);
                    pos = r;
                    return;
                }
                if (l+1 == r) return;
                int md = (l+r)/2;
                f(a, b, l, md, 2*k);
                if (pos >= md) f(a, b, md, r, 2*k+1);
            }
            f(a, b, 0, sz, 1);
            return pos;
        } else {

            if (pred(x)) return b;
            int pos = b-1;
            void f(int a, int b, int l, int r, int k) {
                if (b <= l || r <= a) return;
                if (a <= l && r <= b && !pred(opTT(x, d[k]))) {
                    x = opTT(d[k], x);
                    pos = l-1;
                    return;
                }
                if (l+1 == r) return;
                int md = (l+r)/2;
                f(a, b, md, r, 2*k+1);
                if (pos < md) f(a, b, l, md, 2*k);
            }
            f(a, b, 0, sz, 1);
            return pos;
        }
    }
}

alias LazySeg(T, L, alias opTT, alias opTL, alias opLL, T eT, L eL, alias Engine = LazySegEngine) =
    SegTree!(Engine, T, L , binaryFun!opTT, binaryFun!opTL, binaryFun!opLL, eT, eL);

struct LazySegEngine(T, L, alias opTT, alias opTL, alias opLL, T eT, L eL) {
    import std.typecons : Tuple;
    alias DataType = T;
    alias LazyType = L;
    alias BinSearch = binSearchLazy;
    alias S = Tuple!(T, "d", L, "lz");
    uint n, sz, lg;
    S[] s;
    this(uint n) {
        import std.conv : to;
        import std.algorithm : each;
        this.n = n;
        uint lg = 0;
        while ((2^^lg) < n) lg++;
        this.lg = lg;
        sz = 2^^lg;
        s = new S[](2*sz);
        s.each!((ref x) => x = S(eT, eL));
    }
    this(T[] first) {
        import std.conv : to;
        import std.algorithm : each;
        n = first.length.to!uint;
        uint lg = 0;
        while ((2^^lg) < n) lg++;
        this.lg = lg;
        sz = 2^^lg;

        s = new S[](2*sz);
        s.each!((ref x) => x = S(eT, eL));
        foreach (i; 0..n) {
            s[sz+i].d = first[i];
        }
        foreach_reverse (i; 1..sz) {
            update(i);
        }
    }
    @property uint length() const { return n; }
    pragma(inline):
    private void lzAdd(uint k, in L x) {
        s[k].lz = opLL(s[k].lz, x);
        s[k].d = opTL(s[k].d, x);
    }
    public void push(uint k) {
        if (s[k].lz == eL) return;
        lzAdd(2*k, s[k].lz);
        lzAdd(2*k+1, s[k].lz);
        s[k].lz = eL;
    }
    private void update(uint k) {
        s[k].d = opTT(s[2*k].d, s[2*k+1].d);
    }
    T single(uint k) {
        k += sz;
        foreach_reverse (uint i; 1..lg+1) {
            push(k>>i);
        }
        return s[k].d;
    }
    void singleSet(uint k, T x) {
        k += sz;
        foreach_reverse (uint i; 1..lg+1) {
            push(k>>i);
        }
        s[k].d = x;
        foreach (uint i; 1..lg+1) {
            update(k>>i);
        }
    }
    T sum(uint a, uint b) {
        assert(0 <= a && a <= b && b <= n);
        if (a == b) return eT;
        a += sz; b--; b += sz;
        uint tlg = lg;
        while (true) {
            uint k = a >> tlg;
            if (a >> tlg != b >> tlg) {
                tlg++;
                break;
            }
            if (((a-1) >> tlg) + 2 == (b+1) >> tlg) return s[k].d;
            push(k);
            tlg--;
        }
        T sm = eT;
        foreach_reverse (l; 0..tlg) {
            uint k = a >> l;
            if ((a-1)>>l != a>>l) {
                sm = opTT(s[k].d, sm);
                break;
            }
            push(k);
            if (!((a >> (l-1)) & 1)) sm = opTT(s[2*k+1].d, sm);
        }
        foreach_reverse (l; 0..tlg) {
            uint k = b >> l;
            if (b>>l != (b+1)>>l) {
                sm = opTT(sm, s[k].d);
                break;
            }
            push(k);
            if ((b >> (l-1)) & 1) sm = opTT(sm, s[2*k].d);
        }
        return sm;
    }
    void add(uint a, uint b, L x) {
        assert(0 <= a && a <= b && b <= n);
        if (a == b) return;
        a += sz; b--; b += sz;
        uint tlg = lg;
        while (true) {
            uint k = a >> tlg;
            if (a >> tlg != b >> tlg) {
                tlg++;
                break;
            }
            if (((a-1) >> tlg) + 2 == (b+1) >> tlg) {
                lzAdd(k, x);
                foreach (l; tlg+1..lg+1) {
                    update(a >> l);
                }
                return;
            }
            push(k);
            tlg--;
        }
        foreach_reverse (l; 0..tlg) {
            uint k = a >> l;
            if ((a-1)>>l != a>>l) {
                lzAdd(k, x);
                foreach (h; l+1..tlg) {
                    update(a >> h);
                }
                break;
            }
            push(k);
            if (!((a >> (l-1)) & 1)) lzAdd(2*k+1, x);
        }
        foreach_reverse (l; 0..tlg) {
            uint k = b >> l;
            if (b>>l != (b+1)>>l) {
                lzAdd(k, x);
                foreach (h; l+1..tlg) {
                    update(b >> h);
                }
                break;
            }
            push(k);
            if ((b >> (l-1)) & 1) lzAdd(2*k, x);
        }
        foreach (l; tlg..lg+1) {
            update(a >> l);
        }
    }
}

int binSearchLazy(bool rev, alias pred, TR)(TR t, int a, int b) {
    import std.traits : TemplateArgsOf;
    alias args = TemplateArgsOf!TR;
    alias opTT = args[2];
    auto x = args[5];
    with (t) {
        static if (!rev) {

            if (pred(x)) return a-1;
            int pos = a;
            void f(int a, int b, int l, int r, int k) {
                if (b <= l || r <= a) return;
                if (a <= l && r <= b && !pred(opTT(x, s[k].d))) {
                    x = opTT(x, s[k].d);
                    pos = r;
                    return;
                }
                if (l+1 == r) return;
                push(k);
                int md = (l+r)/2;
                f(a, b, l, md, 2*k);
                if (pos >= md) f(a, b, md, r, 2*k+1);
            }
            f(a, b, 0, sz, 1);
            return pos;
        } else {

            if (pred(x)) return b;
            int pos = b-1;
            void f(int a, int b, int l, int r, int k) {
                if (b <= l || r <= a) return;
                if (a <= l && r <= b && !pred(opTT(x, s[k].d))) {
                    x = opTT(s[k].d, x);
                    pos = l-1;
                    return;
                }
                if (l+1 == r) return;
                push(k);
                int md = (l+r)/2;
                f(a, b, md, r, 2*k+1);
                if (pos < md) f(a, b, l, md, 2*k);
            }
            f(a, b, 0, sz, 1);
            return pos;
        }
    }
}
/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/container/stackpayload.d */
// module dkh.container.stackpayload;

struct StackPayload(T, size_t MINCAP = 4) if (MINCAP >= 1) {
    import core.exception : RangeError;

    private T* _data;
    private uint len, cap;

    @property bool empty() const { return len == 0; }
    @property size_t length() const { return len; }
    alias opDollar = length;

    inout(T)[] data() inout { return (_data) ? _data[0..len] : null; }

    ref inout(T) opIndex(size_t i) inout {
        version(assert) if (len <= i) throw new RangeError();
        return _data[i];
    }
    ref inout(T) front() inout { return this[0]; }
    ref inout(T) back() inout { return this[$-1]; }

    void reserve(size_t newCap) {
        import core.memory : GC;
        import core.stdc.string : memcpy;
        import std.conv : to;
        if (newCap <= cap) return;
        void* newData = GC.malloc(newCap * T.sizeof);
        cap = newCap.to!uint;
        if (len) memcpy(newData, _data, len * T.sizeof);
        _data = cast(T*)(newData);
    }
    void free() {
        import core.memory : GC;
        GC.free(_data);
    }

    void clear() {
        len = 0;
    }

    void insertBack(T item) {
        import std.algorithm : max;
        if (len == cap) reserve(max(cap * 2, MINCAP));
        _data[len++] = item;
    }
    alias opOpAssign(string op : "~") = insertBack;
    void removeBack() {
        assert(!empty, "StackPayload.removeBack: Stack is empty");
        len--;
    }
}

/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/foundation.d */

// module dkh.foundation;

static if (__VERSION__ <= 2070) {
    /*
    Copied by https://github.com/dlang/phobos/blob/master/std/algorithm/iteration.d
    Copyright: Andrei Alexandrescu 2008-.
    License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0).
    */
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            import std.algorithm : reduce;
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                import std.typecons : tuple;
                return reduce!fun(tuple(seed), r);
            }
        }
    }

}
/* IMPORT /home/yosupo/Programs/dunkelheit/source/dkh/scanner.d */
// module dkh.scanner;

// import dkh.container.stackpayload;

class Scanner {
    import std.stdio : File;
    import std.conv : to;
    import std.range : front, popFront, array, ElementType;
    import std.array : split;
    import std.traits : isSomeChar, isStaticArray, isArray;
    import std.algorithm : map;
    private File f;

    this(File f) {
        this.f = f;
    }
    private char[512] lineBuf;
    private char[] line;
    private bool succW() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (!line.empty && line.front.isWhite) {
            line.popFront;
        }
        return !line.empty;
    }
    private bool succ() {
        import std.range.primitives : empty, front, popFront;
        import std.ascii : isWhite;
        while (true) {
            while (!line.empty && line.front.isWhite) {
                line.popFront;
            }
            if (!line.empty) break;
            line = lineBuf[];
            f.readln(line);
            if (!line.length) return false;
        }
        return true;
    }

    private bool readSingle(T)(ref T x) {
        import std.algorithm : findSplitBefore;
        import std.string : strip;
        import std.conv : parse;
        if (!succ()) return false;
        static if (isArray!T) {
            alias E = ElementType!T;
            static if (isSomeChar!E) {

                auto r = line.findSplitBefore(" ");
                x = r[0].strip.dup;
                line = r[1];
            } else static if (isStaticArray!T) {
                foreach (i; 0..T.length) {
                    assert(succW());
                    x[i] = line.parse!E;
                }
            } else {
                StackPayload!E buf;
                while (succW()) {
                    buf ~= line.parse!E;
                }
                x = buf.data;
            }
        } else {
            x = line.parse!T;
        }
        return true;
    }

    int unsafeRead(T, Args...)(ref T x, auto ref Args args) {
        if (!readSingle(x)) return 0;
        static if (args.length == 0) {
            return 1;
        } else {
            return 1 + read(args);
        }
    }

    void read(Args...)(auto ref Args args) {
        import std.exception : enforce;
        static if (args.length != 0) {
            enforce(readSingle(args[0]));
            read(args[1..$]);
        }
    }

    bool hasNext() {
        return succ();
    }
}

/*
This source code generated by dunkelheit and include dunkelheit's source code.
dunkelheit's Copyright: Copyright (c) 2016- Kohei Morita. (https://github.com/yosupo06/dunkelheit)
dunkelheit's License: MIT License(https://github.com/yosupo06/dunkelheit/blob/master/LICENSE.txt)
*/

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

enum {none = 0, matching = 1, indSet = 2};

void main ()
{
	int tests;
	readf !(" %s") (tests);
	foreach (test; 0..tests)
	{
		int n, m;
		readf !(" %s %s") (n, m);
		alias Edge = Tuple !(int, q{d}, int, q{num});
		auto adj = new Edge [] [n * 3];
		foreach (j; 0..m)
		{
			int u, v;
			readf !(" %s %s") (u, v);
			u -= 1;
			v -= 1;
			adj[u] ~= Edge (v, j);
			adj[v] ~= Edge (u, j);
		}

		auto state = new int [n * 3];
		int [] edges;
		int [] vertices;

uLoop:
		foreach (u; 0..n * 3)
		{
			if (state[u] == none)
			{
				foreach (e; adj[u])
				{
					if (state[e.d] == none)
					{
						state[u] = matching;
						state[e.d] = matching;
						edges ~= e.num + 1;
						continue uLoop;
					}
				}
				state[u] = indSet;
				vertices ~= u + 1;
			}
		}

		if (edges.length >= n)
		{
			writeln ("Matching");
			writefln !("%(%s %)") (edges[0..n]);
		}
		else if (vertices.length >= n)
		{
			writeln ("IndSet");
			writefln !("%(%s %)") (vertices[0..n]);
		}
		else
		{
			assert (false);
		}
	}
}

import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }

int N, M;
int[] U, V;

void main() {
  try {
    for (; ; ) {
      const numCases = readInt();
      foreach (caseId; 0 .. numCases) {
        // !!!3N vertices!!!
        N = readInt();
        M = readInt();
        U = new int[M];
        V = new int[M];
        foreach (i; 0 .. M) {
          U[i] = readInt() - 1;
          V[i] = readInt() - 1;
        }
        debug {
          writeln("N = ", N, ", M = ", M);
          writeln("U = ", U);
          writeln("V = ", V);
        }

        int cnt;
        auto matching = new bool[M];
        auto used = new bool[3 * N];
        foreach (i; 0 .. M) {
          if (!used[U[i]] && !used[V[i]]) {
            ++cnt;
            matching[i] = true;
            used[U[i]] = true;
            used[V[i]] = true;
          }
        }

        int[] ans;
        if (cnt >= N) {
          writeln("Matching");
          foreach (i; 0 .. M) {
            if (matching[i]) {
              ans ~= i + 1;
            }
          }
        } else {
          writeln("IndSet");
          foreach (u; 0 .. 3 * N) {
            if (!used[u]) {
              ans ~= u + 1;
            }
          }
        }
        ans = ans[0 .. N];
        foreach (idx, a; ans) {
          if (idx > 0) {
            write(" ");
          }
          write(a);
        }
        writeln();
      }
    }
  } catch (EOFException e) {
  }
}


There is an array $$$a$$$ with $$$n-1$$$ integers. Let $$$x$$$ be the bitwise XOR of all elements of the array. The number $$$x$$$ is added to the end of the array $$$a$$$ (now it has length $$$n$$$), and then the elements are shuffled.You are given the newly formed array $$$a$$$. What is $$$x$$$? If there are multiple possible values of $$$x$$$, you can output any of them.

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \leq n \leq 100$$$) — the number of integers in the resulting array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \le a_i \le 127$$$) — the elements of the newly formed array $$$a$$$. Additional constraint on the input: the array $$$a$$$ is made by the process described in the statement; that is, some value of $$$x$$$ exists.

For each test case, output a single integer — the value of $$$x$$$, as described in the statement. If there are multiple possible values of $$$x$$$, output any of them.

NoteIn the first test case, one possible array $$$a$$$ is $$$a=[2, 5, 4]$$$. Then $$$x = 2 \oplus 5 \oplus 4 = 3$$$ ($$$\oplus$$$ denotes the bitwise XOR), so the new array is $$$[2, 5, 4, 3]$$$. Afterwards, the array is shuffled to form $$$[4, 3, 2, 5]$$$.In the second test case, one possible array $$$a$$$ is $$$a=[1, 10, 6, 10]$$$. Then $$$x = 1 \oplus 10 \oplus 6 \oplus 10 = 7$$$, so the new array is $$$[1, 10, 6, 10, 7]$$$. Afterwards, the array is shuffled to form $$$[6, 1, 10, 7, 10]$$$.In the third test case, all elements of the array are equal to $$$6$$$, so $$$x=6$$$.In the fourth test case, one possible array $$$a$$$ is $$$a=[100, 100]$$$. Then $$$x = 100 \oplus 100 = 0$$$, so the new array is $$$[100, 100, 0]$$$. Afterwards, the array is shuffled to form $$$[100, 100, 0]$$$. (Note that after the shuffle, the array can remain the same.)

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void solve() {
    readln;
    int[] arr = readln.splitter.map!(to!int).array;
    writeln(arr.front);
}

void main()
{
    size_t TC = 1;
    TC = readln.strip.to!int;
    foreach(_;0..TC) solve();
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
	foreach (test; 0..tests)
	{
		auto n = readln.strip.to !(int);
		auto a = readln.splitter.map !(to !(int)).array;
		writeln (a.back);
	}
}


Parsa has a humongous tree on $$$n$$$ vertices.On each vertex $$$v$$$ he has written two integers $$$l_v$$$ and $$$r_v$$$.To make Parsa's tree look even more majestic, Nima wants to assign a number $$$a_v$$$ ($$$l_v \le a_v \le r_v$$$) to each vertex $$$v$$$ such that the beauty of Parsa's tree is maximized.Nima's sense of the beauty is rather bizarre. He defines the beauty of the tree as the sum of $$$|a_u - a_v|$$$ over all edges $$$(u, v)$$$ of the tree.Since Parsa's tree is too large, Nima can't maximize its beauty on his own. Your task is to find the maximum possible beauty for Parsa's tree.

The first line contains an integer $$$t$$$ $$$(1\le t\le 250)$$$ — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2\le n\le 10^5)$$$ — the number of vertices in Parsa's tree. The $$$i$$$-th of the following $$$n$$$ lines contains two integers $$$l_i$$$ and $$$r_i$$$ $$$(1 \le l_i \le r_i \le 10^9)$$$. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ $$$(1 \le u , v \le n, u\neq v)$$$ meaning that there is an edge between the vertices $$$u$$$ and $$$v$$$ in Parsa's tree. It is guaranteed that the given graph is a tree. It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.

For each test case print the maximum possible beauty for Parsa's tree.

NoteThe trees in the example:  In the first test case, one possible assignment is $$$a = \{1, 8\}$$$ which results in $$$|1 - 8| = 7$$$.In the second test case, one of the possible assignments is $$$a = \{1, 5, 9\}$$$ which results in a beauty of $$$|1 - 5| + |5 - 9| = 8$$$

import std.stdio;
import std.algorithm;
import std.math;

long solve2(int root, long[][] dp, long[] l, long[] r, int[][] vtx, bool[] visited)
{
  if (visited[root])
    return 0;

  visited[root] = true;

  if (dp[0][root] != -1L && dp[1][root] != -1L)
    return max(dp[0][root], dp[1][root]);

  long best_beauty_l = 0;
  long best_beauty_r = 0;

  foreach (leaf ; vtx[root]) {
    if (visited[leaf])
      continue;
    if (dp[0][leaf] == -1L || dp[1][leaf] == -1L)
      solve2(leaf, dp, l, r, vtx, visited);
    long beauty_ll = abs(l[root] - l[leaf]) + dp[0][leaf];
    long beauty_lr = abs(l[root] - r[leaf]) + dp[1][leaf];
    long beauty_rl = abs(r[root] - l[leaf]) + dp[0][leaf];
    long beauty_rr = abs(r[root] - r[leaf]) + dp[1][leaf];
    long beauty_l = max(beauty_ll, beauty_lr);
    long beauty_r = max(beauty_rl, beauty_rr);
//    writeln(beauty_l);
//    writeln(beauty_r);
    best_beauty_l += beauty_l;
    best_beauty_r += beauty_r;
  }

  dp[0][root] = best_beauty_l;
  dp[1][root] = best_beauty_r;
  return max(dp[0][root], dp[1][root]);
}

long solve()
{
  int n;
  readf!(" %d")(n);
  auto dp = new long[][](2, n);
  auto l = new long[](n);
  auto r = new long[](n);
  auto vtx = new int[][](n, 0);
  auto visited = new bool[](n);
  dp[0][] = -1L;
  dp[1][] = -1L;

  for (int j = 0; j < n; j++) {
    readf!(" %d %d")(l[j], r[j]);
  }
  for (int j = 0; j < n - 1; j++) {
    int u, v;
    readf!(" %d %d")(u, v);
    vtx[u - 1] ~= v - 1;
    vtx[v - 1] ~= u - 1;
  }
/*
  writeln(vtx);
  foreach (i, x ; vtx) {
    printf("%d => ", i + 1);
    writeln(x.map!(a => a + 1));
  }
*/
/*
  long best = -1;
  for (int j = 0; j < n; j++) {
    best = max(best, solve2(j, dp, l, r, vtx, visited));
  }
*/
  long best = solve2(0, dp, l, r, vtx, visited);

//  writeln(dp);
  return best;
}

void main()
{
  int t;
  readf!(" %d")(t);

  for (int i = 0; i < t; i++) {
    writeln(solve());
  }
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }
double[] rotate(double[] vec, double rad) { return [cos(rad)*vec[0] - sin(rad)*vec[1], sin(rad)*vec[0] + cos(rad)*vec[1]]; }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto l = new long[](n);
		auto r = new long[](n);
		foreach (i; 0..n)
		{
			l[i] = RD;
			r[i] = RD;
		}
		auto edges = new int[][](n);
		foreach (i; 0..n-1)
		{
			auto u = RD!int-1;
			auto v = RD!int-1;
			edges[u] ~= v;
			edges[v] ~= u;
		}

		long[][] dfs(int pos, int last)
		{
			long[][] res = [[l[pos], 0], [r[pos], 0]];
			foreach (v; edges[pos])
			{
				if (v == last) continue;
				auto tmp = dfs(v, pos);
				auto ll = abs(tmp[0][0] - l[pos]) + tmp[0][1];
				auto lr = abs(tmp[0][0] - r[pos]) + tmp[0][1];
				auto rl = abs(tmp[1][0] - l[pos]) + tmp[1][1];
				auto rr = abs(tmp[1][0] - r[pos]) + tmp[1][1];
				res[0][1] += max(ll, rl);
				res[1][1] += max(lr, rr);
			}
			return res;
		}
		auto res = dfs(0, -1);
		ans[ti] = max(res[0][1], res[1][1]);
	}

	foreach (e; ans)
		writeln(e);
	stdout.flush;
	debug readln;
}

import std.algorithm;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
	foreach (test; 0..tests)
	{
		auto n = readln.strip.to !(int);
		auto lo = new int [n];
		auto hi = new int [n];
		foreach (i; 0..n)
		{
			readf !(" %s %s") (lo[i], hi[i]);
		}
		auto adj = new int [] [n];
		foreach (i; 0..n - 1)
		{
			int u, v;
			readf !(" %s %s") (u, v);
			u -= 1;
			v -= 1;
			adj[u] ~= v;
			adj[v] ~= u;
		}
		readln;

		auto f = new long [2] [n];

		long recur (int v, int p)
		{
			foreach (u; adj[v])
			{
				if (u != p)
				{
					recur (u, v);
					f[v][0] += max (
					    f[u][0] + abs (lo[v] - lo[u]),
					    f[u][1] + abs (lo[v] - hi[u]));
					f[v][1] += max (
					    f[u][0] + abs (hi[v] - lo[u]),
					    f[u][1] + abs (hi[v] - hi[u]));
				}
			}
			return max (f[v][0], f[v][1]);
		}

		writeln (recur (0, -1));
	}
}

import std.stdio;
import std.algorithm;
import std.math;

long solve2(int root, long[][] dp, long[] l, long[] r, int[][] vtx)
{
  if (dp[0][root] != -1L && dp[1][root] != -1L)
    return max(dp[0][root], dp[1][root]);

  if (vtx[root].length == 0) {
    dp[0][root] = 0;
    dp[1][root] = 0;
    return 0;
  }

  long best_beauty_l = 0;
  long best_beauty_r = 0;

  foreach (leaf ; vtx[root]) {
    if (dp[0][leaf] == -1L || dp[1][leaf] == -1L)
      solve2(leaf, dp, l, r, vtx);
    long beauty_ll = abs(l[root] - l[leaf]) + dp[0][leaf];
    long beauty_lr = abs(l[root] - r[leaf]) + dp[1][leaf];
    long beauty_rl = abs(r[root] - l[leaf]) + dp[0][leaf];
    long beauty_rr = abs(r[root] - r[leaf]) + dp[1][leaf];
    long beauty_l = max(beauty_ll, beauty_lr);
    long beauty_r = max(beauty_rl, beauty_rr);
//    writeln(beauty_l);
//    writeln(beauty_r);
    best_beauty_l += beauty_l;
    best_beauty_r += beauty_r;
  }

  dp[0][root] = best_beauty_l;
  dp[1][root] = best_beauty_r;
  return max(dp[0][root], dp[1][root]);
}

long solve()
{
  int n;
  readf!(" %d")(n);
  auto dp = new long[][](2, n);
  auto l = new long[](n);
  auto r = new long[](n);
  auto vtx = new int[][](n, 0);
  dp[0][] = -1L;
  dp[1][] = -1L;
//  writeln(dp);

  for (int j = 0; j < n; j++) {
    readf!(" %d %d")(l[j], r[j]);
  }
  for (int j = 0; j < n - 1; j++) {
    int u, v;
    readf!(" %d %d")(u, v);
    vtx[v - 1] ~= u - 1;
  }

//  writeln(vtx);

  long best = -1;
  for (int j = 0; j < n; j++) {
    best = max(best, solve2(j, dp, l, r, vtx));
  }

//  writeln(dp);
  return best;
}

void main()
{
  int t;
  readf!(" %d")(t);

  for (int i = 0; i < t; i++) {
    writeln(solve());
  }
}


A star is a figure of the following type: an asterisk character '*' in the center of the figure and four rays (to the left, right, top, bottom) of the same positive length. The size of a star is the length of its rays. The size of a star must be a positive number (i.e. rays of length $$$0$$$ are not allowed).Let's consider empty cells are denoted by '.', then the following figures are stars:  The leftmost figure is a star of size $$$1$$$, the middle figure is a star of size $$$2$$$ and the rightmost figure is a star of size $$$3$$$. You are given a rectangular grid of size $$$n \times m$$$ consisting only of asterisks '*' and periods (dots) '.'. Rows are numbered from $$$1$$$ to $$$n$$$, columns are numbered from $$$1$$$ to $$$m$$$. Your task is to draw this grid using any number of stars or find out that it is impossible. Stars can intersect, overlap or even coincide with each other. The number of stars in the output can't exceed $$$n \cdot m$$$. Each star should be completely inside the grid. You can use stars of same and arbitrary sizes.In this problem, you do not need to minimize the number of stars. Just find any way to draw the given grid with at most $$$n \cdot m$$$ stars.

The first line of the input contains two integers $$$n$$$ and $$$m$$$ ($$$3 \le n, m \le 100$$$) — the sizes of the given grid. The next $$$n$$$ lines contains $$$m$$$ characters each, the $$$i$$$-th line describes the $$$i$$$-th row of the grid. It is guaranteed that grid consists of characters '*' and '.' only.

If it is impossible to draw the given grid using stars only, print "-1". Otherwise in the first line print one integer $$$k$$$ ($$$0 \le k \le n \cdot m$$$) — the number of stars needed to draw the given grid. The next $$$k$$$ lines should contain three integers each — $$$x_j$$$, $$$y_j$$$ and $$$s_j$$$, where $$$x_j$$$ is the row index of the central star character, $$$y_j$$$ is the column index of the central star character and $$$s_j$$$ is the size of the star. Each star should be completely inside the grid.

NoteIn the first example the output 23 4 13 5 2is also correct.

import core.bitop;
import std.algorithm;
import std.array;
import std.bitmanip;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import std.range.interfaces;

void main()
{
    int n, m;
    readf("%s %s", &n, &m);
    readln;

    dchar[][] arr;
    arr ~= (cast(dchar)'.').repeat(m).array;
    foreach (_; 0 .. n) arr ~= readln.chomp.to!(dchar[]);
    arr ~= (cast(dchar)'.').repeat(m).array;

    foreach (ref rw; arr) rw = cast(dchar)'.' ~ rw ~ cast(dchar)'.';

    debug { arr.writeln; }

    auto reach = new int[][][] (n+2, m+2, 4);
    foreach (i, rw; arr) {
        foreach (j, e; rw) {
            if (e == '.') reach[i][j][0] = reach[i][j][1] = 0;
            else {
                reach[i][j][0] = 1 + reach[i-1][j][0];
                reach[i][j][1] = 1 + reach[i][j-1][1];
            }
        }
    }
    foreach_reverse (i, rw; arr) {
        foreach_reverse (j, e; rw) {
            if (e == '.') reach[i][j][2] = reach[i][j][3] = 0;
            else {
                reach[i][j][2] = 1 + reach[i+1][j][2];
                reach[i][j][3] = 1 + reach[i][j+1][3];
            }

        }
    }

    auto cnt = new int[][][] (2, n+2, m+2);
    Tuple!(int, int, int)[] ans;
    foreach (i, rw; arr) {
        foreach (j, el; rw) {
            if (el != '*') continue;

            int range = reach[i][j].minElement - 1;

            if (range > 0) {
                cnt[0][i][j-range] += 1;
                cnt[0][i][j+range+1] -= 1;
                cnt[1][i-range][j] += 1;
                cnt[1][i+range+1][j] -= 1;
                ans ~= tuple(cast(int)i, cast(int)j, range);
            }
        }
    }

    foreach (ref rw; cnt[0]) {
        rw = rw.cumulativeFold!((a, b) => a + b).array;
    }
    foreach (i, rw; cnt[1]) {
        foreach (j, ref e; rw) {
            if (i > 0) e += cnt[1][i-1][j];
        }
    }

    foreach (i, rw; arr) {
        foreach (j, e; rw) {
            if (e == '.') continue;
            if (!cnt[0][i][j] && !cnt[1][i][j]) {
                writeln(-1);
                return;
            }
        }
    }

    ans.length.writeln;
    ans.each!(t => writeln(t[0], ' ', t[1], ' ', t[2]));
}

import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	int rows, cols;
	while (readf (" %s %s", &rows, &cols) > 0)
	{
		readln;
		auto a = new bool [] [] (rows + 2, cols + 2);
		foreach (row; 1..rows + 1)
		{
			auto s = readln.strip;
			foreach (col; 1..cols + 1)
			{
				a[row][col] = (s[col - 1] == '*');
			}
		}
		rows += 2;
		cols += 2;

		auto dr = new int [] [] (rows, cols);
		foreach (row; 0..rows)
		{
			int val = -1;
			foreach (col; 0..cols)
			{
				if (a[row][col])
				{
					val += 1;
				}
				else
				{
					val = -1;
				}
				dr[row][col] = val;
			}
		}

		auto dl = new int [] [] (rows, cols);
		foreach (row; 0..rows)
		{
			int val = -1;
			foreach_reverse (col; 0..cols)
			{
				if (a[row][col])
				{
					val += 1;
				}
				else
				{
					val = -1;
				}
				dl[row][col] = val;
			}
		}

		auto dd = new int [] [] (rows, cols);
		foreach (col; 0..cols)
		{
			int val = -1;
			foreach (row; 0..rows)
			{
				if (a[row][col])
				{
					val += 1;
				}
				else
				{
					val = -1;
				}
				dd[row][col] = val;
			}
		}

		auto du = new int [] [] (rows, cols);
		foreach (col; 0..cols)
		{
			int val = -1;
			foreach_reverse (row; 0..rows)
			{
				if (a[row][col])
				{
					val += 1;
				}
				else
				{
					val = -1;
				}
				du[row][col] = val;
			}
		}

		int res = 0;
		auto mr = new int [] [] (rows, cols);
		auto ml = new int [] [] (rows, cols);
		auto md = new int [] [] (rows, cols);
		auto mu = new int [] [] (rows, cols);
		foreach (row; 0..rows)
		{
			foreach (col; 0..cols)
			{
				auto d = min (dr[row][col], dl[row][col],
				    dd[row][col], du[row][col]);
				if (d <= 0)
				{
					continue;
				}
				int r = d * 2 + 1;
				res += 1;
				mr[row][col - d] = max (mr[row][col - d], r);
				ml[row][col + d] = max (ml[row][col + d], r);
				md[row - d][col] = max (md[row - d][col], r);
				mu[row + d][col] = max (mu[row + d][col], r);
			}
		}

		foreach (row; 0..rows)
		{
			int val = 0;
			foreach (col; 0..cols)
			{
				val = max (val, mr[row][col]);
				if (val > 0)
				{
					a[row][col] = false;
					val -= 1;
				}
			}
		}

		foreach (row; 0..rows)
		{
			int val = 0;
			foreach_reverse (col; 0..cols)
			{
				val = max (val, ml[row][col]);
				if (val > 0)
				{
					a[row][col] = false;
					val -= 1;
				}
			}
		}

		foreach (col; 0..cols)
		{
			int val = 0;
			foreach (row; 0..rows)
			{
				val = max (val, md[row][col]);
				if (val > 0)
				{
					a[row][col] = false;
					val -= 1;
				}
			}
		}

		foreach (col; 0..cols)
		{
			int val = 0;
			foreach_reverse (row; 0..rows)
			{
				val = max (val, mu[row][col]);
				if (val > 0)
				{
					a[row][col] = false;
					val -= 1;
				}
			}
		}

		debug {writefln ("%(%(%d %)\n%)", a);}
		if (a.any !(any))
		{
			writeln (-1);
			continue;
		}

		writeln (res);
		foreach (row; 0..rows)
		{
			foreach (col; 0..cols)
			{
				auto d = min (dr[row][col], dl[row][col],
				    dd[row][col], du[row][col]);
				if (d <= 0)
				{
					continue;
				}
				writeln (row, " ", col, " ", d);
			}
		}
	}
}

import core.bitop;
import std.algorithm;
import std.array;
import std.bitmanip;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import std.range.interfaces;

void main()
{
    int n, m;
    readf("%s %s", &n, &m);
    readln;

    dchar[][] arr;
    arr ~= (cast(dchar)'.').repeat(m).array;
    foreach (_; 0 .. n) arr ~= readln.chomp.to!(dchar[]);
    arr ~= (cast(dchar)'.').repeat(m).array;

    foreach (ref rw; arr) rw = cast(dchar)'.' ~ rw ~ cast(dchar)'.';

    debug { arr.writeln; }

    auto covered = new bool[][] (n+1, m+1);
    Tuple!(int, int, int)[] ans;
    foreach (i, rw; arr) {
        foreach (j, el; rw) {
            if (el != '*') continue;

            int range = 0;
            while (arr[i-range-1][j] == '*' && arr[i+range+1][j] == '*'
                  && arr[i][j-range-1] == '*' && arr[i][j+range+1] == '*') {
                covered[i-range-1][j] = true;
                covered[i+range+1][j] = true;
                covered[i][j-range-1] = true;
                covered[i][j+range+1] = true;
                ++range;
            }

            if (range > 0) {
                covered[i][j] = true;
                ans ~= tuple(cast(int)i, cast(int)j, range);
            }
        }
    }

    foreach (i, rw; covered) {
        foreach (j, e; rw) {
            if (arr[i][j] == '*' && !covered[i][j]) {
                writeln(-1);
                return;
            }
        }
    }

    ans.length.writeln;
    ans.each!(t => writeln(t[0], ' ', t[1], ' ', t[2]));
}


DZY has a sequence a, consisting of n integers.We'll call a sequence ai, ai + 1, ..., aj (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change one number to any integer you want) from the subsegment to make the subsegment strictly increasing.You only need to output the length of the subsegment you find.

The first line contains integer n (1 ≤ n ≤ 105). The next line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109).

In a single line print the answer to the problem — the maximum length of the required subsegment.

NoteYou can choose subsegment a2, a3, a4, a5, a6 and change its 3rd element (that is a4) to 4.

import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

int N;
int[] A;
void main() {
    scanf("%d\n", &N);
    A = readln.chomp.split(" ").map!(to!int).array;
    int[] L1 = new int[N];
    int[] L2 = new int[N];

    L1[0] = 1;
    foreach (i; 0 .. N - 1) {
        if (A[i] + 1 <= A[i + 1]) {
            L1[i + 1] = L1[i] + 1;
        } else {
            L1[i + 1] = 1;
        }
    }

    L2[N - 1] = 1;
    for (int i = N - 1; i > 0; i--) {
        if (A[i - 1] + 1 <= A[i]) {
            L2[i - 1] = L2[i] + 1;
        } else {
            L2[i - 1] = 1;
        }
    }
    //writeln(L1);
    //writeln(L2);

    int Ans = L1.reduce!max;
    if (N > 1 && L2[0] == 1) Ans = max(Ans, L2[1] + 1);
    if (N > 1 && L1[$ - 1] == 1) Ans = max(Ans, L1[$ - 2] + 1);
    foreach (i; 0 .. N - 2) {
        if (A[i] >= A[i + 1]) {
            Ans = max(Ans, L1[i] + 1, L2[i + 1] + 1);
        }
        if (A[i] + 2 <= A[i + 2]) {
            Ans = max(Ans, L1[i] + L2[i + 2] + 1);
        }
    }
    writeln(Ans);
}

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;

    auto dp = new int[][](2, N);
    dp[0][0] = dp[1][N-1] = 1;

    foreach (i; 1..N) {
        dp[0][i] = (A[i] > A[i-1]) ? dp[0][i-1] + 1 : 1;
        dp[1][N-i-1] = (A[N-i] > A[N-i-1]) ? dp[1][N-i] + 1 : 1;
    }

    int ans = 0;

    foreach (i; 0..N) ans = max(max(ans, dp[0][i]+1), dp[1][i]+1);
    foreach (i; 0..N-2) if (A[i+2] - A[i] >= 2) ans = max(ans, dp[0][i]+dp[1][i+2]+1);

    writeln(min(ans, N));
}

import std.stdio, std.string;

void update(ref int tar, int val)
{
    if (val > tar)
    {
        tar = val;
    }
}

void solve(int[] a)
{
    auto pre = new int[a.length];
    auto len = new int[a.length];
    pre[0] = 0;
    len[0] = 1;
    foreach (i; 1 .. a.length)
    {
        if (a[i] > a[i - 1])
        {
            pre[i] = pre[i - 1];
        }
        else
        {
            pre[i] = i;
        }
        len[i] = i - pre[i] + 1;
    }
    int ans = 0;
    foreach (i; 0 .. a.length)
    {
        update(ans, len[i]);
        int idx = pre[i];
        if (idx > 0)
        {
            update(ans, len[i] + 1);
            if (len[i] == 1)
            {
                update(ans, len[idx - 1] + 1);
            }
        }
        if (idx > 1)
        {
            if (a[idx] - a[idx - 2] > 1)
            {
                update(ans, len[i] + 1 + len[idx - 2]);
            }
            if (len[i] > 1)
            {
                if (a[idx + 1] - a[idx - 1] > 1)
                {
                    update(ans, len[i] + len[idx - 1]);
                }
            }
        }
    }
    writefln("%d", ans);
}

void main(string[] args)
{
    int n;
    while (scanf("%d", &n) == 1)
    {
        auto a = new int[n];
        foreach (i; 0 .. n)
        {
            scanf("%d", &a[i]);
        }
        solve(a);
    }
}

import core.thread;
import std.conv, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex;

//	Input
class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { tokens = readln.split; if (stdin.eof) throw new EOFException; } auto token = tokens[0]; tokens.popFront; return token; }
int readInt() { return to!int(readToken); }
long readLong() { return to!long(readToken); }
real readReal() { return to!real(readToken); }

//	chmin/chmax
void chmin(T)(ref T t, const T f) { if (t > f) t = f; }
void chmax(T)(ref T t, const T f) { if (t < f) t = f; }

//	Pair
struct Pair(S, T) {
	S x; T y;
	int opCmp(ref const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; }
	string toString() const { return "(" ~ to!string(x) ~ ", " ~ to!string(y) ~ ")"; }
}
auto pair(S, T)(S x, T y) { return Pair!(S, T)(x, y); }

//	Array
int binarySearch(T)(T[] as, bool delegate(T) test) { int low = -1, upp = as.length; for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; }
int lowerBound(T)(T[] as, T val) { return as.binarySearch((T a) { return (a <  val); }); }
int upperBound(T)(T[] as, T val) { return as.binarySearch((T a) { return (a <= val); }); }
T[] unique(T)(T[] as) { T[] bs; foreach (a; as) if (bs.empty || bs[$ - 1] != a) bs ~= a; return bs; }

int N;
int[] A;

void main(string[] args) {
	try {
	for (; ; ) {
		N = readInt;
		A = new int[N];
		foreach (i; 0 .. N) {
			A[i] = readInt;
		}

		int[] ls = new int[N];
		int[] rs = new int[N];
		ls[0] = 0;
		foreach (i; 1 .. N) {
			ls[i] = (A[i - 1] < A[i]) ? ls[i - 1] : i;
		}
		rs[N - 1] = N - 1;
		foreach_reverse (i; 0 .. N - 1) {
			rs[i] = (A[i] < A[i + 1]) ? rs[i + 1] : i;
		}

		int ans;

		//	no change
		foreach (i; 0 .. N) {
			chmax(ans, rs[i] - i + 1);
		}

		//	one change, one side
		foreach (i; 0 .. N) {
			if (i - 1 >= 0) {
				chmax(ans, i - ls[i - 1] + 1);
			}
			if (i + 1 < N) {
				chmax(ans, rs[i + 1] - i + 1);
			}
		}

		//	one change, two sides
		foreach (i; 1 .. N - 1) {
			if (A[i + 1] - A[i - 1] >= 2) {
				chmax(ans, rs[i + 1] - ls[i - 1] + 1);
			}
		}

		writeln(ans);

	}
	} catch (EOFException) {}
}

import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

int N;
int[] A;
void main() {
    scanf("%d\n", &N);
    A = readln.chomp.split(" ").map!(to!int).array;
    int[] L1 = new int[N];
    int[] L2 = new int[N];

    L1[0] = 1;
    foreach (i; 0 .. N - 1) {
        if (A[i] + 1 <= A[i + 1]) {
            L1[i + 1] = L1[i] + 1;
        } else {
            L1[i + 1] = 1;
        }
    }

    L2[N - 1] = 1;
    for (int i = N - 1; i > 0; i--) {
        if (A[i - 1] + 1 <= A[i]) {
            L2[i - 1] = L2[i] + 1;
        } else {
            L2[i - 1] = 1;
        }
    }

    int Ans = L1.reduce!max;
    if (N > 1 && L1[$ - 1] == 1) Ans = max(Ans, L1[$ - 2] + 1);
    foreach (i; 0 .. N - 2) {
        if (A[i] >= A[i + 1]) Ans = max(Ans, L1[i] + 1);
        if (A[i] + 2 <= A[i + 2]) {
            Ans = max(Ans, L1[i] + L2[i + 2] + 1);
        }
    }
    writeln(Ans);
}

import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

int N;
int[] A;
void main() {
    scanf("%d\n", &N);
    A = readln.chomp.split(" ").map!(to!int).array;
    int[] L1 = new int[N];
    int[] L2 = new int[N];

    if (N == 2) {
        writeln(2);
        return;
    }

    L1[0] = 1;
    foreach (i; 0 .. N - 1) {
        if (A[i] + 1 <= A[i + 1]) {
            L1[i + 1] = L1[i] + 1;
        } else {
            L1[i + 1] = 1;
        }
    }

    L2[N - 1] = 1;
    for (int i = N - 1; i > 0; i--) {
        if (A[i - 1] + 1 <= A[i]) {
            L2[i - 1] = L2[i] + 1;
        } else {
            L2[i - 1] = 1;
        }
    }

    int Ans = L1.reduce!max;
    foreach (i; 0 .. N - 2) {
        if (A[i] >= A[i + 1]) Ans = max(Ans, L1[i] + 1);
        if (A[i] + 2 <= A[i + 2]) {
            Ans = max(Ans, L1[i] + L2[i + 2] + 1);
        }
    }
    writeln(Ans);
}

import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

int N;
int[] A;
void main() {
    scanf("%d\n", &N);
    A = readln.chomp.split(" ").map!(to!int).array;
    int[] L1 = new int[N];
    int[] L2 = new int[N];

    if (N == 2) {
        writeln(2);
        return;
    }

    L1[0] = 1;
    foreach (i; 0 .. N - 1) {
        if (A[i] + 1 <= A[i + 1]) {
            L1[i + 1] = L1[i] + 1;
        } else {
            L1[i + 1] = 1;
        }
    }

    L2[N - 1] = 1;
    for (int i = N - 1; i > 0; i--) {
        if (A[i - 1] + 1 <= A[i]) {
            L2[i - 1] = L2[i] + 1;
        } else {
            L2[i - 1] = 1;
        }
    }

    int Ans = L1.reduce!max;
    if (L1[$ - 1] == 1) Ans = max(Ans, L1[$ - 2] + 1);
    foreach (i; 0 .. N - 2) {
        if (A[i] >= A[i + 1]) Ans = max(Ans, L1[i] + 1);
        if (A[i] + 2 <= A[i + 2]) {
            Ans = max(Ans, L1[i] + L2[i + 2] + 1);
        }
    }
    writeln(Ans);
}

import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

int N;
int[] A;
void main() {
    scanf("%d\n", &N);
    A = readln.chomp.split(" ").map!(to!int).array;
    int[] L1 = new int[N];
    int[] L2 = new int[N];

    L1[0] = 1;
    foreach (i; 0 .. N - 1) {
        if (A[i] + 1 <= A[i + 1]) {
            L1[i + 1] = L1[i] + 1;
        } else {
            L1[i + 1] = 1;
        }
    }

    L2[N - 1] = 1;
    for (int i = N - 1; i > 0; i--) {
        if (A[i - 1] + 1 <= A[i]) {
            L2[i - 1] = L2[i] + 1;
        } else {
            L2[i - 1] = 1;
        }
    }
    //writeln(L1);
    //writeln(L2);

    int Ans = L1.reduce!max;
    if (N > 1 && L2[0] == 1) Ans = max(Ans, L2[1] + 1);
    if (N > 1 && L1[$ - 1] == 1) Ans = max(Ans, L1[$ - 2] + 1);
    foreach (i; 0 .. N - 2) {
        if (A[i] >= A[i + 1]) Ans = max(Ans, L1[i] + 1);
        if (A[i] + 2 <= A[i + 2]) {
            Ans = max(Ans, L1[i] + L2[i + 2] + 1);
        }
    }
    writeln(Ans);
}

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;

    auto dp = new int[][](N, 3);
    dp[0][0] = 1;

    foreach (i; 1..N) {
        if (A[i] > A[i-1]) {
            dp[i][0] = dp[i-1][0] + 1;
            if (i > 1 && A[i] > A[i-2] + 1)
                dp[i][2] = dp[i-1][1] + 1;
            dp[i][2] = max(dp[i][2], dp[i-1][2]+1);
        }
        else {
            dp[i][0] = 1;
            dp[i][1] = dp[i-1][0]+1;
            dp[i][2] = 1;
        }
    }

    int ans = 0;
    foreach (i; 0..N) foreach (j; 0..2) ans = max(ans, dp[i][j]);
    writeln(ans);
}

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;

    auto dp = new int[][](N, 3);
    dp[0][0] = 1;

    foreach (i; 1..N) {
        if (A[i] > A[i-1]) {
            dp[i][0] = dp[i-1][0] + 1;
            if (i > 1 && A[i] > A[i-2] + 1)
                dp[i][2] = dp[i-1][1] + 1;
            dp[i][2] = max(dp[i][2], dp[i-1][2]+1);
        }
        else {
            dp[i][0] = 1;
            dp[i][1] = dp[i-1][0]+1;
            dp[i][2] = 1;
        }
    }

    int ans = 0;
    foreach (i; 0..N) foreach (j; 0..3) ans = max(ans, dp[i][j]);
    writeln(ans);
}

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;

    auto dp = new int[](N);
    dp[0] = 1;

    foreach (i; 1..N)
        dp[i] = (A[i] > A[i-1]) ? dp[i-1] + 1 : 1;

    int ans = 0;

    foreach (i; 0..N) ans = max(ans, dp[i]+1);
    foreach (i; 0..N-2) if (dp[i+2] - dp[i] >= 2) ans = max(ans, dp[i]+dp[i+2]+1);

    writeln(min(ans, N));
}

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio, std.bitmanip;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;

    auto dp = new int[][](N, 2);
    dp[0][0] = dp[0][1] = 1;

    foreach (i; 1..N) {
        if (A[i] > A[i-1]) {
            dp[i][0] = dp[i-1][0] + 1;
            dp[i][1] = dp[i-1][1] + 1;
        }
        else {
            dp[i][0] = 1;
            dp[i][1] = max(dp[i-1][1], dp[i-1][0]+1);
        }
    }

    int ans = 0;
    foreach (i; 0..N) foreach (j; 0..2) ans = max(ans, dp[i][j]);
    writeln(ans);
}


Alice and Bob are playing a game on a matrix, consisting of $$$2$$$ rows and $$$m$$$ columns. The cell in the $$$i$$$-th row in the $$$j$$$-th column contains $$$a_{i, j}$$$ coins in it.Initially, both Alice and Bob are standing in a cell $$$(1, 1)$$$. They are going to perform a sequence of moves to reach a cell $$$(2, m)$$$.The possible moves are:   Move right — from some cell $$$(x, y)$$$ to $$$(x, y + 1)$$$;  Move down — from some cell $$$(x, y)$$$ to $$$(x + 1, y)$$$. First, Alice makes all her moves until she reaches $$$(2, m)$$$. She collects the coins in all cells she visit (including the starting cell).When Alice finishes, Bob starts his journey. He also performs the moves to reach $$$(2, m)$$$ and collects the coins in all cells that he visited, but Alice didn't.The score of the game is the total number of coins Bob collects.Alice wants to minimize the score. Bob wants to maximize the score. What will the score of the game be if both players play optimally?

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of the testcase contains a single integer $$$m$$$ ($$$1 \le m \le 10^5$$$) — the number of columns of the matrix. The $$$i$$$-th of the next $$$2$$$ lines contain $$$m$$$ integers $$$a_{i,1}, a_{i,2}, \dots, a_{i,m}$$$ ($$$1 \le a_{i,j} \le 10^4$$$) — the number of coins in the cell in the $$$i$$$-th row in the $$$j$$$-th column of the matrix. The sum of $$$m$$$ over all testcases doesn't exceed $$$10^5$$$.

For each testcase print a single integer — the score of the game if both players play optimally.

NoteThe paths for the testcases are shown on the following pictures. Alice's path is depicted in red and Bob's path is depicted in blue.

import std.stdio;
import std.ascii;
import std.algorithm;
import std.range;
import core.stdc.stdio;

void main()
{
	int t = readInt!int;
	while (t--) solve;
}
void solve()
{
	int m = readInt!int;
	auto a = new long[][](2, m);
	auto score = new long[](m);
	foreach(ref row; a) foreach(ref cell; row) cell = readInt!long;
	auto pf1 = a[0].cumulativeFold!((a, b) => a + b).array;
	auto pf2 = a[1].cumulativeFold!((a, b) => a + b).array;
	alias sum1 = (i, j) => (i > 0? pf1[j] - pf1[i - 1] : pf1[j]);
	alias sum2 = (i, j) => (i > 0? pf2[j] - pf2[i - 1] : pf2[j]);
	foreach(i; 0 .. m)
	{
		score[i] = sum1(0, i) + sum2(i, m - 1);
	}
	auto mxp = score.cumulativeFold!max.array; mxp[] -= a[0][0];
	auto mxs = score.reverse.cumulativeFold!max.array.reverse.array; mxs[] -= a[1][m-1];
	long minAns = long.max;
	foreach(i; 0 .. m)
	{
		auto p1 = i > 0? sum2(0, i - 1) : 0;
		auto p2 = i + 1 < m? sum1(i + 1, m - 1) : 0;
		minAns = min(minAns, max(p1, p2));
	}
	minAns.writeln;
}

/* INPUT ROUTINES */
int currChar;
static this()
{
	currChar = getchar();
}

char topChar()
{
	return cast(char) currChar;
}

void popChar()
{
	currChar = getchar();
}

auto readInt(T)()
{
	T num = 0;
	int sgn = 0;
	while (topChar.isWhite)
		popChar;
	while (topChar == '-' || topChar == '+')
	{
		sgn ^= (topChar == '-');
		popChar;
	}
	while (topChar.isDigit)
	{
		num *= 10;
		num += (topChar - '0');
		popChar;
	}
	if (sgn)
		return -num;
	return num;
}

string readString()
{
	string res = "";
	while (topChar.isWhite)
		popChar;
	while (!topChar.isWhite)
	{
		res ~= topChar;
		popChar;
	}
	return res;
}
/**MODULAR SYSTEM*/
struct Z(immutable long m)
{
	long rep;
	this(long num)
	{
		rep = num;
	}

	Z!m opBinary(string operator)(Z!m rhs)
	{
		static if (operator == "+")
		{
			long result = rhs.rep + this.rep;
			if (result >= m)
				result -= m;
			return Z!m(result);
		}
		else static if (operator == "-")
		{
			long result = this.rep - rhs.rep;
			if (result < 0)
				result += m;
			return Z!m(result);
		}
		else static if (operator == "*")
		{
			long result = this.rep * rhs.rep;
			if (result >= m)
				result %= m;
			return Z!m(result);
		}
		else
			static assert(text("Operator ", operator, " not supported"));
	}

	Z!m opBinary(string operator)(long exponent) if (operator == "^^")
	{
		assert(exponent >= 0);
		Z!m base = this;
		Z!m result = 1;
		while (exponent)
		{
			if (exponent & 1)
				result = result * base;
			base = base * base;
			exponent >>= 1;
		}
		return result;
	}

	invariant
	{
		assert(rep >= 0 && rep < m);
	}
}

import std.algorithm;
import std.random;

struct SegmentTreeLazy(V, U, alias f, alias fou, alias uou, string fName = null, string uName = null)
{
	alias This = typeof(this);
	size_t length;
	size_t realLength = 0;
	V[] _nodeFValue;
	U[] _nodeUpdate;
	bool[] _nodeHasUpdate;
	size_t[] _nodeRangeEnd;
	size_t[] _nodeRangeStart;
	string toString()
	{
		import std.conv;
		string str;
		foreach(i; 0 .. realLength)
			if (_nodeHasUpdate[i])
			{
				str ~= text(_nodeFValue[i], "(", _nodeUpdate[i], "), ");
			}
			else
			{
				str ~= text(_nodeFValue[i], ", ");
			}
		return str;
	}
	this(size_t length, V initialValue)
	{
		this.length = length;
		size_t noNodes = 4 * length;
		_nodeFValue = new V[](noNodes);
		_nodeUpdate = new U[](noNodes);
		_nodeHasUpdate = new bool[](noNodes);
		_nodeRangeEnd = new size_t[](noNodes);
		_nodeRangeStart = new size_t[](noNodes);
		void fill(size_t i, size_t rangeStart, size_t rangeEnd)
		{
			realLength = max(realLength, i + 1);
			_nodeRangeStart[i] = rangeStart;
			_nodeRangeEnd[i] = rangeEnd;
			if (_isLeaf(i)) { _nodeFValue[i] = initialValue; return; }
			size_t l = i<<1;
			size_t r = l+1;
			size_t m = (rangeStart + rangeEnd) / 2;
			fill(l, rangeStart, m), fill(r, m + 1, rangeEnd);
			_nodeFValue[i] = f(_nodeFValue[l], _nodeFValue[r]);
		}
		fill(1, 0, length - 1);
	}
	V rangeF(size_t start, size_t end)
	{
		bool set = false;
		V result;
		void visit(size_t i) in(_hasFragments(i, start, end))
		{
			if (_isFragment(i, start, end))
			{
				if (!set) { result = _cookedF(i); set = true; }
				else { result = f(result, _cookedF(i)); }
				return;
			}
			_clearUpdate(i);
			size_t l = i<<1, r = (i<<1)+1;
			if (_hasFragments(l, start, end)) visit(l);
			if (_hasFragments(r, start, end)) visit(r);
		}
		visit(1);
		return result;
	}
	void rangeU(size_t start, size_t end, U u)
	{
		void visit(size_t i) in(_hasFragments(i, start, end))
		{
			if (_isFragment(i, start, end))
			{
				_addUpdate(i, u);
				return;
			}
			_clearUpdate(i);
			size_t l = i<<1, r = (i<<1)+1;
			if (_hasFragments(l, start, end)) visit(l);
			if (_hasFragments(r, start, end)) visit(r);
			_nodeFValue[i] = f(_cookedF(l), _cookedF(r));
		}
		visit(1);
	}
	V _cookedF(size_t i)
	{
		if (_nodeHasUpdate[i]) { return fou(_nodeFValue[i],
						    _nodeUpdate[i],
						    _nodeRangeStart[i],
						    _nodeRangeEnd[i]); }
		return _nodeFValue[i];
	}
	void _clearUpdate(size_t i)
	{
		if (!_nodeHasUpdate[i]) return;
		if (_isLeaf(i)) { _nodeFValue[i] = _cookedF(i); _nodeHasUpdate[i] = false; return;}
		size_t l = i<<1, r = (i<<1)+1;
		_addUpdate(l, _nodeUpdate[i]), _addUpdate(r, _nodeUpdate[i]);
		_nodeFValue[i] = f(_cookedF(l), _cookedF(r));
		_nodeHasUpdate[i] = false;
	}
	void _addUpdate(size_t i, U u)
	{
		if (!_nodeHasUpdate[i]) { _nodeHasUpdate[i] = true; _nodeUpdate[i] = u; return; }
		_nodeUpdate[i] = uou(_nodeUpdate[i], u);
	}
	bool _isLeaf(size_t i)
	{
		return _nodeRangeStart[i] == _nodeRangeEnd[i];
	}
	bool _isFragment(size_t i, size_t rangeStart, size_t rangeEnd)
	{
		return rangeStart <= _nodeRangeStart[i] && _nodeRangeEnd[i] <= rangeEnd;
	}
	bool _hasFragments(size_t i, size_t rangeStart, size_t rangeEnd)
	{
		return _nodeRangeStart[i] <= rangeEnd && rangeStart <= _nodeRangeEnd[i];
	}
	// prettifiers
	struct Handle
	{
		import std.ascii;
		size_t _start, _end;
		This* _parent;
		auto f()
		{
			return _parent.rangeF(_start, _end);
		}
		auto u(U v)
		{
			_parent.rangeU(_start, _end, v);
		}
		static if (fName !is null)
		{
			mixin(q{alias }, fName, q{ = f;});
		}
		static if (uName !is null)
		{
			static if (uName[0].isAlphaNum)
			{
				mixin(q{alias }, uName, q{ = u;});
			}
			else static if (uName[0] != ' ')
			{
				ref Handle opOpAssign(string operator)(U v)
				if (operator == uName)
				{
					u(v);
					return this;
				}
			}
			else
			{
				ref Handle opAssign(U v)
				{
					u(v);
					return this;
				}
			}
		}
	}
	size_t[2] opSlice(size_t i)(size_t s, size_t e) if (i == 0)
	{
		return [s, e-1];
	}
	auto opIndex(size_t[2] slice)
	{
		return Handle(slice[0], slice[1], &this);
	}
}

import std.algorithm, std.array, std.container, std.conv, std.math, std.numeric, std.random, std.range, std.stdio, std.string, std.typecons, core.bitop;

void main()
{
  long t;
  readf!" %d "(t);
  while (t--) {
    int m;
    readf!" %d "(m);
    auto a = readln.strip.split.map!(to!long).array;
    auto b = readln.strip.split.map!(to!long).array;

    long[] sfa = [0L];
    long sum;
    foreach_reverse (x ; a) {
      sum += x;
      sfa ~= sum;
    }
    long[] pfb = [0L];
    sum = 0;
    foreach (x ; b) {
      sum += x;
      pfb ~= sum;
    }

    long min_bobscore = long.max;
    foreach (i ; 0 .. m) {
      long bobscore1 = pfb[i];
      long bobscore2 = sfa[$ - i - 2];
      long bobscore = max(bobscore1, bobscore2);
      if (bobscore < min_bobscore)
        min_bobscore = bobscore;
    }
    writeln(min_bobscore);
  }
}

import std;

T read (T, string ending = "", string beginning = "") () @trusted {
    scope T x;
    readf!(beginning ~ "%s" ~ ending)(x);
    return x;
}

void main () {
    immutable tests = read!(uint, "\n");
    TEST_LOOP: foreach (test_index; 0 .. tests) {
        immutable m = readln.chomp.to!uint;

        auto mat = (){
            auto result = appender!(uint[]);
            result.reserve(2 * m);

            foreach (line; stdin.byLine.take(2))
                result.put(line.splitter(' ').map!(to!uint));

            return chunks(result[].assumeUnique, m);
        }();

        immutable sum = mat[0].sum;

        StoppingPolicy.requireSameLength.zip(
            cumulativeFold!"a - b"(mat[0], sum),
            cumulativeFold!"a + b"(chain([0], mat[1].dropBackOne))
        ).map!"max(a.expand)".minElement.writeln;
    }
}

// "" `` '' () {} []

import std.stdio;
import std.ascii;
import std.algorithm;
import std.range;
import core.stdc.stdio;

void main()
{
	int t = readInt!int;
	while (t--) solve;
}
void solve()
{
	int m = readInt!int;
	auto a = new long[][](2, m);
	auto score = new long[](m);
	foreach(ref row; a) foreach(ref cell; row) cell = readInt!long;
	auto pf1 = a[0].cumulativeFold!((a, b) => a + b).array;
	auto pf2 = a[1].cumulativeFold!((a, b) => a + b).array;
	alias sum1 = (i, j) => (i > 0? pf1[j] - pf1[i - 1] : pf1[j]);
	alias sum2 = (i, j) => (i > 0? pf2[j] - pf2[i - 1] : pf2[j]);
	foreach(i; 0 .. m)
	{
		score[i] = sum1(0, i) + sum2(i, m - 1);
	}
	auto mxp = score.cumulativeFold!max.array; mxp[] -= a[0][0];
	auto mxs = score.reverse.cumulativeFold!max.array.reverse.array; mxs[] -= a[1][m-1];
	long minAns = long.max;
	foreach(i; 0 .. m)
	{
		auto p1 = i > 0? mxp[i - 1] - sum2(i, m - 1) : 0;
		auto p2 = i + 1 < m? mxs[i + 1] - sum1(0, i) : 0;
		minAns = min(minAns, max(p1, p2));
	}
	minAns.writeln;
}

/* INPUT ROUTINES */
int currChar;
static this()
{
	currChar = getchar();
}

char topChar()
{
	return cast(char) currChar;
}

void popChar()
{
	currChar = getchar();
}

auto readInt(T)()
{
	T num = 0;
	int sgn = 0;
	while (topChar.isWhite)
		popChar;
	while (topChar == '-' || topChar == '+')
	{
		sgn ^= (topChar == '-');
		popChar;
	}
	while (topChar.isDigit)
	{
		num *= 10;
		num += (topChar - '0');
		popChar;
	}
	if (sgn)
		return -num;
	return num;
}

string readString()
{
	string res = "";
	while (topChar.isWhite)
		popChar;
	while (!topChar.isWhite)
	{
		res ~= topChar;
		popChar;
	}
	return res;
}
/**MODULAR SYSTEM*/
struct Z(immutable long m)
{
	long rep;
	this(long num)
	{
		rep = num;
	}

	Z!m opBinary(string operator)(Z!m rhs)
	{
		static if (operator == "+")
		{
			long result = rhs.rep + this.rep;
			if (result >= m)
				result -= m;
			return Z!m(result);
		}
		else static if (operator == "-")
		{
			long result = this.rep - rhs.rep;
			if (result < 0)
				result += m;
			return Z!m(result);
		}
		else static if (operator == "*")
		{
			long result = this.rep * rhs.rep;
			if (result >= m)
				result %= m;
			return Z!m(result);
		}
		else
			static assert(text("Operator ", operator, " not supported"));
	}

	Z!m opBinary(string operator)(long exponent) if (operator == "^^")
	{
		assert(exponent >= 0);
		Z!m base = this;
		Z!m result = 1;
		while (exponent)
		{
			if (exponent & 1)
				result = result * base;
			base = base * base;
			exponent >>= 1;
		}
		return result;
	}

	invariant
	{
		assert(rep >= 0 && rep < m);
	}
}

import std.algorithm;
import std.random;

struct SegmentTreeLazy(V, U, alias f, alias fou, alias uou, string fName = null, string uName = null)
{
	alias This = typeof(this);
	size_t length;
	size_t realLength = 0;
	V[] _nodeFValue;
	U[] _nodeUpdate;
	bool[] _nodeHasUpdate;
	size_t[] _nodeRangeEnd;
	size_t[] _nodeRangeStart;
	string toString()
	{
		import std.conv;
		string str;
		foreach(i; 0 .. realLength)
			if (_nodeHasUpdate[i])
			{
				str ~= text(_nodeFValue[i], "(", _nodeUpdate[i], "), ");
			}
			else
			{
				str ~= text(_nodeFValue[i], ", ");
			}
		return str;
	}
	this(size_t length, V initialValue)
	{
		this.length = length;
		size_t noNodes = 4 * length;
		_nodeFValue = new V[](noNodes);
		_nodeUpdate = new U[](noNodes);
		_nodeHasUpdate = new bool[](noNodes);
		_nodeRangeEnd = new size_t[](noNodes);
		_nodeRangeStart = new size_t[](noNodes);
		void fill(size_t i, size_t rangeStart, size_t rangeEnd)
		{
			realLength = max(realLength, i + 1);
			_nodeRangeStart[i] = rangeStart;
			_nodeRangeEnd[i] = rangeEnd;
			if (_isLeaf(i)) { _nodeFValue[i] = initialValue; return; }
			size_t l = i<<1;
			size_t r = l+1;
			size_t m = (rangeStart + rangeEnd) / 2;
			fill(l, rangeStart, m), fill(r, m + 1, rangeEnd);
			_nodeFValue[i] = f(_nodeFValue[l], _nodeFValue[r]);
		}
		fill(1, 0, length - 1);
	}
	V rangeF(size_t start, size_t end)
	{
		bool set = false;
		V result;
		void visit(size_t i) in(_hasFragments(i, start, end))
		{
			if (_isFragment(i, start, end))
			{
				if (!set) { result = _cookedF(i); set = true; }
				else { result = f(result, _cookedF(i)); }
				return;
			}
			_clearUpdate(i);
			size_t l = i<<1, r = (i<<1)+1;
			if (_hasFragments(l, start, end)) visit(l);
			if (_hasFragments(r, start, end)) visit(r);
		}
		visit(1);
		return result;
	}
	void rangeU(size_t start, size_t end, U u)
	{
		void visit(size_t i) in(_hasFragments(i, start, end))
		{
			if (_isFragment(i, start, end))
			{
				_addUpdate(i, u);
				return;
			}
			_clearUpdate(i);
			size_t l = i<<1, r = (i<<1)+1;
			if (_hasFragments(l, start, end)) visit(l);
			if (_hasFragments(r, start, end)) visit(r);
			_nodeFValue[i] = f(_cookedF(l), _cookedF(r));
		}
		visit(1);
	}
	V _cookedF(size_t i)
	{
		if (_nodeHasUpdate[i]) { return fou(_nodeFValue[i],
						    _nodeUpdate[i],
						    _nodeRangeStart[i],
						    _nodeRangeEnd[i]); }
		return _nodeFValue[i];
	}
	void _clearUpdate(size_t i)
	{
		if (!_nodeHasUpdate[i]) return;
		if (_isLeaf(i)) { _nodeFValue[i] = _cookedF(i); _nodeHasUpdate[i] = false; return;}
		size_t l = i<<1, r = (i<<1)+1;
		_addUpdate(l, _nodeUpdate[i]), _addUpdate(r, _nodeUpdate[i]);
		_nodeFValue[i] = f(_cookedF(l), _cookedF(r));
		_nodeHasUpdate[i] = false;
	}
	void _addUpdate(size_t i, U u)
	{
		if (!_nodeHasUpdate[i]) { _nodeHasUpdate[i] = true; _nodeUpdate[i] = u; return; }
		_nodeUpdate[i] = uou(_nodeUpdate[i], u);
	}
	bool _isLeaf(size_t i)
	{
		return _nodeRangeStart[i] == _nodeRangeEnd[i];
	}
	bool _isFragment(size_t i, size_t rangeStart, size_t rangeEnd)
	{
		return rangeStart <= _nodeRangeStart[i] && _nodeRangeEnd[i] <= rangeEnd;
	}
	bool _hasFragments(size_t i, size_t rangeStart, size_t rangeEnd)
	{
		return _nodeRangeStart[i] <= rangeEnd && rangeStart <= _nodeRangeEnd[i];
	}
	// prettifiers
	struct Handle
	{
		import std.ascii;
		size_t _start, _end;
		This* _parent;
		auto f()
		{
			return _parent.rangeF(_start, _end);
		}
		auto u(U v)
		{
			_parent.rangeU(_start, _end, v);
		}
		static if (fName !is null)
		{
			mixin(q{alias }, fName, q{ = f;});
		}
		static if (uName !is null)
		{
			static if (uName[0].isAlphaNum)
			{
				mixin(q{alias }, uName, q{ = u;});
			}
			else static if (uName[0] != ' ')
			{
				ref Handle opOpAssign(string operator)(U v)
				if (operator == uName)
				{
					u(v);
					return this;
				}
			}
			else
			{
				ref Handle opAssign(U v)
				{
					u(v);
					return this;
				}
			}
		}
	}
	size_t[2] opSlice(size_t i)(size_t s, size_t e) if (i == 0)
	{
		return [s, e-1];
	}
	auto opIndex(size_t[2] slice)
	{
		return Handle(slice[0], slice[1], &this);
	}
}

import std.stdio;
import std.ascii;
import std.algorithm;
import std.range;
import core.stdc.stdio;

void main()
{
	int t = readInt!int;
	while (t--) solve;
}
void solve()
{
	int m = readInt!int;
	auto a = new long[][](2, m);
	auto score = SegmentTreeLazy!(long, long,
			(a, b) => max(a, b),
			(mx, u, rs, re) => u,
			(u1, u2) => u2,
			"max",
			" ")(m, 0);
	foreach(ref row; a) foreach(ref cell; row) cell = readInt!int;
	auto pf1 = a[0].cumulativeFold!((a, b) => a + b).array;
	auto pf2 = a[1].cumulativeFold!((a, b) => a + b).array;
	alias sum1 = (i, j) => (i > 0? pf1[j] - pf1[i - 1] : pf1[j]);
	alias sum2 = (i, j) => (i > 0? pf2[j] - pf2[i - 1] : pf2[j]);
	foreach(i; 0 .. m)
		score[i .. i + 1] = sum1(0, i) + sum2(i, m - 1);
	debug
	{
		foreach(i; 0 .. m) score[i .. i + 1].max.write(" ");
		writeln;
	}
	long minAns = long.max;
	foreach(i; 0 .. m)
	{
		auto p1 = i > 0? score[0 .. i].max - sum2(i, m - 1) - a[0][0] : 0;
		auto p2 = i + 1 < m? score[i + 1 .. m].max - sum1(0, i) - a[1][m-1] : 0;
		debug writeln("p1 = ", p1, " p2 = ", p2);
		minAns = min(minAns, max(p1, p2));
	}
	minAns.writeln;
}

/* INPUT ROUTINES */
int currChar;
static this()
{
	currChar = getchar();
}

char topChar()
{
	return cast(char) currChar;
}

void popChar()
{
	currChar = getchar();
}

auto readInt(T)()
{
	T num = 0;
	int sgn = 0;
	while (topChar.isWhite)
		popChar;
	while (topChar == '-' || topChar == '+')
	{
		sgn ^= (topChar == '-');
		popChar;
	}
	while (topChar.isDigit)
	{
		num *= 10;
		num += (topChar - '0');
		popChar;
	}
	if (sgn)
		return -num;
	return num;
}

string readString()
{
	string res = "";
	while (topChar.isWhite)
		popChar;
	while (!topChar.isWhite)
	{
		res ~= topChar;
		popChar;
	}
	return res;
}
/**MODULAR SYSTEM*/
struct Z(immutable long m)
{
	long rep;
	this(long num)
	{
		rep = num;
	}

	Z!m opBinary(string operator)(Z!m rhs)
	{
		static if (operator == "+")
		{
			long result = rhs.rep + this.rep;
			if (result >= m)
				result -= m;
			return Z!m(result);
		}
		else static if (operator == "-")
		{
			long result = this.rep - rhs.rep;
			if (result < 0)
				result += m;
			return Z!m(result);
		}
		else static if (operator == "*")
		{
			long result = this.rep * rhs.rep;
			if (result >= m)
				result %= m;
			return Z!m(result);
		}
		else
			static assert(text("Operator ", operator, " not supported"));
	}

	Z!m opBinary(string operator)(long exponent) if (operator == "^^")
	{
		assert(exponent >= 0);
		Z!m base = this;
		Z!m result = 1;
		while (exponent)
		{
			if (exponent & 1)
				result = result * base;
			base = base * base;
			exponent >>= 1;
		}
		return result;
	}

	invariant
	{
		assert(rep >= 0 && rep < m);
	}
}

import std.algorithm;
import std.random;

struct SegmentTreeLazy(V, U, alias f, alias fou, alias uou, string fName = null, string uName = null)
{
	alias This = typeof(this);
	size_t length;
	size_t realLength = 0;
	V[] _nodeFValue;
	U[] _nodeUpdate;
	bool[] _nodeHasUpdate;
	size_t[] _nodeRangeEnd;
	size_t[] _nodeRangeStart;
	string toString()
	{
		import std.conv;
		string str;
		foreach(i; 0 .. realLength)
			if (_nodeHasUpdate[i])
			{
				str ~= text(_nodeFValue[i], "(", _nodeUpdate[i], "), ");
			}
			else
			{
				str ~= text(_nodeFValue[i], ", ");
			}
		return str;
	}
	this(size_t length, V initialValue)
	{
		this.length = length;
		size_t noNodes = 4 * length;
		_nodeFValue = new V[](noNodes);
		_nodeUpdate = new U[](noNodes);
		_nodeHasUpdate = new bool[](noNodes);
		_nodeRangeEnd = new size_t[](noNodes);
		_nodeRangeStart = new size_t[](noNodes);
		void fill(size_t i, size_t rangeStart, size_t rangeEnd)
		{
			realLength = max(realLength, i + 1);
			_nodeRangeStart[i] = rangeStart;
			_nodeRangeEnd[i] = rangeEnd;
			if (_isLeaf(i)) { _nodeFValue[i] = initialValue; return; }
			size_t l = i<<1;
			size_t r = l+1;
			size_t m = (rangeStart + rangeEnd) / 2;
			fill(l, rangeStart, m), fill(r, m + 1, rangeEnd);
			_nodeFValue[i] = f(_nodeFValue[l], _nodeFValue[r]);
		}
		fill(1, 0, length - 1);
	}
	V rangeF(size_t start, size_t end)
	{
		bool set = false;
		V result;
		void visit(size_t i) in(_hasFragments(i, start, end))
		{
			if (_isFragment(i, start, end))
			{
				if (!set) { result = _cookedF(i); set = true; }
				else { result = f(result, _cookedF(i)); }
				return;
			}
			_clearUpdate(i);
			size_t l = i<<1, r = (i<<1)+1;
			if (_hasFragments(l, start, end)) visit(l);
			if (_hasFragments(r, start, end)) visit(r);
		}
		visit(1);
		return result;
	}
	void rangeU(size_t start, size_t end, U u)
	{
		void visit(size_t i) in(_hasFragments(i, start, end))
		{
			if (_isFragment(i, start, end))
			{
				_addUpdate(i, u);
				return;
			}
			_clearUpdate(i);
			size_t l = i<<1, r = (i<<1)+1;
			if (_hasFragments(l, start, end)) visit(l);
			if (_hasFragments(r, start, end)) visit(r);
			_nodeFValue[i] = f(_cookedF(l), _cookedF(r));
		}
		visit(1);
	}
	V _cookedF(size_t i)
	{
		if (_nodeHasUpdate[i]) { return fou(_nodeFValue[i],
						    _nodeUpdate[i],
						    _nodeRangeStart[i],
						    _nodeRangeEnd[i]); }
		return _nodeFValue[i];
	}
	void _clearUpdate(size_t i)
	{
		if (!_nodeHasUpdate[i]) return;
		if (_isLeaf(i)) { _nodeFValue[i] = _cookedF(i); _nodeHasUpdate[i] = false; return;}
		size_t l = i<<1, r = (i<<1)+1;
		_addUpdate(l, _nodeUpdate[i]), _addUpdate(r, _nodeUpdate[i]);
		_nodeFValue[i] = f(_cookedF(l), _cookedF(r));
		_nodeHasUpdate[i] = false;
	}
	void _addUpdate(size_t i, U u)
	{
		if (!_nodeHasUpdate[i]) { _nodeHasUpdate[i] = true; _nodeUpdate[i] = u; return; }
		_nodeUpdate[i] = uou(_nodeUpdate[i], u);
	}
	bool _isLeaf(size_t i)
	{
		return _nodeRangeStart[i] == _nodeRangeEnd[i];
	}
	bool _isFragment(size_t i, size_t rangeStart, size_t rangeEnd)
	{
		return rangeStart <= _nodeRangeStart[i] && _nodeRangeEnd[i] <= rangeEnd;
	}
	bool _hasFragments(size_t i, size_t rangeStart, size_t rangeEnd)
	{
		return _nodeRangeStart[i] <= rangeEnd && rangeStart <= _nodeRangeEnd[i];
	}
	// prettifiers
	struct Handle
	{
		import std.ascii;
		size_t _start, _end;
		This* _parent;
		auto f()
		{
			return _parent.rangeF(_start, _end);
		}
		auto u(U v)
		{
			_parent.rangeU(_start, _end, v);
		}
		static if (fName !is null)
		{
			mixin(q{alias }, fName, q{ = f;});
		}
		static if (uName !is null)
		{
			static if (uName[0].isAlphaNum)
			{
				mixin(q{alias }, uName, q{ = u;});
			}
			else static if (uName[0] != ' ')
			{
				ref Handle opOpAssign(string operator)(U v)
				if (operator == uName)
				{
					u(v);
					return this;
				}
			}
			else
			{
				ref Handle opAssign(U v)
				{
					u(v);
					return this;
				}
			}
		}
	}
	size_t[2] opSlice(size_t i)(size_t s, size_t e) if (i == 0)
	{
		return [s, e-1];
	}
	auto opIndex(size_t[2] slice)
	{
		return Handle(slice[0], slice[1], &this);
	}
}


You and your friends live in $$$n$$$ houses. Each house is located on a 2D plane, in a point with integer coordinates. There might be different houses located in the same point. The mayor of the city is asking you for places for the building of the Eastern exhibition. You have to find the number of places (points with integer coordinates), so that the summary distance from all the houses to the exhibition is minimal. The exhibition can be built in the same point as some house. The distance between two points $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$ is $$$|x_1 - x_2| + |y_1 - y_2|$$$, where $$$|x|$$$ is the absolute value of $$$x$$$.

First line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The first line of each test case contains a single integer $$$n$$$ $$$(1 \leq n \leq 1000)$$$. Next $$$n$$$ lines describe the positions of the houses $$$(x_i, y_i)$$$ $$$(0 \leq x_i, y_i \leq 10^9)$$$. It's guaranteed that the sum of all $$$n$$$ does not exceed $$$1000$$$.

For each test case output a single integer - the number of different positions for the exhibition. The exhibition can be built in the same point as some house.

NoteHere are the images for the example test cases. Blue dots stand for the houses, green — possible positions for the exhibition.First test case.Second test case. Third test case. Fourth test case. Fifth test case. Sixth test case. Here both houses are located at $$$(0, 0)$$$.

import std.stdio, std.algorithm;
long solve(long[] a)
{
    int n = cast(int) a.length;
    a.sort();
    return a[n / 2] - a[(n - 1) / 2] + 1;
}
void main()
{
    int q;
    readf!"%d\n"(q);
    foreach (_; 0 .. q)
    {
        int n;
        readf!"%d\n"(n);
        long[] a = new long[n], b = new long[n];
        foreach (i; 0 .. n)
            readf!"%d %d\n"(a[i], b[i]);
        writeln(solve(a) * solve(b));
    }
}

import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void get(Args...)(ref Args args)
{
    import std.traits, std.meta, std.typecons;

    static if (Args.length == 1) {
        alias Arg = Args[0];

        static if (isArray!Arg) {
          static if (isSomeChar!(ElementType!Arg)) {
            args[0] = readln.chomp.to!Arg;
          } else {
            args[0] = readln.split.to!Arg;
          }
        } else static if (isTuple!Arg) {
            auto input = readln.split;
            static foreach (i; 0..Fields!Arg.length) {
                args[0][i] = input[i].to!(Fields!Arg[i]);
            }
        } else {
            args[0] = readln.chomp.to!Arg;
        }
    } else {
        auto input = readln.split;
        assert(input.length == Args.length);

        static foreach (i; 0..Args.length) {
            args[i] = input[i].to!(Args[i]);
        }
    }
}

void get_lines(Args...)(size_t N, ref Args args)
{
    import std.traits, std.range;

    static foreach (i; 0..Args.length) {
        static assert(isArray!(Args[i]));
        args[i].length = N;
    }

    foreach (i; 0..N) {
        static if (Args.length == 1) {
            get(args[0][i]);
        } else {
            auto input = readln.split;
            static foreach (j; 0..Args.length) {
                args[j][i] = input[j].to!(ElementType!(Args[j]));
            }
        }
    }
}

void main()
{
    int T; get(T); while (T--) {
        int N; get(N);
        long[] xs, ys; get_lines(N, xs, ys);
        if (N % 2 == 1) {
            writeln(1);
            continue;
        }
        sort(xs);
        auto x = xs[N / 2] - xs[N / 2 - 1] + 1;
        sort(ys);
        auto y = ys[N / 2] - ys[N / 2 - 1] + 1;
        writeln(x * y);
    }
}

import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(ref long x, long y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto t = RD!int;
	auto ans = new long[](t);
	foreach (ti; 0..t)
	{
		auto n = RD!int;
		auto x = new long[](n);
		auto y = new long[](n);
		foreach (i; 0..n)
		{
			x[i] = RD;
			y[i] = RD;
		}
		x.sort;
		y.sort;

		long a, b;
		if (n % 2)
		{
			a = 1;
			b = 1;
		}
		else
		{
			a = x[n/2] - x[n/2-1] + 1;
			b = y[n/2] - y[n/2-1] + 1;
		}
		ans[ti] = a * b;
	}

	foreach (e; ans)
		writeln(e);
	stdout.flush;
	debug readln;
}


A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.Catacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number ti:   If Petya has visited this room before, he writes down the minute he was in this room last time;  Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i. Initially, Petya was in one of the rooms at minute 0, he didn't write down number t0.At some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?

The first line contains a single integer n (1 ≤ n ≤ 2·105) — then number of notes in Petya's logbook. The second line contains n non-negative integers t1, t2, ..., tn (0 ≤ ti < i) — notes in the logbook.

In the only line print a single integer — the minimum possible number of rooms in Paris catacombs.

NoteIn the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.In the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1.

// Try Codeforces
// author: Leonardone @ NEETSDKASU
import std.stdio      : readln, writeln;
import std.array      : split;
import std.string     : chomp;
import std.conv       : to;

void main()
{
    auto n = readln.chomp.to!int;
    auto ts = readln.chomp.split.to!(int[]);
    auto ord = new int[n + 1];
    auto tim = new int[n + 1];
    auto ans = n;
    ord[0] = 1;
    auto c = 1;
    foreach (i ; 1 .. n+1)
    {
        auto ti = ts[i-1];
        auto nm = ord[ti];
        if (ti == tim[nm])
        {
            tim[nm] = i;
            ord[i] = nm;
        }
        else
        {
            c++;
            tim[c] = i;
            ord[i] = c;
        }
    }
    ans = c;
    writeln(ans);
}