You are playing a strange game with Li Chen. You have a tree with $$$n$$$ nodes drawn on a piece of paper. All nodes are unlabeled and distinguishable. Each of you independently labeled the vertices from $$$1$$$ to $$$n$$$. Neither of you know the other's labelling of the tree.You and Li Chen each chose a subtree (i.e., a connected subgraph) in that tree. Your subtree consists of the vertices labeled $$$x_1, x_2, \ldots, x_{k_1}$$$ in your labeling, Li Chen's subtree consists of the vertices labeled $$$y_1, y_2, \ldots, y_{k_2}$$$ in his labeling. The values of $$$x_1, x_2, \ldots, x_{k_1}$$$ and $$$y_1, y_2, \ldots, y_{k_2}$$$ are known to both of you.   The picture shows two labelings of a possible tree: yours on the left and Li Chen's on the right. The selected trees are highlighted. There are two common nodes. You want to determine whether your subtrees have at least one common vertex. Luckily, your friend Andrew knows both labelings of the tree. You can ask Andrew at most $$$5$$$ questions, each of which is in one of the following two forms:   A x: Andrew will look at vertex $$$x$$$ in your labeling and tell you the number of this vertex in Li Chen's labeling.  B y: Andrew will look at vertex $$$y$$$ in Li Chen's labeling and tell you the number of this vertex in your labeling. Determine whether the two subtrees have at least one common vertex after asking some questions. If there is at least one common vertex, determine one of your labels for any of the common vertices.

NoteFor the first sample, Li Chen's hidden permutation is $$$[2, 3, 1]$$$, and for the second, his hidden permutation is $$$[5, 3, 2, 4, 1, 6]$$$ for both cases.In the first sample, there is a tree with three nodes in a line. On the top, is how you labeled the tree and the subtree you chose, and the bottom is how Li Chen labeled the tree and the subtree he chose:   In the first question, you ask Andrew to look at node $$$1$$$ in your labelling and tell you the label of it in Li Chen's labelling. Andrew responds with $$$2$$$. At this point, you know that both of your subtrees contain the same node (i.e. node $$$1$$$ according to your labeling), so you can output "C 1" and finish. However, you can also ask Andrew to look at node $$$2$$$ in Li Chen's labelling and tell you the label of it in your labelling. Andrew responds with $$$1$$$ (this step was given with the only reason — to show you how to ask questions).For the second sample, there are two test cases. The first looks is the one from the statement:   We first ask "B 2", and Andrew will tell us $$$3$$$. In this case, we know $$$3$$$ is a common vertex, and moreover, any subtree with size $$$3$$$ that contains node $$$3$$$ must contain node $$$1$$$ as well, so we can output either "C 1" or "C 3" as our answer.In the second case in the second sample, the situation looks as follows:   In this case, you know that the only subtree of size $$$3$$$ that doesn't contain node $$$1$$$ is subtree $$$4,5,6$$$. You ask Andrew for the label of node $$$1$$$ in Li Chen's labelling and Andrew says $$$5$$$. In this case, you know that Li Chen's subtree doesn't contain node $$$1$$$, so his subtree must be consist of the nodes $$$4,5,6$$$ (in your labelling), thus the two subtrees have no common nodes.


You are given $$$n$$$ points on the plane. The polygon formed from all the $$$n$$$ points is strictly convex, that is, the polygon is convex, and there are no three collinear points (i.e. lying in the same straight line). The points are numbered from $$$1$$$ to $$$n$$$, in clockwise order.We define the distance between two points $$$p_1 = (x_1, y_1)$$$ and $$$p_2 = (x_2, y_2)$$$ as their Manhattan distance: $$$$$$d(p_1, p_2) = |x_1 - x_2| + |y_1 - y_2|.$$$$$$Furthermore, we define the perimeter of a polygon, as the sum of Manhattan distances between all adjacent pairs of points on it; if the points on the polygon are ordered as $$$p_1, p_2, \ldots, p_k$$$ $$$(k \geq 3)$$$, then the perimeter of the polygon is $$$d(p_1, p_2) + d(p_2, p_3) + \ldots + d(p_k, p_1)$$$.For some parameter $$$k$$$, let's consider all the polygons that can be formed from the given set of points, having any $$$k$$$ vertices, such that the polygon is not self-intersecting. For each such polygon, let's consider its perimeter. Over all such perimeters, we define $$$f(k)$$$ to be the maximal perimeter.Please note, when checking whether a polygon is self-intersecting, that the edges of a polygon are still drawn as straight lines. For instance, in the following pictures:  In the middle polygon, the order of points ($$$p_1, p_3, p_2, p_4$$$) is not valid, since it is a self-intersecting polygon. The right polygon (whose edges resemble the Manhattan distance) has the same order and is not self-intersecting, but we consider edges as straight lines. The correct way to draw this polygon is ($$$p_1, p_2, p_3, p_4$$$), which is the left polygon.Your task is to compute $$$f(3), f(4), \ldots, f(n)$$$. In other words, find the maximum possible perimeter for each possible number of points (i.e. $$$3$$$ to $$$n$$$).

The first line contains a single integer $$$n$$$ ($$$3 \leq n \leq 3\cdot 10^5$$$) — the number of points.  Each of the next $$$n$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$-10^8 \leq x_i, y_i \leq 10^8$$$) — the coordinates of point $$$p_i$$$. The set of points is guaranteed to be convex, all points are distinct, the points are ordered in clockwise order, and there will be no three collinear points.

NoteIn the first example, for $$$f(3)$$$, we consider four possible polygons:   ($$$p_1, p_2, p_3$$$), with perimeter $$$12$$$.  ($$$p_1, p_2, p_4$$$), with perimeter $$$8$$$.  ($$$p_1, p_3, p_4$$$), with perimeter $$$12$$$.  ($$$p_2, p_3, p_4$$$), with perimeter $$$12$$$. For $$$f(4)$$$, there is only one option, taking all the given points. Its perimeter $$$14$$$.In the second example, there is only one possible polygon. Its perimeter is $$$8$$$.


There is an array $$$a$$$ of $$$2^{30}$$$ integers, indexed from $$$0$$$ to $$$2^{30}-1$$$. Initially, you know that $$$0 \leq a_i < 2^{30}$$$ ($$$0 \leq i < 2^{30}$$$), but you do not know any of the values. Your task is to process queries of two types: 1 l r x: You are informed that the bitwise xor of the subarray $$$[l, r]$$$ (ends inclusive) is equal to $$$x$$$. That is, $$$a_l \oplus a_{l+1} \oplus \ldots \oplus a_{r-1} \oplus a_r = x$$$, where $$$\oplus$$$ is the bitwise xor operator. In some cases, the received update contradicts past updates. In this case, you should ignore the contradicting update (the current update). 2 l r: You are asked to output the bitwise xor of the subarray $$$[l, r]$$$ (ends inclusive). If it is still impossible to know this value, considering all past updates, then output $$$-1$$$.Note that the queries are encoded. That is, you need to write an online solution.

The first line contains a single integer $$$q$$$ ($$$1 \leq q \leq 2 \cdot 10^5$$$) — the number of queries. Each of the next $$$q$$$ lines describes a query. It contains one integer $$$t$$$ ($$$1 \leq t \leq 2$$$) — the type of query. The given queries will be encoded in the following way: let $$$last$$$ be the answer to the last query of the second type that you have answered (initially, $$$last = 0$$$). If the last answer was $$$-1$$$, set $$$last = 1$$$.  If $$$t = 1$$$, three integers follow, $$$l'$$$, $$$r'$$$, and $$$x'$$$ ($$$0 \leq l', r', x' < 2^{30}$$$), meaning that you got an update. First, do the following: $$$l = l' \oplus last$$$, $$$r = r' \oplus last$$$, $$$x = x' \oplus last$$$ and, if $$$l > r$$$, swap $$$l$$$ and $$$r$$$.This means you got an update that the bitwise xor of the subarray $$$[l, r]$$$ is equal to $$$x$$$ (notice that you need to ignore updates that contradict previous updates). If $$$t = 2$$$, two integers follow, $$$l'$$$ and $$$r'$$$ ($$$0 \leq l', r' < 2^{30}$$$), meaning that you got a query. First, do the following: $$$l = l' \oplus last$$$, $$$r = r' \oplus last$$$ and, if $$$l > r$$$, swap $$$l$$$ and $$$r$$$.For the given query, you need to print the bitwise xor of the subarray $$$[l, r]$$$. If it is impossible to know, print $$$-1$$$. Don't forget to change the value of $$$last$$$. It is guaranteed there will be at least one query of the second type.

After every query of the second type, output the bitwise xor of the given subarray or $$$-1$$$ if it is still impossible to know.

NoteIn the first example, the real queries (without being encoded) are: 12 2 1 2 2 0 1073741823 1 1 2 5 2 1 1 2 2 2 2 1 2 1 2 3 6 2 1 1 1 1 3 0 2 1 1 2 2 2 2 3 3  The answers for the first two queries are $$$-1$$$ because we don't have any such information on the array initially.  The first update tells us $$$a_1 \oplus a_2 = 5$$$. Note that we still can't be certain about the values $$$a_1$$$ or $$$a_2$$$ independently (for example, it could be that $$$a_1 = 1, a_2 = 4$$$, and also $$$a_1 = 3, a_2 = 6$$$).  After we receive all three updates, we have enough information to deduce $$$a_1, a_2, a_3$$$ independently. In the second example, notice that after the first two updates we already know that $$$a_5 \oplus a_6 = 12$$$, so the third update is contradicting, and we ignore it.


You are given an $$$n \times m$$$ grid. Each grid cell is filled with a unique integer from $$$1$$$ to $$$nm$$$ so that each integer appears exactly once.In one operation, you can choose an arbitrary cycle of the grid and move all integers along that cycle one space over. Here, a cycle is any sequence that satisfies the following conditions:  There are at least four squares.  Each square appears at most once.  Every pair of adjacent squares, and also the first and last squares, share an edge. For example, if we had the following grid:  We can choose an arbitrary cycle like this one:  To get the following grid:  In this particular case, the chosen cycle can be represented as the sequence $$$[1, 2, 3, 6, 5, 8, 7, 4]$$$, the numbers are in the direction that we want to rotate them in.Find any sequence of operations to sort the grid so that the array created by concatenating the rows from the highest to the lowest is sorted (look at the first picture above).Note you do not need to minimize number of operations or sum of cycle lengths. The only constraint is that the sum of all cycles lengths must not be greater than $$$10^5$$$. We can show that an answer always exists under the given constraints. Output any valid sequence of moves that will sort the grid.

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$3 \leq n,m \leq 20$$$) — the dimensions of the grid. Each of the next $$$n$$$ lines contains $$$m$$$ integers $$$x_{i,1}, x_{i,2}, \ldots, x_{i, m}$$$ ($$$1 \leq x_{i,j} \leq nm$$$), denoting the values of the block in row $$$i$$$ and column $$$j$$$.  It is guaranteed that all $$$x_{i,j}$$$ are distinct.

First, print a single integer $$$k$$$, the number of operations ($$$k \geq 0$$$). On each of the next $$$k$$$ lines, print a cycle as follows: $$$$$$s\ y_1\ y_2\ \ldots\ y_s$$$$$$ Here, $$$s$$$ is the number of blocks to move ($$$s \geq 4$$$). Here we have block $$$y_1$$$ moving to where block $$$y_2$$$ is, block $$$y_2$$$ moving to where block $$$y_3$$$ is, and so on with block $$$y_s$$$ moving to where block $$$y_1$$$ is. The sum of $$$s$$$ over all operations must be at most $$$10^5$$$.

NoteThe first sample is the case in the statement. Here, we can use the cycle in reverse order to sort the grid.


On a chessboard with a width of $$$10^9$$$ and a height of $$$10^9$$$, the rows are numbered from bottom to top from $$$1$$$ to $$$10^9$$$, and the columns are numbered from left to right from $$$1$$$ to $$$10^9$$$. Therefore, for each cell of the chessboard you can assign the coordinates $$$(x,y)$$$, where $$$x$$$ is the column number and $$$y$$$ is the row number.Every day there are fights between black and white pieces on this board. Today, the black ones won, but at what price? Only the rook survived, and it was driven into the lower left corner — a cell with coordinates $$$(1,1)$$$. But it is still happy, because the victory has been won and it's time to celebrate it! In order to do this, the rook needs to go home, namely — on the upper side of the field (that is, in any cell that is in the row with number $$$10^9$$$).Everything would have been fine, but the treacherous white figures put spells on some places of the field before the end of the game. There are two types of spells:   Vertical. Each of these is defined by one number $$$x$$$. Such spells create an infinite blocking line between the columns $$$x$$$ and $$$x+1$$$.  Horizontal. Each of these is defined by three numbers $$$x_1$$$, $$$x_2$$$, $$$y$$$. Such spells create a blocking segment that passes through the top side of the cells, which are in the row $$$y$$$ and in columns from $$$x_1$$$ to $$$x_2$$$ inclusive. The peculiarity of these spells is that it is impossible for a certain pair of such spells to have a common point. Note that horizontal spells can have common points with vertical spells.    An example of a chessboard. Let's recall that the rook is a chess piece that in one move can move to any point that is in the same row or column with its initial position. In our task, the rook can move from the cell $$$(r_0,c_0)$$$ into the cell $$$(r_1,c_1)$$$ only under the condition that $$$r_1 = r_0$$$ or $$$c_1 = c_0$$$ and there is no blocking lines or blocking segments between these cells (For better understanding, look at the samples).Fortunately, the rook can remove spells, but for this it has to put tremendous efforts, therefore, it wants to remove the minimum possible number of spells in such way, that after this it can return home. Find this number!

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$0 \le n,m \le 10^5$$$) — the number of vertical and horizontal spells. Each of the following $$$n$$$ lines contains one integer $$$x$$$ ($$$1 \le x < 10^9$$$) — the description of the vertical spell. It will create a blocking line between the columns of $$$x$$$ and $$$x+1$$$. Each of the following $$$m$$$ lines contains three integers $$$x_1$$$, $$$x_2$$$ and $$$y$$$ ($$$1 \le x_{1} \le x_{2} \le 10^9$$$, $$$1 \le y < 10^9$$$) — the numbers that describe the horizontal spell. It will create a blocking segment that passes through the top sides of the cells that are in the row with the number $$$y$$$, in columns from $$$x_1$$$ to $$$x_2$$$ inclusive. It is guaranteed that all spells are different, as well as the fact that for each pair of horizontal spells it is true that the segments that describe them do not have common points.

In a single line print one integer — the minimum number of spells the rook needs to remove so it can get from the cell $$$(1,1)$$$ to at least one cell in the row with the number $$$10^9$$$

NoteIn the first sample, in order for the rook return home, it is enough to remove the second horizontal spell.  Illustration for the first sample. On the left it shows how the field looked at the beginning. On the right it shows how the field looked after the deletion of the second horizontal spell. It also shows the path, on which the rook would be going home. In the second sample, in order for the rook to return home, it is enough to remove the only vertical spell. If we tried to remove just one of the horizontal spells, it would not allow the rook to get home, because it would be blocked from above by one of the remaining horizontal spells (either first one or second one), and to the right it would be blocked by a vertical spell.  Illustration for the second sample. On the left it shows how the field looked at the beginning. On the right it shows how it looked after the deletion of the vertical spell. It also shows the path, on which the rook would be going home. In the third sample, we have two horizontal spells that go through the whole field. These spells can not be bypassed, so we need to remove both of them.  Illustration for the third sample. On the left it shows how the field looked at the beginning. On the right it shows how the field looked after the deletion of the horizontal spells. It also shows the path, on which the rook would be going home. In the fourth sample, we have no spells, which means that we do not need to remove anything.In the fifth example, we can remove the first vertical and third horizontal spells.  Illustration for the fifth sample. On the left it shows how the field looked at the beginning. On the right it shows how it looked after the deletions. It also shows the path, on which the rook would be going home.


Let $$$T$$$ be a tree on $$$n$$$ vertices. Consider a graph $$$G_0$$$, initially equal to $$$T$$$. You are given a sequence of $$$q$$$ updates, where the $$$i$$$-th update is given as a pair of two distinct integers $$$u_i$$$ and $$$v_i$$$. For every $$$i$$$ from $$$1$$$ to $$$q$$$, we define the graph $$$G_i$$$ as follows:   If $$$G_{i-1}$$$ contains an edge $$$\{u_i, v_i\}$$$, then remove this edge to form $$$G_i$$$.  Otherwise, add this edge to $$$G_{i-1}$$$ to form $$$G_i$$$.  Formally, $$$G_i := G_{i-1} \triangle \{\{u_i, v_i\}\}$$$ where $$$\triangle$$$ denotes the set symmetric difference. Furthermore, it is guaranteed that $$$T$$$ is always a subgraph of $$$G_i$$$. In other words, an update never removes an edge of $$$T$$$.Consider a connected graph $$$H$$$ and run a depth-first search on it. One can see that the tree edges (i.e. the edges leading to a not yet visited vertex at the time of traversal) form a spanning tree of the graph $$$H$$$. This spanning tree is not generally fixed for a particular graph — it depends on the starting vertex, and on the order in which the neighbors of each vertex are traversed. We call vertex $$$w$$$ good if one can order the neighbors of each vertex in such a way that the depth-first search started from $$$w$$$ produces $$$T$$$ as the spanning tree. For every $$$i$$$ from $$$1$$$ to $$$q$$$, find and report the number of good vertices.

The first line contains two integers $$$n$$$ and $$$q$$$ ($$$3 \le n \le 2\cdot 10^5$$$, $$$1 \le q \le 2 \cdot 10^5$$$) — the number of nodes and the number of updates, respectively. Each of the next $$$n-1$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1 \le u, v \le n$$$, $$$u \ne v$$$) — vertices connected by an edge in $$$T$$$. It is guaranteed that this graph is a tree. Each of the next $$$q$$$ lines contains two integers $$$u$$$ and $$$v$$$ ($$$1 \le u, v \le n$$$, $$$u \ne v$$$) — the endpoints of the edge that is added or removed. It is guaranteed that this edge does not belong to $$$T$$$.

For each update, print one integer $$$k$$$ — the number of good vertices $$$w$$$ after the corresponding update.

NoteThe first sample is depicted in the following figure.  After the first update, $$$G$$$ contains all three possible edges. The result of a DFS is as follows:   Let the starting vertex be $$$1$$$. We have two choices of ordering the neighbors of $$$1$$$, either $$$[2, 3]$$$ or $$$[3, 2]$$$.   If we choose the former, then we reach vertex $$$2$$$. Regardless of the ordering of its neighbors, the next visited vertex will be $$$3$$$. Thus, the spanning tree generated by this DFS will contain edges $$$\{1, 2\}$$$ and $$$\{2, 3\}$$$, which does not equal to $$$T$$$.  If we choose the latter, we obtain a spanning tree with edges $$$\{1, 3\}$$$ and $$$\{2, 3\}$$$.  Hence, there is no way of ordering the neighbors of vertices such that the DFS produces $$$T$$$, and subsequently $$$1$$$ is not a good vertex.  Let the starting vertex be $$$2$$$. We have two choices of traversing its neighbors. If we visit $$$3$$$ first, then the spanning tree will consist of edges $$$\{2,3\}$$$ and $$$\{1,3\}$$$, which is not equal to $$$T$$$. If we, however, visit $$$1$$$ first, then we can only continue to $$$3$$$ from here, and the spanning tree will consist of edges $$$\{1, 2\}$$$ and $$$\{1,3\}$$$, which equals to $$$T$$$. Hence, $$$2$$$ is a good vertex.  The case when we start in the vertex $$$3$$$ is symmetrical to starting in $$$2$$$, and hence $$$3$$$ is a good vertex.  Therefore, the answer is $$$2$$$.After the second update, the edge between $$$2$$$ and $$$3$$$ is removed, and $$$G = T$$$. It follows that the spanning tree generated by DFS will be always equal to $$$T$$$ independent of the choice of the starting vertex. Thus, the answer is $$$3$$$.In the second sample, the set of good vertices after the corresponding query is:   $$$\{2, 3, 5\}$$$  $$$\{3, 5\}$$$  $$$\{3, 4, 5\}$$$  $$$\{4, 5\}$$$  $$$\{4, 5, 6\}$$$  $$$\{5, 6\}$$$


In an unspecified solar system, there are $$$N$$$ planets. A space government company has recently hired space contractors to build $$$M$$$ bidirectional Hyperspace™ highways, each connecting two different planets. The primary objective, which was to make sure that every planet can be reached from any other planet taking only Hyperspace™ highways, has been completely fulfilled. Unfortunately, lots of space contractors had friends and cousins in the Space Board of Directors of the company, so the company decided to do much more than just connecting all planets. In order to make spending enormous amounts of space money for Hyperspace™ highways look neccessary, they decided to enforce a strict rule on the Hyperspace™ highway network: whenever there is a way to travel through some planets and return to the starting point without travelling through any planet twice, every pair of planets on the itinerary should be directly connected by a Hyperspace™ highway. In other words, the set of planets in every simple cycle induces a complete subgraph.You are designing a Hyperspace™ navigational app, and the key technical problem you are facing is finding the minimal number of Hyperspace™ highways one needs to use to travel from planet $$$A$$$ to planet $$$B$$$. As this problem is too easy for Bubble Cup, here is a harder task: your program needs to do it for $$$Q$$$ pairs of planets.

The first line contains three positive integers $$$N$$$ ($$$1\leq N\leq 100\,000$$$), $$$M$$$ ($$$1\leq M\leq 500\,000$$$) and $$$Q$$$ ($$$1\leq Q\leq 200\,000$$$), denoting the number of planets, the number of Hyperspace™ highways, and the number of queries, respectively. Each of the following M lines contains a highway: highway $$$i$$$ is given by two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \leq u_i < v_i \leq N$$$), meaning the planets $$$u_i$$$ and $$$v_i$$$ are connected by a Hyperspace™ highway. It is guaranteed that the network of planets and Hyperspace™ highways forms a simple connected graph. Each of the following $$$Q$$$ lines contains a query: query $$$j$$$ is given by two integers $$$a_j$$$ and $$$b_j$$$ $$$(1 \leq a_j < b_j \leq N )$$$, meaning we are interested in the minimal number of Hyperspace™ highways one needs to take to travel from planet $$$a_j$$$ to planet $$$b_j$$$.

Output $$$Q$$$ lines: the $$$j$$$-th line of output should contain the minimal number of Hyperspace™ highways one needs to take to travel from planet $$$a_j$$$ to planet $$$b_j$$$.


Everybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the bags is $$$\{0,1,…,M-1\}$$$, for some positive integer $$$M$$$. Ajs draws a number from the first bag and a number from the second bag, and then sums them modulo $$$M$$$.What are the residues modulo $$$M$$$ that Ajs cannot obtain with this action?

The first line contains two positive integer $$$N$$$ ($$$1 \leq N \leq 200\,000$$$) and $$$M$$$ ($$$N+1 \leq M \leq 10^{9}$$$), denoting the number of the elements in the first bag and the modulus, respectively. The second line contains $$$N$$$ nonnegative integers $$$a_1,a_2,\ldots,a_N$$$ ($$$0 \leq a_1<a_2< \ldots< a_N<M$$$), the contents of the first bag.

In the first line, output the cardinality $$$K$$$ of the set of residues modulo $$$M$$$ which Ajs cannot obtain. In the second line of the output, print $$$K$$$ space-separated integers greater or equal than zero and less than $$$M$$$, which represent the residues Ajs cannot obtain. The outputs should be sorted in increasing order of magnitude. If $$$K$$$=0, do not output the second line.

NoteIn the first sample, the first bag and the second bag contain $$$\{3,4\}$$$ and $$$\{0,1,2\}$$$, respectively. Ajs can obtain every residue modulo $$$5$$$ except the residue $$$2$$$: $$$ 4+1 \equiv 0, \, 4+2 \equiv 1, \, 3+0 \equiv 3, \, 3+1 \equiv 4 $$$ modulo $$$5$$$. One can check that there is no choice of elements from the first and the second bag which sum to $$$2$$$ modulo $$$5$$$.In the second sample, the contents of the first bag are $$$\{5,25,125,625\}$$$, while the second bag contains all other nonnegative integers with at most $$$9$$$ decimal digits. Every residue modulo $$$1\,000\,000\,000$$$ can be obtained as a sum of an element in the first bag and an element in the second bag.


It is the year 2969. 1000 years have passed from the moon landing. Meanwhile, the humanity colonized the Hyperspace™ and lived in harmony.Until we realized that we were not alone.Not too far away from the Earth, the massive fleet of aliens' spaceships is preparing to attack the Earth. For the first time in a while, the humanity is in real danger. Crisis and panic are everywhere. The scientists from all around the solar system have met and discussed the possible solutions. However, no progress has been made.The Earth's last hope is YOU!Fortunately, the Earth is equipped with very powerful defense systems made by MDCS. There are $$$N$$$ aliens' spaceships which form the line. The defense system consists of three types of weapons:   SQL rockets – every SQL rocket can destroy at most one spaceship in the given set. Cognition beams – every Cognition beam has an interval $$$[l,r]$$$ and can destroy at most one spaceship in that interval. OMG bazooka – every OMG bazooka has three possible targets, however, each bazooka can destroy either zero or exactly two spaceships. In addition, due to the smart targeting system, the sets of the three possible targets of any two different OMG bazookas are disjoint (that means that every ship is targeted with at most one OMG bazooka). Your task is to make a plan of the attack which will destroy the largest possible number of spaceships. Every destroyed spaceship should be destroyed with exactly one weapon.

The first line contains two integers: the number of your weapons $$$N$$$ $$$(1\leq N\leq 5000)$$$ and the number of spaceships $$$M$$$ $$$(1\leq M\leq 5000)$$$. In the next $$$N$$$ lines, each line starts with one integer that represents type (either 0, 1 or 2). If the type is 0, then the weapon is SQL rocket, the rest of the line contains strictly positive number $$$K$$$ $$$(\sum{K} \leq 100 000)$$$ and array $$$k_i$$$ $$$(1\leq k_i\leq M)$$$ of $$$K$$$ integers. If the type is 1, then the weapon is Cognition beam, the rest of the line contains integers $$$l$$$ and $$$r$$$ $$$(1\leq l\leq r\leq M)$$$. If the type is 2 then the weapon is OMG bazooka, the rest of the line contains distinct numbers $$$a$$$, $$$b$$$ and $$$c$$$ $$$ (1 \leq a,b,c \leq M)$$$.

The first line should contain the maximum number of destroyed spaceships — $$$X$$$. In the next $$$X$$$ lines, every line should contain two numbers $$$A$$$ and $$$B$$$, where $$$A$$$ is an index of the weapon and $$$B$$$ is an index of the spaceship which was destroyed by the weapon $$$A$$$.

NoteSQL rocket can destroy only 4th spaceship. OMG Bazooka can destroy two of 1st, 4th or 5th spaceship, and Cognition beam can destroy any spaceship from the interval $$$[1,4]$$$. The maximum number of destroyed spaceship is 4, and one possible plan is that SQL rocket should destroy 4th spaceship, OMG bazooka should destroy 1st and 5th spaceship and Cognition beam should destroy 2nd spaceship.


In the intergalactic empire Bubbledom there are $$$N$$$ planets, of which some pairs are directly connected by two-way wormholes. There are $$$N-1$$$ wormholes. The wormholes are of extreme religious importance in Bubbledom, a set of planets in Bubbledom consider themselves one intergalactic kingdom if and only if any two planets in the set can reach each other by traversing the wormholes. You are given that Bubbledom is one kingdom. In other words, the network of planets and wormholes is a tree.However, Bubbledom is facing a powerful enemy also possessing teleportation technology. The enemy attacks every night, and the government of Bubbledom retakes all the planets during the day. In a single attack, the enemy attacks every planet of Bubbledom at once, but some planets are more resilient than others. Planets are number $$$0,1,…,N-1$$$ and the planet $$$i$$$ will fall with probability $$$p_i$$$. Before every night (including the very first one), the government reinforces or weakens the defenses of a single planet.The government of Bubbledom is interested in the following question: what is the expected number of intergalactic kingdoms Bubbledom will be split into, after a single enemy attack (before they get a chance to rebuild)? In other words, you need to print the expected number of connected components after every attack.

The first line contains one integer number $$$N$$$ ($$$1 \le N \le 10^5$$$) denoting the number of planets in Bubbledom (numbered from $$$0$$$ to $$$N-1$$$).  The next line contains $$$N$$$ different real numbers in the interval $$$[0,1]$$$, specified with 2 digits after the decimal point, denoting the probabilities that the corresponding planet will fall. The next $$$N-1$$$ lines contain all the wormholes in Bubbledom, where a wormhole is specified by the two planets it connects. The next line contains a positive integer $$$Q$$$ ($$$1 \le Q \le 10^5$$$), denoting the number of enemy attacks. The next $$$Q$$$ lines each contain a non-negative integer and a real number from interval $$$[0,1]$$$, denoting the planet the government of Bubbledom decided to reinforce or weaken, along with the new probability that the planet will fall.

Output contains $$$Q$$$ numbers, each of which represents the expected number of kingdoms that are left after each enemy attack. Your answers will be considered correct if their absolute or relative error does not exceed $$$10^{-4}$$$.


On the surface of a newly discovered planet, which we model by a plane, explorers found remains of two different civilizations in various locations. They would like to learn more about those civilizations and to explore the area they need to build roads between some of locations. But as always, there are some restrictions:   Every two locations of the same civilization are connected by a unique path of roads  No two locations from different civilizations may have road between them (explorers don't want to accidentally mix civilizations they are currently exploring)  Roads must be straight line segments  Since intersections are expensive to build, they don't want any two roads to intersect (that is, only common point for any two roads may be at some of locations) Obviously all locations are different points in the plane, but explorers found out one more interesting information that may help you – no three locations lie on the same line!Help explorers and find a solution for their problem, or report it is impossible.

In the first line, integer $$$n$$$ $$$(1 \leq n \leq 10^3)$$$ - the number of locations discovered. In next $$$n$$$ lines, three integers $$$x, y, c$$$ $$$(0 \leq x, y \leq 10^4, c \in \{0, 1\})$$$ - coordinates of the location and number of civilization it belongs to.

In first line print number of roads that should be built. In the following lines print all pairs of locations (their $$$0$$$-based indices) that should be connected with a road. If it is not possible to build roads such that all restrictions are met, print "Impossible". You should not print the quotation marks.


Ani and Borna are playing a short game on a two-variable polynomial. It's a special kind of a polynomial: the monomials are fixed, but all of its coefficients are fill-in-the-blanks dashes, e.g. $$$$$$ \_ xy + \_ x^4 y^7 + \_ x^8 y^3 + \ldots $$$$$$Borna will fill in the blanks with positive integers. He wants the polynomial to be bounded from below, i.e. his goal is to make sure there exists a real number $$$M$$$ such that the value of the polynomial at any point is greater than $$$M$$$.  Ani is mischievous, and wants the polynomial to be unbounded. Along with stealing Borna's heart, she can also steal parts of polynomials. Ani is only a petty kind of thief, though: she can only steal at most one monomial from the polynomial before Borna fills in the blanks. If Ani and Borna play their only moves optimally, who wins?

The first line contains a positive integer $$$N$$$ $$$(2 \leq N \leq 200\, 000)$$$, denoting the number of the terms in the starting special polynomial. Each of the following $$$N$$$ lines contains a description of a monomial: the $$$k$$$-th line contains two **space**-separated integers $$$a_k$$$ and $$$b_k$$$ $$$(0 \leq a_k, b_k \leq 10^9$$$) which mean the starting polynomial has the term $$$\_ x^{a_k} y^{b_k}$$$. It is guaranteed that for $$$k \neq l$$$, either $$$a_k \neq a_l$$$ or $$$b_k \neq b_l$$$.

If Borna can always choose the coefficients such that the resulting polynomial is bounded from below, regardless of what monomial Ani steals, output "Borna". Else, output "Ani".  You shouldn't output the quotation marks.

NoteIn the first sample, the initial polynomial is $$$\_xy+ \_x^2 + \_y^2$$$. If Ani steals the $$$\_y^2$$$ term, Borna is left with $$$\_xy+\_x^2$$$. Whatever positive integers are written on the blanks, $$$y \rightarrow -\infty$$$ and $$$x := 1$$$ makes the whole expression go to negative infinity.In the second sample, the initial polynomial is $$$\_1 + \_x + \_x^2 + \_x^8$$$. One can check that no matter what term Ani steals, Borna can always win.


In the last mission, MDCS has successfully shipped $$$N$$$ AI robots to Mars. Before they start exploring, system initialization is required so they are arranged in a line. Every robot can be described with three numbers: position ($$$x_i$$$), radius of sight ($$$r_i$$$) and IQ ($$$q_i$$$).Since they are intelligent robots, some of them will talk if they see each other. Radius of sight is inclusive, so robot can see other all robots in range $$$[x_i - r_i, x_i + r_i]$$$. But they don't walk to talk with anybody, but only with robots who have similar IQ. By similar IQ we mean that their absolute difference isn't more than $$$K$$$.  Help us and calculate how many pairs of robots are going to talk with each other, so we can timely update their software and avoid any potential quarrel.

The first line contains two integers, numbers $$$N (1 \leq N \leq 10^5) $$$ and $$$K (0 \leq K \leq 20)$$$. Next $$$N$$$ lines contain three numbers each $$$x_i, r_i, q_i (0 \leq x_i,r_i,q_i \leq 10^9)$$$ — position, radius of sight and IQ of every robot respectively.

Output contains only one number — solution to the problem.

NoteThe first robot can see the second, but not vice versa. The first robot can't even see the third. The second and the third robot can see each other and their IQs don't differ more than 2 so only one conversation will happen.


Being bored of exploring the Moon over and over again Wall-B decided to explore something he is made of — binary numbers. He took a binary number and decided to count how many times different substrings of length two appeared. He stored those values in $$$c_{00}$$$, $$$c_{01}$$$, $$$c_{10}$$$ and $$$c_{11}$$$, representing how many times substrings 00, 01, 10 and 11 appear in the number respectively. For example: $$$10111100 \rightarrow c_{00} = 1, \ c_{01} = 1,\ c_{10} = 2,\ c_{11} = 3$$$ $$$10000 \rightarrow c_{00} = 3,\ c_{01} = 0,\ c_{10} = 1,\ c_{11} = 0$$$ $$$10101001 \rightarrow c_{00} = 1,\ c_{01} = 3,\ c_{10} = 3,\ c_{11} = 0$$$ $$$1 \rightarrow c_{00} = 0,\ c_{01} = 0,\ c_{10} = 0,\ c_{11} = 0$$$Wall-B noticed that there can be multiple binary numbers satisfying the same $$$c_{00}$$$, $$$c_{01}$$$, $$$c_{10}$$$ and $$$c_{11}$$$ constraints. Because of that he wanted to count how many binary numbers satisfy the constraints $$$c_{xy}$$$ given the interval $$$[A, B]$$$. Unfortunately, his processing power wasn't strong enough to handle large intervals he was curious about. Can you help him? Since this number can be large print it modulo $$$10^9 + 7$$$.

First two lines contain two positive binary numbers $$$A$$$ and $$$B$$$ ($$$1 \leq A \leq B < 2^{100\,000}$$$), representing the start and the end of the interval respectively. Binary numbers $$$A$$$ and $$$B$$$ have no leading zeroes. Next four lines contain decimal numbers $$$c_{00}$$$, $$$c_{01}$$$, $$$c_{10}$$$ and $$$c_{11}$$$ ($$$0 \leq c_{00}, c_{01}, c_{10}, c_{11} \leq 100\,000$$$) representing the count of two-digit substrings 00, 01, 10 and 11 respectively.

Output one integer number representing how many binary numbers in the interval $$$[A, B]$$$ satisfy the constraints mod $$$10^9 + 7$$$.

NoteExample 1: The binary numbers in the interval $$$[10,1001]$$$ are $$$10,11,100,101,110,111,1000,1001$$$. Only number 110 satisfies the constraints: $$$c_{00} = 0, c_{01} = 0, c_{10} = 1, c_{11} = 1$$$.Example 2: No number in the interval satisfies the constraints


After learning a lot about space exploration, a little girl named Ana wants to change the subject.Ana is a girl who loves palindromes (string that can be read the same backwards as forward). She has learned how to check for a given string whether it's a palindrome or not, but soon she grew tired of this problem, so she came up with a more interesting one and she needs your help to solve it:You are given an array of strings which consist of only small letters of the alphabet. Your task is to find how many palindrome pairs are there in the array. A palindrome pair is a pair of strings such that the following condition holds: at least one permutation of the concatenation of the two strings is a palindrome. In other words, if you have two strings, let's say "aab" and "abcac", and you concatenate them into "aababcac", we have to check if there exists a permutation of this new string such that it is a palindrome (in this case there exists the permutation "aabccbaa"). Two pairs are considered different if the strings are located on different indices. The pair of strings with indices $$$(i,j)$$$ is considered the same as the pair $$$(j,i)$$$.

The first line contains a positive integer $$$N$$$ ($$$1 \le N \le 100\,000$$$), representing the length of the input array. Eacg of the next $$$N$$$ lines contains a string (consisting of lowercase English letters from 'a' to 'z') — an element of the input array.  The total number of characters in the input array will be less than $$$1\,000\,000$$$.

Output one number, representing how many palindrome pairs there are in the array.

NoteThe first example:  aa $$$+$$$ bb $$$\to$$$ abba. The second example:  aab $$$+$$$ abcac $$$=$$$ aababcac $$$\to$$$ aabccbaa aab $$$+$$$ aa $$$=$$$ aabaa abcac $$$+$$$ aa $$$=$$$ abcacaa $$$\to$$$ aacbcaa dffe $$$+$$$ ed $$$=$$$ dffeed $$$\to$$$ fdeedf dffe $$$+$$$ aade $$$=$$$ dffeaade $$$\to$$$ adfaafde ed $$$+$$$ aade $$$=$$$ edaade $$$\to$$$ aeddea


Since astronauts from BubbleCup XI mission finished their mission on the Moon and are big fans of famous singer, they decided to spend some fun time before returning to the Earth and hence created a so called "Moonwalk challenge" game.Teams of astronauts are given the map of craters on the Moon and direct bidirectional paths from some craters to others that are safe for "Moonwalking". Each of those direct paths is colored in one color and there is unique path between each two craters. Goal of the game is to find two craters such that given array of colors appears most times as continuous subarray on the path between those two craters (overlapping appearances should be counted).To help your favorite team win, you should make a program that, given the map, answers the queries of the following type: For two craters and array of colors answer how many times given array appears as continuous subarray on the path from the first crater to the second.Colors are represented as lowercase English alphabet letters.

In the first line, integer $$$N$$$ $$$(2 \leq N \leq 10^5)$$$ — number of craters on the Moon. Craters are numerated with numbers $$$1$$$ to $$$N$$$. In next $$$N-1$$$ lines, three values $$$u, v, L$$$ $$$(1 \leq u, v \leq N, L \in \{a, ..., z\})$$$ — denoting that there is a direct path with color $$$L$$$ between craters $$$u$$$ and $$$v$$$. Next line contains integer $$$Q$$$ $$$(1 \leq Q \leq 10^5)$$$ — number of queries. Next $$$Q$$$ lines contain three values $$$u, v$$$ $$$(1 \leq u, v \leq N)$$$ and $$$S$$$ $$$(|S| \leq 100)$$$, where $$$u$$$ and $$$v$$$ are the two cratersfor which you should find how many times array of colors $$$S$$$ (represented as string) appears on the path from $$$u$$$ to $$$v$$$.

For each query output one number that represents number of occurrences of array S on the path from $$$u$$$ to $$$v$$$.


Two friends are travelling through Bubble galaxy. They say "Hello!" via signals to each other if their distance is smaller or equal than $$$d_1$$$ and    it's the first time they speak to each other or   at some point in time after their last talk their distance was greater than $$$d_2$$$. We need to calculate how many times friends said "Hello!" to each other. For $$$N$$$ moments, you'll have an array of points for each friend representing their positions at that moment. A person can stay in the same position between two moments in time, but if a person made a move we assume this movement as movement with constant speed in constant direction.

The first line contains one integer number $$$N$$$ ($$$2 \leq N \leq 100\,000$$$) representing number of moments in which we captured positions for two friends. The second line contains two integer numbers $$$d_1$$$ and $$$d_2 \ (0 < d_1 < d_2 < 1000)$$$.  The next $$$N$$$ lines contains four integer numbers $$$A_x,A_y,B_x,B_y$$$ ($$$0 \leq A_x, A_y, B_x, B_y \leq 1000$$$) representing coordinates of friends A and B in each captured moment.

Output contains one integer number that represents how many times friends will say "Hello!" to each other.

Note Explanation: Friends should send signals 2 times to each other, first time around point $$$A2$$$ and $$$B2$$$ and second time during A's travel from point $$$A3$$$ to $$$A4$$$ while B stays in point $$$B3=B4$$$.


After finding and moving to the new planet that supports human life, discussions started on which currency should be used. After long negotiations, Bitcoin was ultimately chosen as the universal currency.These were the great news for Alice, whose grandfather got into Bitcoin mining in 2013, and accumulated a lot of them throughout the years. Unfortunately, when paying something in bitcoin everyone can see how many bitcoins you have in your public address wallet. This worried Alice, so she decided to split her bitcoins among multiple different addresses, so that every address has at most $$$x$$$ satoshi (1 bitcoin = $$$10^8$$$ satoshi). She can create new public address wallets for free and is willing to pay $$$f$$$ fee in satoshi per transaction to ensure acceptable speed of transfer. The fee is deducted from the address the transaction was sent from. Tell Alice how much total fee in satoshi she will need to pay to achieve her goal.

First line contains number $$$N$$$ ($$$1 \leq N \leq 200\,000$$$) representing total number of public addresses Alice has. Next line contains $$$N$$$ integer numbers $$$a_i$$$ ($$$1 \leq a_i \leq 10^9$$$) separated by a single space, representing how many satoshi Alice has in her public addresses. Last line contains two numbers $$$x$$$, $$$f$$$ ($$$1 \leq f < x \leq 10^9$$$) representing maximum number of satoshies Alice can have in one address, as well as fee in satoshies she is willing to pay per transaction.

Output one integer number representing total fee in satoshi Alice will need to pay to achieve her goal.

NoteAlice can make two transactions in a following way:0. 13 7 6 (initial state)1. 6 7 6 5 (create new address and transfer from first public address 5 satoshies)2. 6 4 6 5 1 (create new address and transfer from second address 1 satoshi)Since cost per transaction is 2 satoshies, total fee is 4.


Little C loves number «3» very much. He loves all things about it.Now he has a positive integer $$$n$$$. He wants to split $$$n$$$ into $$$3$$$ positive integers $$$a,b,c$$$, such that $$$a+b+c=n$$$ and none of the $$$3$$$ integers is a multiple of $$$3$$$. Help him to find a solution.

A single line containing one integer $$$n$$$ ($$$3 \leq n \leq 10^9$$$) — the integer Little C has.

Print $$$3$$$ positive integers $$$a,b,c$$$ in a single line, such that $$$a+b+c=n$$$ and none of them is a multiple of $$$3$$$. It can be proved that there is at least one solution. If there are multiple solutions, print any of them.


There are $$$n$$$ points on the plane, $$$(x_1,y_1), (x_2,y_2), \ldots, (x_n,y_n)$$$.You need to place an isosceles triangle with two sides on the coordinate axis to cover all points (a point is covered if it lies inside the triangle or on the side of the triangle). Calculate the minimum length of the shorter side of the triangle.

First line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^5$$$). Each of the next $$$n$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \leq x_i,y_i \leq 10^9$$$).

Print the minimum length of the shorter side of the triangle. It can be proved that it's always an integer.

NoteIllustration for the first example: Illustration for the second example:


Formula 1 officials decided to introduce new competition. Cars are replaced by space ships and number of points awarded can differ per race.Given the current ranking in the competition and points distribution for the next race, your task is to calculate the best possible ranking for a given astronaut after the next race. It's guaranteed that given astronaut will have unique number of points before the race.

The first line contains two integer numbers $$$N$$$ ($$$1 \leq N \leq 200000$$$) representing number of F1 astronauts, and current position of astronaut $$$D$$$ ($$$1 \leq D \leq N$$$) you want to calculate best ranking for (no other competitor will have the same number of points before the race). The second line contains $$$N$$$ integer numbers $$$S_k$$$ ($$$0 \leq S_k \leq 10^8$$$, $$$k=1...N$$$), separated by a single space, representing current ranking of astronauts. Points are sorted in non-increasing order. The third line contains $$$N$$$ integer numbers $$$P_k$$$ ($$$0 \leq P_k \leq 10^8$$$, $$$k=1...N$$$), separated by a single space, representing point awards for the next race. Points are sorted in non-increasing order, so winner of the race gets the maximum number of points.

Output contains one integer number — the best possible ranking for astronaut after the race. If multiple astronauts have the same score after the race, they all share the best ranking.

NoteIf the third ranked astronaut wins the race, he will have 35 points. He cannot take the leading position, but he can overtake the second position if the second ranked astronaut finishes the race at the last position.


You are given a set of all integers from $$$l$$$ to $$$r$$$ inclusive, $$$l < r$$$, $$$(r - l + 1) \le 3 \cdot 10^5$$$ and $$$(r - l)$$$ is always odd.You want to split these numbers into exactly $$$\frac{r - l + 1}{2}$$$ pairs in such a way that for each pair $$$(i, j)$$$ the greatest common divisor of $$$i$$$ and $$$j$$$ is equal to $$$1$$$. Each number should appear in exactly one of the pairs.Print the resulting pairs or output that no solution exists. If there are multiple solutions, print any of them.

If any solution exists, print "YES" in the first line. Each of the next $$$\frac{r - l + 1}{2}$$$ lines should contain some pair of integers. GCD of numbers in each pair should be equal to $$$1$$$. All $$$(r - l + 1)$$$ numbers should be pairwise distinct and should have values from $$$l$$$ to $$$r$$$ inclusive. If there are multiple solutions, print any of them. If there exists no solution, print "NO".


You are given a grid, consisting of $$$2$$$ rows and $$$n$$$ columns. Each cell of this grid should be colored either black or white.Two cells are considered neighbours if they have a common border and share the same color. Two cells $$$A$$$ and $$$B$$$ belong to the same component if they are neighbours, or if there is a neighbour of $$$A$$$ that belongs to the same component with $$$B$$$.Let's call some bicoloring beautiful if it has exactly $$$k$$$ components.Count the number of beautiful bicolorings. The number can be big enough, so print the answer modulo $$$998244353$$$.

The only line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 1000$$$, $$$1 \le k \le 2n$$$) — the number of columns in a grid and the number of components required.

Print a single integer — the number of beautiful bicolorings modulo $$$998244353$$$.

NoteOne of possible bicolorings in sample $$$1$$$:


Vasya has a multiset $$$s$$$ consisting of $$$n$$$ integer numbers. Vasya calls some number $$$x$$$ nice if it appears in the multiset exactly once. For example, multiset $$$\{1, 1, 2, 3, 3, 3, 4\}$$$ contains nice numbers $$$2$$$ and $$$4$$$.Vasya wants to split multiset $$$s$$$ into two multisets $$$a$$$ and $$$b$$$ (one of which may be empty) in such a way that the quantity of nice numbers in multiset $$$a$$$ would be the same as the quantity of nice numbers in multiset $$$b$$$ (the quantity of numbers to appear exactly once in multiset $$$a$$$ and the quantity of numbers to appear exactly once in multiset $$$b$$$).

The first line contains a single integer $$$n~(2 \le n \le 100)$$$. The second line contains $$$n$$$ integers $$$s_1, s_2, \dots s_n~(1 \le s_i \le 100)$$$ — the multiset $$$s$$$.

If there exists no split of $$$s$$$ to satisfy the given requirements, then print "NO" in the first line. Otherwise print "YES" in the first line. The second line should contain a string, consisting of $$$n$$$ characters. $$$i$$$-th character should be equal to 'A' if the $$$i$$$-th element of multiset $$$s$$$ goes to multiset $$$a$$$ and 'B' if if the $$$i$$$-th element of multiset $$$s$$$ goes to multiset $$$b$$$. Elements are numbered from $$$1$$$ to $$$n$$$ in the order they are given in the input. If there exist multiple solutions, then print any of them.


Vasya owns three big integers — $$$a, l, r$$$. Let's define a partition of $$$x$$$ such a sequence of strings $$$s_1, s_2, \dots, s_k$$$ that $$$s_1 + s_2 + \dots + s_k = x$$$, where $$$+$$$ is a concatanation of strings. $$$s_i$$$ is the $$$i$$$-th element of the partition. For example, number $$$12345$$$ has the following partitions: ["1", "2", "3", "4", "5"], ["123", "4", "5"], ["1", "2345"], ["12345"] and lots of others.Let's call some partition of $$$a$$$ beautiful if each of its elements contains no leading zeros.Vasya want to know the number of beautiful partitions of number $$$a$$$, which has each of $$$s_i$$$ satisfy the condition $$$l \le s_i \le r$$$. Note that the comparison is the integer comparison, not the string one.Help Vasya to count the amount of partitions of number $$$a$$$ such that they match all the given requirements. The result can be rather big, so print it modulo $$$998244353$$$.

The first line contains a single integer $$$a~(1 \le a \le 10^{1000000})$$$. The second line contains a single integer $$$l~(0 \le l \le 10^{1000000})$$$. The third line contains a single integer $$$r~(0 \le r \le 10^{1000000})$$$. It is guaranteed that $$$l \le r$$$. It is also guaranteed that numbers $$$a, l, r$$$ contain no leading zeros.

Print a single integer — the amount of partitions of number $$$a$$$ such that they match all the given requirements modulo $$$998244353$$$.

NoteIn the first test case, there are two good partitions $$$13+5$$$ and $$$1+3+5$$$.In the second test case, there is one good partition $$$1+0+0+0+0$$$.


Vasya came up with a password to register for EatForces — a string $$$s$$$. The password in EatForces should be a string, consisting of lowercase and uppercase Latin letters and digits.But since EatForces takes care of the security of its users, user passwords must contain at least one digit, at least one uppercase Latin letter and at least one lowercase Latin letter. For example, the passwords "abaCABA12", "Z7q" and "3R24m" are valid, and the passwords "qwerty", "qwerty12345" and "Password" are not. A substring of string $$$s$$$ is a string $$$x = s_l s_{l + 1} \dots s_{l + len - 1} (1 \le l \le |s|, 0 \le len \le |s| - l + 1)$$$. $$$len$$$ is the length of the substring. Note that the empty string is also considered a substring of $$$s$$$, it has the length $$$0$$$.Vasya's password, however, may come too weak for the security settings of EatForces. He likes his password, so he wants to replace some its substring with another string of the same length in order to satisfy the above conditions. This operation should be performed exactly once, and the chosen string should have the minimal possible length.Note that the length of $$$s$$$ should not change after the replacement of the substring, and the string itself should contain only lowercase and uppercase Latin letters and digits.

The first line contains a single integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of testcases. Each of the next $$$T$$$ lines contains the initial password $$$s~(3 \le |s| \le 100)$$$, consisting of lowercase and uppercase Latin letters and digits. Only $$$T = 1$$$ is allowed for hacks.

For each testcase print a renewed password, which corresponds to given conditions.  The length of the replaced substring is calculated as following: write down all the changed positions. If there are none, then the length is $$$0$$$. Otherwise the length is the difference between the first and the last changed position plus one. For example, the length of the changed substring between the passwords "abcdef" $$$\rightarrow$$$ "a7cdEf" is $$$4$$$, because the changed positions are $$$2$$$ and $$$5$$$, thus $$$(5 - 2) + 1 = 4$$$. It is guaranteed that such a password always exists. If there are several suitable passwords — output any of them.

NoteIn the first example Vasya's password lacks a digit, he replaces substring "C" with "4" and gets password "abcD4E". That means, he changed the substring of length 1.In the second example Vasya's password is ok from the beginning, and nothing has to be changed. That is the same as replacing the empty substring with another empty substring (length 0).


You are given a weighed undirected connected graph, consisting of $$$n$$$ vertices and $$$m$$$ edges.You should answer $$$q$$$ queries, the $$$i$$$-th query is to find the shortest distance between vertices $$$u_i$$$ and $$$v_i$$$.

The first line contains two integers $$$n$$$ and $$$m~(1 \le n, m \le 10^5, m - n \le 20)$$$ — the number of vertices and edges in the graph. Next $$$m$$$ lines contain the edges: the $$$i$$$-th edge is a triple of integers $$$v_i, u_i, d_i~(1 \le u_i, v_i \le n, 1 \le d_i \le 10^9, u_i \neq v_i)$$$. This triple means that there is an edge between vertices $$$u_i$$$ and $$$v_i$$$ of weight $$$d_i$$$. It is guaranteed that graph contains no self-loops and multiple edges. The next line contains a single integer $$$q~(1 \le q \le 10^5)$$$ — the number of queries. Each of the next $$$q$$$ lines contains two integers $$$u_i$$$ and $$$v_i~(1 \le u_i, v_i \le n)$$$ — descriptions of the queries. Pay attention to the restriction $$$m - n ~ \le ~ 20$$$.

Print $$$q$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th query — the shortest distance between vertices $$$u_i$$$ and $$$v_i$$$.


Suppose you are given a sequence $$$S$$$ of $$$k$$$ pairs of integers $$$(a_1, b_1), (a_2, b_2), \dots, (a_k, b_k)$$$.You can perform the following operations on it:  Choose some position $$$i$$$ and increase $$$a_i$$$ by $$$1$$$. That can be performed only if there exists at least one such position $$$j$$$ that $$$i \ne j$$$ and $$$a_i = a_j$$$. The cost of this operation is $$$b_i$$$;  Choose some position $$$i$$$ and decrease $$$a_i$$$ by $$$1$$$. That can be performed only if there exists at least one such position $$$j$$$ that $$$a_i = a_j + 1$$$. The cost of this operation is $$$-b_i$$$. Each operation can be performed arbitrary number of times (possibly zero).Let $$$f(S)$$$ be minimum possible $$$x$$$ such that there exists a sequence of operations with total cost $$$x$$$, after which all $$$a_i$$$ from $$$S$$$ are pairwise distinct. Now for the task itself ...You are given a sequence $$$P$$$ consisting of $$$n$$$ pairs of integers $$$(a_1, b_1), (a_2, b_2), \dots, (a_n, b_n)$$$. All $$$b_i$$$ are pairwise distinct. Let $$$P_i$$$ be the sequence consisting of the first $$$i$$$ pairs of $$$P$$$. Your task is to calculate the values of $$$f(P_1), f(P_2), \dots, f(P_n)$$$.

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of pairs in sequence $$$P$$$. Next $$$n$$$ lines contain the elements of $$$P$$$: $$$i$$$-th of the next $$$n$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ ($$$1 \le a_i \le 2 \cdot 10^5$$$, $$$1 \le b_i \le n$$$). It is guaranteed that all values of $$$b_i$$$ are pairwise distinct.

Print $$$n$$$ integers — the $$$i$$$-th number should be equal to $$$f(P_i)$$$.


Euler is a little, cute squirrel. When the autumn comes, he collects some reserves for winter. The interesting fact is that Euler likes to collect acorns in a specific way. A tree can be described as $$$n$$$ acorns connected by $$$n - 1$$$ branches, such that there is exactly one way between each pair of acorns. Let's enumerate the acorns from $$$1$$$ to $$$n$$$.The squirrel chooses one acorn (not necessary with number $$$1$$$) as a start, and visits them in a way called "Euler tour" (see notes), collecting each acorn when he visits it for the last time.Today morning Kate was observing Euler. She took a sheet of paper and wrote down consecutive indices of acorns on his path. Unfortunately, during her way to home it started raining and some of numbers became illegible. Now the girl is very sad, because she has to present the observations to her teacher."Maybe if I guess the lacking numbers, I'll be able to do it!" she thought. Help her and restore any valid Euler tour of some tree or tell that she must have made a mistake.

The first line contains a single integer $$$n$$$ ($$$1 \leq n \leq 5 \cdot 10^5$$$), denoting the number of acorns in the tree. The second line contains $$$2n - 1$$$ integers $$$a_1, a_2, \ldots, a_{2n-1}$$$ ($$$0 \leq a_i \leq n$$$) — the Euler tour of the tree that Kate wrote down. $$$0$$$ means an illegible number, which has to be guessed.

If there is no Euler tour satisfying the given description, output "no" in the first line. Otherwise, on the first line output "yes", and then in the second line print the Euler tour which satisfy the given description. Any valid Euler tour will be accepted, since the teacher doesn't know how exactly the initial tree looks.

NoteAn Euler tour of a tree with $$$n$$$ acorns is a sequence of $$$2n - 1$$$ indices of acorns. such that each acorn occurs at least once, the first and the last acorns are same and each two consecutive acorns are directly connected with a branch.


Masha lives in a multi-storey building, where floors are numbered with positive integers. Two floors are called adjacent if their numbers differ by one. Masha decided to visit Egor. Masha lives on the floor $$$x$$$, Egor on the floor $$$y$$$ (not on the same floor with Masha).The house has a staircase and an elevator. If Masha uses the stairs, it takes $$$t_1$$$ seconds for her to walk between adjacent floors (in each direction). The elevator passes between adjacent floors (in each way) in $$$t_2$$$ seconds. The elevator moves with doors closed. The elevator spends $$$t_3$$$ seconds to open or close the doors. We can assume that time is not spent on any action except moving between adjacent floors and waiting for the doors to open or close. If Masha uses the elevator, it immediately goes directly to the desired floor.Coming out of the apartment on her floor, Masha noticed that the elevator is now on the floor $$$z$$$ and has closed doors. Now she has to choose whether to use the stairs or use the elevator. If the time that Masha needs to get to the Egor's floor by the stairs is strictly less than the time it will take her using the elevator, then she will use the stairs, otherwise she will choose the elevator.Help Mary to understand whether to use the elevator or the stairs.

The only line contains six integers $$$x$$$, $$$y$$$, $$$z$$$, $$$t_1$$$, $$$t_2$$$, $$$t_3$$$ ($$$1 \leq x, y, z, t_1, t_2, t_3 \leq 1000$$$) — the floor Masha is at, the floor Masha wants to get to, the floor the elevator is located on, the time it takes Masha to pass between two floors by stairs, the time it takes the elevator to pass between two floors and the time it takes for the elevator to close or open the doors. It is guaranteed that $$$x \ne y$$$.

If the time it will take to use the elevator is not greater than the time it will take to use the stairs, print «YES» (without quotes), otherwise print «NO> (without quotes). You can print each letter in any case (upper or lower).

NoteIn the first example:If Masha goes by the stairs, the time she spends is $$$4 \cdot 4 = 16$$$, because she has to go $$$4$$$ times between adjacent floors and each time she spends $$$4$$$ seconds. If she chooses the elevator, she will have to wait $$$2$$$ seconds while the elevator leaves the $$$4$$$-th floor and goes to the $$$5$$$-th. After that the doors will be opening for another $$$1$$$ second. Then Masha will enter the elevator, and she will have to wait for $$$1$$$ second for the doors closing. Next, the elevator will spend $$$4 \cdot 2 = 8$$$ seconds going from the $$$5$$$-th floor to the $$$1$$$-st, because the elevator has to pass $$$4$$$ times between adjacent floors and spends $$$2$$$ seconds each time. And finally, it will take another $$$1$$$ second before the doors are open and Masha can come out. Thus, all the way by elevator will take $$$2 + 1 + 1 + 8 + 1 = 13$$$ seconds, which is less than $$$16$$$ seconds, so Masha has to choose the elevator.In the second example, it is more profitable for Masha to use the stairs, because it will take $$$13$$$ seconds to use the elevator, that is more than the $$$10$$$ seconds it will takes to go by foot.In the third example, the time it takes to use the elevator is equal to the time it takes to walk up by the stairs, and is equal to $$$12$$$ seconds. That means Masha will take the elevator.


Initially Ildar has an empty array. He performs $$$n$$$ steps. On each step he takes a subset of integers already added to the array and appends the mex of this subset to the array. The mex of an multiset of integers is the smallest non-negative integer not presented in the multiset. For example, the mex of the multiset $$$[0, 2, 3]$$$ is $$$1$$$, while the mex of the multiset $$$[1, 2, 1]$$$ is $$$0$$$.More formally, on the step $$$m$$$, when Ildar already has an array $$$a_1, a_2, \ldots, a_{m-1}$$$, he chooses some subset of indices $$$1 \leq i_1 < i_2 < \ldots < i_k < m$$$ (possibly, empty), where $$$0 \leq k < m$$$, and appends the $$$mex(a_{i_1}, a_{i_2}, \ldots a_{i_k})$$$ to the end of the array.After performing all the steps Ildar thinks that he might have made a mistake somewhere. He asks you to determine for a given array $$$a_1, a_2, \ldots, a_n$$$ the minimum step $$$t$$$ such that he has definitely made a mistake on at least one of the steps $$$1, 2, \ldots, t$$$, or determine that he could have obtained this array without mistakes.

The first line contains a single integer $$$n$$$ ($$$1 \leq n \leq 100\,000$$$) — the number of steps Ildar made. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \leq a_i \leq 10^9$$$) — the array Ildar obtained.

If Ildar could have chosen the subsets on each step in such a way that the resulting array is $$$a_1, a_2, \ldots, a_n$$$, print $$$-1$$$. Otherwise print a single integer $$$t$$$ — the smallest index of a step such that a mistake was made on at least one step among steps $$$1, 2, \ldots, t$$$.

NoteIn the first example it is possible that Ildar made no mistakes. Here is the process he could have followed.  $$$1$$$-st step. The initial array is empty. He can choose an empty subset and obtain $$$0$$$, because the mex of an empty set is $$$0$$$. Appending this value to the end he gets the array $$$[0]$$$.  $$$2$$$-nd step. The current array is $$$[0]$$$. He can choose a subset $$$[0]$$$ and obtain an integer $$$1$$$, because $$$mex(0) = 1$$$. Appending this value to the end he gets the array $$$[0,1]$$$.  $$$3$$$-rd step. The current array is $$$[0,1]$$$. He can choose a subset $$$[0,1]$$$ and obtain an integer $$$2$$$, because $$$mex(0,1) = 2$$$. Appending this value to the end he gets the array $$$[0,1,2]$$$.  $$$4$$$-th step. The current array is $$$[0,1,2]$$$. He can choose a subset $$$[0]$$$ and obtain an integer $$$1$$$, because $$$mex(0) = 1$$$. Appending this value to the end he gets the array $$$[0,1,2,1]$$$. Thus, he can get the array without mistakes, so the answer is $$$-1$$$.In the second example he has definitely made a mistake on the very first step, because he could not have obtained anything different from $$$0$$$.In the third example he could have obtained $$$[0, 1, 2]$$$ without mistakes, but $$$239$$$ is definitely wrong.


There are $$$n$$$ children numbered from $$$1$$$ to $$$n$$$ in a kindergarten. Kindergarten teacher gave $$$a_i$$$ ($$$1 \leq a_i \leq n$$$) candies to the $$$i$$$-th child. Children were seated in a row in order from $$$1$$$ to $$$n$$$ from left to right and started eating candies. While the $$$i$$$-th child was eating candies, he calculated two numbers $$$l_i$$$ and $$$r_i$$$ — the number of children seating to the left of him that got more candies than he and the number of children seating to the right of him that got more candies than he, respectively.Formally, $$$l_i$$$ is the number of indices $$$j$$$ ($$$1 \leq j < i$$$), such that $$$a_i < a_j$$$ and $$$r_i$$$ is the number of indices $$$j$$$ ($$$i < j \leq n$$$), such that $$$a_i < a_j$$$.Each child told to the kindergarten teacher the numbers $$$l_i$$$ and $$$r_i$$$ that he calculated. Unfortunately, she forgot how many candies she has given to each child. So, she asks you for help: given the arrays $$$l$$$ and $$$r$$$ determine whether she could have given the candies to the children such that all children correctly calculated their values $$$l_i$$$ and $$$r_i$$$, or some of them have definitely made a mistake. If it was possible, find any way how she could have done it.

On the first line there is a single integer $$$n$$$ ($$$1 \leq n \leq 1000$$$) — the number of children in the kindergarten. On the next line there are $$$n$$$ integers $$$l_1, l_2, \ldots, l_n$$$ ($$$0 \leq l_i \leq n$$$), separated by spaces. On the next line, there are $$$n$$$ integer numbers $$$r_1, r_2, \ldots, r_n$$$ ($$$0 \leq r_i \leq n$$$), separated by spaces.

If there is no way to distribute the candies to the children so that all of them calculated their numbers correctly, print «NO» (without quotes). Otherwise, print «YES» (without quotes) on the first line. On the next line, print $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$, separated by spaces — the numbers of candies the children $$$1, 2, \ldots, n$$$ received, respectively. Note that some of these numbers can be equal, but all numbers should satisfy the condition $$$1 \leq a_i \leq n$$$. The number of children seating to the left of the $$$i$$$-th child that got more candies than he should be equal to $$$l_i$$$ and the number of children seating to the right of the $$$i$$$-th child that got more candies than he should be equal to $$$r_i$$$. If there is more than one solution, find any of them.

NoteIn the first example, if the teacher distributed $$$1$$$, $$$3$$$, $$$1$$$, $$$2$$$, $$$1$$$ candies to $$$1$$$-st, $$$2$$$-nd, $$$3$$$-rd, $$$4$$$-th, $$$5$$$-th child, respectively, then all the values calculated by the children are correct. For example, the $$$5$$$-th child was given $$$1$$$ candy, to the left of him $$$2$$$ children were given $$$1$$$ candy, $$$1$$$ child was given $$$2$$$ candies and $$$1$$$ child — $$$3$$$ candies, so there are $$$2$$$ children to the left of him that were given more candies than him.In the second example it is impossible to distribute the candies, because the $$$4$$$-th child made a mistake in calculating the value of $$$r_4$$$, because there are no children to the right of him, so $$$r_4$$$ should be equal to $$$0$$$.In the last example all children may have got the same number of candies, that's why all the numbers are $$$0$$$. Note that each child should receive at least one candy.


At a break Vanya came to the class and saw an array of $$$n$$$ $$$k$$$-bit integers $$$a_1, a_2, \ldots, a_n$$$ on the board. An integer $$$x$$$ is called a $$$k$$$-bit integer if $$$0 \leq x \leq 2^k - 1$$$. Of course, Vanya was not able to resist and started changing the numbers written on the board. To ensure that no one will note anything, Vanya allowed himself to make only one type of changes: choose an index of the array $$$i$$$ ($$$1 \leq i \leq n$$$) and replace the number $$$a_i$$$ with the number $$$\overline{a_i}$$$. We define $$$\overline{x}$$$ for a $$$k$$$-bit integer $$$x$$$ as the $$$k$$$-bit integer such that all its $$$k$$$ bits differ from the corresponding bits of $$$x$$$. Vanya does not like the number $$$0$$$. Therefore, he likes such segments $$$[l, r]$$$ ($$$1 \leq l \leq r \leq n$$$) such that $$$a_l \oplus a_{l+1} \oplus \ldots \oplus a_r \neq 0$$$, where $$$\oplus$$$ denotes the bitwise XOR operation. Determine the maximum number of segments he likes Vanya can get applying zero or more operations described above.

The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \leq n \leq 200\,000$$$, $$$1 \leq k \leq 30$$$). The next line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$0 \leq a_i \leq 2^k - 1$$$), separated by spaces — the array of $$$k$$$-bit integers.

Print one integer — the maximum possible number of segments with XOR not equal to $$$0$$$ that can be obtained by making several (possibly $$$0$$$) operations described in the statement.

NoteIn the first example if Vasya does not perform any operations, he gets an array that has $$$5$$$ segments that Vanya likes. If he performs the operation with $$$i = 2$$$, he gets an array $$$[1, 0, 0]$$$, because $$$\overline{3} = 0$$$ when $$$k = 2$$$. This array has $$$3$$$ segments that Vanya likes. Also, to get an array with $$$5$$$ segments that Vanya likes, he can perform two operations with $$$i = 3$$$ and with $$$i = 2$$$. He then gets an array $$$[1, 0, 3]$$$. It can be proven that he can't obtain $$$6$$$ or more segments that he likes.In the second example, to get $$$19$$$ segments that Vanya likes, he can perform $$$4$$$ operations with $$$i = 3$$$, $$$i = 4$$$, $$$i = 5$$$, $$$i = 6$$$ and get an array $$$[1, 4, 3, 0, 4, 3]$$$.


Egor came up with a new chips puzzle and suggests you to play.The puzzle has the form of a table with $$$n$$$ rows and $$$m$$$ columns, each cell can contain several black or white chips placed in a row. Thus, the state of the cell can be described by a string consisting of characters '0' (a white chip) and '1' (a black chip), possibly empty, and the whole puzzle can be described as a table, where each cell is a string of zeros and ones. The task is to get from one state of the puzzle some other state.To do this, you can use the following operation.  select 2 different cells $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$: the cells must be in the same row or in the same column of the table, and the string in the cell $$$(x_1, y_1)$$$ must be non-empty;  in one operation you can move the last character of the string at the cell $$$(x_1, y_1)$$$ to the beginning of the string at the cell $$$(x_2, y_2)$$$. Egor came up with two states of the table for you: the initial state and the final one. It is guaranteed that the number of zeros and ones in the tables are the same. Your goal is with several operations get the final state from the initial state. Of course, Egor does not want the number of operations to be very large. Let's denote as $$$s$$$ the number of characters in each of the tables (which are the same). Then you should use no more than $$$4 \cdot s$$$ operations.

The first line contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq n, m \leq 300$$$) — the number of rows and columns of the table, respectively. The following $$$n$$$ lines describe the initial state of the table in the following format: each line contains $$$m$$$ non-empty strings consisting of zeros and ones. In the $$$i$$$-th of these lines, the $$$j$$$-th string is the string written at the cell $$$(i, j)$$$. The rows are enumerated from $$$1$$$ to $$$n$$$, the columns are numerated from $$$1$$$ to $$$m$$$. The following $$$n$$$ lines describe the final state of the table in the same format. Let's denote the total length of strings in the initial state as $$$s$$$. It is guaranteed that $$$s \leq 100\, 000$$$. It is also guaranteed that the numbers of zeros and ones coincide in the initial and final states.

On the first line print $$$q$$$ — the number of operations used. You should find such a solution that $$$0 \leq q \leq 4 \cdot s$$$.  In each the next $$$q$$$ lines print 4 integers $$$x_1$$$, $$$y_1$$$, $$$x_2$$$, $$$y_2$$$. On the $$$i$$$-th line you should print the description of the $$$i$$$-th operation. These integers should satisfy the conditions $$$1 \leq x_1, x_2 \leq n$$$, $$$1 \leq y_1, y_2 \leq m$$$, $$$(x_1, y_1) \neq (x_2, y_2)$$$, $$$x_1 = x_2$$$ or $$$y_1 = y_2$$$. The string in the cell $$$(x_1, y_1)$$$ should be non-empty. This sequence of operations should transform the initial state of the table to the final one. We can show that a solution exists. If there is more than one solution, find any of them.

NoteConsider the first example.  The current state of the table:00 1001 11The first operation. The cell $$$(2, 1)$$$ contains the string $$$01$$$. Applying the operation to cells $$$(2, 1)$$$ and $$$(1, 1)$$$, we move the $$$1$$$ from the end of the string $$$01$$$ to the beginning of the string $$$00$$$ and get the string $$$100$$$. The current state of the table:100 100   11The second operation. The cell $$$(1, 1)$$$ contains the string $$$100$$$. Applying the operation to cells $$$(1, 1)$$$ and $$$(1, 2)$$$, we move the $$$0$$$ from the end of the string $$$100$$$ to the beginning of the string $$$10$$$ and get the string $$$010$$$. The current state of the table:10 0100  11The third operation. The cell $$$(1, 2)$$$ contains the string $$$010$$$. Applying the operation to cells $$$(1, 2)$$$ and $$$(2, 2)$$$, we move the $$$0$$$ from the end of the string $$$010$$$ to the beginning of the string $$$11$$$ and get the string $$$011$$$. The current state of the table:10 010  011The fourth operation. The cell $$$(2, 2)$$$ contains the string $$$011$$$. Applying the operation to cells $$$(2, 2)$$$ and $$$(2, 1)$$$, we move the $$$1$$$ from the end of the string $$$011$$$ to the beginning of the string $$$0$$$ and get the string $$$10$$$. The current state of the table:10 0110 01 It's easy to see that we have reached the final state of the table.


Pasha is a young technician, nevertheless, he has already got a huge goal: to assemble a PC. The first task he has to become familiar with is to assemble an electric scheme.The scheme Pasha assembled yesterday consists of several wires. Each wire is a segment that connects two points on a plane with integer coordinates within the segment $$$[1, 10^9]$$$.There are wires of two colors in the scheme:   red wires: these wires are horizontal segments, i.e. if such a wire connects two points $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, then $$$y_1 = y_2$$$;  blue wires: these wires are vertical segments, i.e. if such a wire connects two points $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$, then $$$x_1 = x_2$$$. Note that if a wire connects a point to itself, it may be blue, and it can be red. Also, in Pasha's scheme no two wires of the same color intersect, i.e. there are no two wires of same color that have common points.The imperfection of Pasha's scheme was that the wires were not isolated, so in the points where two wires of different colors intersect, Pasha saw sparks. Pasha wrote down all the points where he saw sparks and obtained a set of $$$n$$$ distinct points. After that he disassembled the scheme.Next morning Pasha looked at the set of $$$n$$$ points where he had seen sparks and wondered how many wires had he used. Unfortunately, he does not remember that, so he wonders now what is the smallest number of wires he might have used in the scheme. Help him to determine this number and place the wires in such a way that in the resulting scheme the sparks occur in the same places.

The first line contains a single integer $$$n$$$ ($$$1 \leq n \leq 1000$$$) — the number of points where Pasha saw sparks. Each of the next $$$n$$$ lines contain two integers $$$x$$$ and $$$y$$$ ($$$1 \leq x, y \leq 10^9$$$) — the coordinates of a point with sparks. It is guaranteed that all points are distinct.

Print the description of the scheme in the following format. In the first line print $$$h$$$ — the number of horizontal red wires ($$$0 \leq h$$$). In each of the next $$$h$$$ lines print $$$4$$$ integers $$$x_1$$$, $$$y_1$$$, $$$x_2$$$, $$$y_2$$$ — the coordinates of two points $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$ that are connected with this red wire. The segmenst must be horizontal, i.e. $$$y_1 = y_2$$$ must hold. Also, the constraint $$$1 \leq x_1, y_1, x_2, y_2 \leq 10^9$$$ must hold. After that print $$$v$$$ — the number of vertical blue wires ($$$0 \leq v$$$). In each of the next $$$v$$$ lines print $$$4$$$ integers $$$x_1$$$, $$$y_1$$$, $$$x_2$$$, $$$y_2$$$ — the coordinates of two points $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$ that are connected with this blue wire. The segmenst must be vertical, i.e. $$$x_1 = x_2$$$ shomustuld hold. Also, the constraint $$$1 \leq x_1, y_1, x_2, y_2 \leq 10^9$$$ must hold. No two segments of the same color should have common points. The set of points where sparks appear should be the same as given in the input. The number of segments $$$(h + v)$$$ should be minimum possible. It's easy to see that the answer always exists. If there are multiple possible answers, print any.

NoteIn the first example Pasha could have assembled the following scheme:  In this scheme there are $$$2$$$ wires of each color: red ones connecting $$$(5, 2)$$$ with $$$(1, 2)$$$ and $$$(1, 4)$$$ with $$$(5, 4)$$$, blue ones connecting $$$(2, 1)$$$ with $$$(2, 5)$$$ and $$$(4, 5)$$$ with $$$(4, 1)$$$. Note that the sparks appear in the points that are described in the input, they are shown in yellow on the picture. For example, Pasha will see the spark in the point $$$(2, 4)$$$ because the second red wire and the first blue wire intersect there. It is possible to show that we can't have less than $$$4$$$ wires to produce a scheme with same sparks positions.


The king of some country $$$N$$$ decided to completely rebuild the road network. There are $$$n$$$ people living in the country, they are enumerated from $$$1$$$ to $$$n$$$. It is possible to construct a road between the house of any citizen $$$a$$$ to the house of any other citizen $$$b$$$. There should not be more than one road between any pair of citizens. The road network must be connected, i.e. it should be possible to reach every citizen starting from anyone using roads. To save funds, it was decided to build exactly $$$n-1$$$ road, so the road network should be a tree.However, it is not that easy as it sounds, that's why the king addressed you for help. There are $$$m$$$ secret communities in the country, each of them unites a non-empty subset of citizens. The king does not want to conflict with any of the communities, so he wants to build the network such that the houses of members of each society form a connected subtree in network. A set of vertices forms a connected subtree if and only if the graph remains connected when we delete all the other vertices and all edges but ones that connect the vertices from the set.Help the king to determine if it is possible to build the desired road network, and if it is, build it.

Each test consists of one or more test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 2000$$$) — the number of test cases. The following lines describe the test cases, each in the following format. The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 2000$$$) — the number of citizens and the number of secret communities.  The next $$$m$$$ lines contain the description of the communities. The $$$i$$$-th of these lines contains a string $$$s_i$$$ of length $$$n$$$, consisting of characters '0' and '1'. The citizen with number $$$j$$$ is a member of the $$$i$$$-th community if and only if $$$s_{{i}{j}}=1$$$. It is guaranteed that the string $$$s_i$$$ contains at least one character '1' for each $$$1 \leq i \leq m$$$. It is guaranteed that the sum of $$$n$$$ for all test cases does not exceed $$$2000$$$ and the sum of $$$m$$$ for all test cases does not exceed $$$2000$$$.

Print the answer for all test cases in the order they are given in the input, each in the following format. If there is no way to build the desired road network, print "NO" (without quotes). Otherwise in the first line print "YES" (without quotes). In the next $$$n-1$$$ lines print the description of the road network: each line should contain two integers $$$a$$$ and $$$b$$$ ($$$1 \leq a, b \leq n$$$, $$$a \neq b$$$) that denote you build a road between houses of citizens $$$a$$$ and $$$b$$$.  The roads should form a connected tree, and each community should form a connected subtree.

NoteIn the first example you can build the following network:  It is easy to see that for each community all the houses of its members form a connected subtree. For example, the $$$2$$$-nd community unites the citizens $$$1$$$, $$$2$$$, $$$3$$$. They form a connected subtree, because if we delete everything except the houses $$$1$$$, $$$2$$$, $$$3$$$ and the roads between them, two roads will remain: between $$$1$$$ and $$$3$$$ and between $$$2$$$ and $$$3$$$, forming a connected graph.There is no network in the second example suitable for the king.


You are given two arrays $$$a_0, a_1, \ldots, a_{n - 1}$$$ and $$$b_0, b_1, \ldots, b_{m-1}$$$, and an integer $$$c$$$.Compute the following sum:$$$$$$\sum_{i=0}^{n-1} \sum_{j=0}^{m-1} a_i b_j c^{i^2\,j^3}$$$$$$Since it's value can be really large, print it modulo $$$490019$$$.

First line contains three integers $$$n$$$, $$$m$$$ and $$$c$$$ ($$$1 \le n, m \le 100\,000$$$, $$$1 \le c < 490019$$$). Next line contains exactly $$$n$$$ integers $$$a_i$$$ and defines the array $$$a$$$ ($$$0 \le a_i \le 1000$$$). Last line contains exactly $$$m$$$ integers $$$b_i$$$ and defines the array $$$b$$$ ($$$0 \le b_i \le 1000$$$).

Print one integer — value of the sum modulo $$$490019$$$.

NoteIn the first example, the only non-zero summand corresponds to $$$i = 1$$$, $$$j = 1$$$ and is equal to $$$1 \cdot 1 \cdot 3^1 = 3$$$.In the second example, all summands are equal to $$$1$$$.


Bob and Alice are often participating in various programming competitions. Like many competitive programmers, Alice and Bob have good and bad days. They noticed, that their lucky and unlucky days are repeating with some period. For example, for Alice days $$$[l_a; r_a]$$$ are lucky, then there are some unlucky days: $$$[r_a + 1; l_a + t_a - 1]$$$, and then there are lucky days again: $$$[l_a + t_a; r_a + t_a]$$$ and so on. In other words, the day is lucky for Alice if it lies in the segment $$$[l_a + k t_a; r_a + k t_a]$$$ for some non-negative integer $$$k$$$.The Bob's lucky day have similar structure, however the parameters of his sequence are different: $$$l_b$$$, $$$r_b$$$, $$$t_b$$$. So a day is a lucky for Bob if it lies in a segment $$$[l_b + k t_b; r_b + k t_b]$$$, for some non-negative integer $$$k$$$.Alice and Bob want to participate in team competitions together and so they want to find out what is the largest possible number of consecutive days, which are lucky for both Alice and Bob.

The first line contains three integers $$$l_a$$$, $$$r_a$$$, $$$t_a$$$ ($$$0 \le l_a \le r_a \le t_a - 1, 2 \le t_a \le 10^9$$$) and describes Alice's lucky days. The second line contains three integers $$$l_b$$$, $$$r_b$$$, $$$t_b$$$ ($$$0 \le l_b \le r_b \le t_b - 1, 2 \le t_b \le 10^9$$$) and describes Bob's lucky days. It is guaranteed that both Alice and Bob have some unlucky days.

Print one integer: the maximum number of days in the row that are lucky for both Alice and Bob.

NoteThe graphs below correspond to the two sample tests and show the lucky and unlucky days of Alice and Bob as well as the possible solutions for these tests.


Alice has a birthday today, so she invited home her best friend Bob. Now Bob needs to find a way to commute to the Alice's home.In the city in which Alice and Bob live, the first metro line is being built. This metro line contains $$$n$$$ stations numbered from $$$1$$$ to $$$n$$$. Bob lives near the station with number $$$1$$$, while Alice lives near the station with number $$$s$$$. The metro line has two tracks. Trains on the first track go from the station $$$1$$$ to the station $$$n$$$ and trains on the second track go in reverse direction. Just after the train arrives to the end of its track, it goes to the depot immediately, so it is impossible to travel on it after that.Some stations are not yet open at all and some are only partially open — for each station and for each track it is known whether the station is closed for that track or not. If a station is closed for some track, all trains going in this track's direction pass the station without stopping on it.When the Bob got the information on opened and closed stations, he found that traveling by metro may be unexpectedly complicated. Help Bob determine whether he can travel to the Alice's home by metro or he should search for some other transport.

The first line contains two integers $$$n$$$ and $$$s$$$ ($$$2 \le s \le n \le 1000$$$) — the number of stations in the metro and the number of the station where Alice's home is located. Bob lives at station $$$1$$$. Next lines describe information about closed and open stations. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$a_i = 0$$$ or $$$a_i = 1$$$). If $$$a_i = 1$$$, then the $$$i$$$-th station is open on the first track (that is, in the direction of increasing station numbers). Otherwise the station is closed on the first track. The third line contains $$$n$$$ integers $$$b_1, b_2, \ldots, b_n$$$ ($$$b_i = 0$$$ or $$$b_i = 1$$$). If $$$b_i = 1$$$, then the $$$i$$$-th station is open on the second track (that is, in the direction of decreasing station numbers). Otherwise the station is closed on the second track.

Print "YES" (quotes for clarity) if Bob will be able to commute to the Alice's home by metro and "NO" (quotes for clarity) otherwise. You can print each letter in any case (upper or lower).

NoteIn the first example, all stations are opened, so Bob can simply travel to the station with number $$$3$$$.In the second example, Bob should travel to the station $$$5$$$ first, switch to the second track and travel to the station $$$4$$$ then.In the third example, Bob simply can't enter the train going in the direction of Alice's home.


Alice's hair is growing by leaps and bounds. Maybe the cause of it is the excess of vitamins, or maybe it is some black magic...To prevent this, Alice decided to go to the hairdresser. She wants for her hair length to be at most $$$l$$$ centimeters after haircut, where $$$l$$$ is her favorite number. Suppose, that the Alice's head is a straight line on which $$$n$$$ hairlines grow. Let's number them from $$$1$$$ to $$$n$$$. With one swing of the scissors the hairdresser can shorten all hairlines on any segment to the length $$$l$$$, given that all hairlines on that segment had length strictly greater than $$$l$$$. The hairdresser wants to complete his job as fast as possible, so he will make the least possible number of swings of scissors, since each swing of scissors takes one second.Alice hasn't decided yet when she would go to the hairdresser, so she asked you to calculate how much time the haircut would take depending on the time she would go to the hairdresser. In particular, you need to process queries of two types:  $$$0$$$ — Alice asks how much time the haircut would take if she would go to the hairdresser now.  $$$1$$$ $$$p$$$ $$$d$$$ — $$$p$$$-th hairline grows by $$$d$$$ centimeters. Note, that in the request $$$0$$$ Alice is interested in hypothetical scenario of taking a haircut now, so no hairlines change their length.

The first line contains three integers $$$n$$$, $$$m$$$ and $$$l$$$ ($$$1 \le n, m \le 100\,000$$$, $$$1 \le l \le 10^9$$$) — the number of hairlines, the number of requests and the favorite number of Alice. The second line contains $$$n$$$ integers $$$a_i$$$ ($$$1 \le a_i \le 10^9$$$) — the initial lengths of all hairlines of Alice. Each of the following $$$m$$$ lines contains a request in the format described in the statement. The request description starts with an integer $$$t_i$$$. If $$$t_i = 0$$$, then you need to find the time the haircut would take. Otherwise, $$$t_i = 1$$$ and in this moment one hairline grows. The rest of the line than contains two more integers: $$$p_i$$$ and $$$d_i$$$ ($$$1 \le p_i \le n$$$, $$$1 \le d_i \le 10^9$$$) — the number of the hairline and the length it grows by.

For each query of type $$$0$$$ print the time the haircut would take.

NoteConsider the first example:  Initially lengths of hairlines are equal to $$$1, 2, 3, 4$$$ and only $$$4$$$-th hairline is longer $$$l=3$$$, and hairdresser can cut it in $$$1$$$ second.  Then Alice's second hairline grows, the lengths of hairlines are now equal to $$$1, 5, 3, 4$$$  Now haircut takes two seonds: two swings are required: for the $$$4$$$-th hairline and for the $$$2$$$-nd.  Then Alice's first hairline grows, the lengths of hairlines are now equal to $$$4, 5, 3, 4$$$  The haircut still takes two seconds: with one swing hairdresser can cut $$$4$$$-th hairline and with one more swing cut the segment from $$$1$$$-st to $$$2$$$-nd hairline.  Then Alice's third hairline grows, the lengths of hairlines are now equal to $$$4, 5, 4, 4$$$  Now haircut takes only one second: with one swing it is possible to cut the segment from $$$1$$$-st hairline to the $$$4$$$-th.


You are given a connected undirected graph without cycles (that is, a tree) of $$$n$$$ vertices, moreover, there is a non-negative integer written on every edge.Consider all pairs of vertices $$$(v, u)$$$ (that is, there are exactly $$$n^2$$$ such pairs) and for each pair calculate the bitwise exclusive or (xor) of all integers on edges of the simple path between $$$v$$$ and $$$u$$$. If the path consists of one vertex only, then xor of all integers on edges of this path is equal to $$$0$$$.Suppose we sorted the resulting $$$n^2$$$ values in non-decreasing order. You need to find the $$$k$$$-th of them.The definition of xor is as follows.Given two integers $$$x$$$ and $$$y$$$, consider their binary representations (possibly with leading zeros): $$$x_k \dots x_2 x_1 x_0$$$ and $$$y_k \dots y_2 y_1 y_0$$$ (where $$$k$$$ is any number so that all bits of $$$x$$$ and $$$y$$$ can be represented). Here, $$$x_i$$$ is the $$$i$$$-th bit of the number $$$x$$$ and $$$y_i$$$ is the $$$i$$$-th bit of the number $$$y$$$. Let $$$r = x \oplus y$$$ be the result of the xor operation of $$$x$$$ and $$$y$$$. Then $$$r$$$ is defined as $$$r_k \dots r_2 r_1 r_0$$$ where:$$$$$$ r_i = \left\{ \begin{aligned} 1, ~ \text{if} ~ x_i \ne y_i \\ 0, ~ \text{if} ~ x_i = y_i \end{aligned} \right. $$$$$$

The first line contains two integers $$$n$$$ and $$$k$$$ ($$$2 \le n \le 10^6$$$, $$$1 \le k \le n^2$$$) — the number of vertices in the tree and the number of path in the list with non-decreasing order. Each of the following $$$n - 1$$$ lines contains two integers $$$p_i$$$ and $$$w_i$$$ ($$$1 \le p_i \le i$$$, $$$0 \le w_i < 2^{62}$$$) — the ancestor of vertex $$$i + 1$$$ and the weight of the corresponding edge.

Print one integer: $$$k$$$-th smallest xor of a path in the tree.

NoteThe tree in the second sample test looks like this:For such a tree in total $$$9$$$ paths exist:   $$$1 \to 1$$$ of value $$$0$$$  $$$2 \to 2$$$ of value $$$0$$$  $$$3 \to 3$$$ of value $$$0$$$  $$$2 \to 3$$$ (goes through $$$1$$$) of value $$$1 = 2 \oplus 3$$$  $$$3 \to 2$$$ (goes through $$$1$$$) of value $$$1 = 2 \oplus 3$$$  $$$1 \to 2$$$ of value $$$2$$$  $$$2 \to 1$$$ of value $$$2$$$  $$$1 \to 3$$$ of value $$$3$$$  $$$3 \to 1$$$ of value $$$3$$$


Bob has put on some weight recently. In order to lose weight a bit, Bob has decided to swim regularly in the pool. However, the day before he went to the pool for the first time he had a weird dream. In this dream Bob was swimming along one of the pool's lanes, but also there were some jellyfish swimming around him. It's worth mentioning that jellyfish have always been one of Bob's deepest childhood fears.Let us assume the following physical model for Bob's dream.  The pool's lane is an area of the plane between lines $$$x=0$$$ and $$$x=w$$$. Bob is not allowed to swim outside of the lane, but he may touch its bounding lines if he wants.  The jellyfish are very small, but in Bob's dream they are extremely swift. Each jellyfish has its area of activity around it. Those areas are circles of various radii, with the jellyfish sitting in their centers. The areas of activity of two jellyfish may overlap and one area of activity may even be fully contained within another one.  Bob has a shape of a convex polygon.  Unfortunately, Bob's excess weight has made him very clumsy, and as a result he can't rotate his body while swimming. So he swims in a parallel translation pattern. However at any given moment of time he can choose any direction of his movement.  Whenever Bob swims into a jellyfish's activity area, it will immediately notice him and sting him very painfully. We assume that Bob has swum into the activity area if at some moment of time the intersection of his body with the jellyfish's activity area had a positive area (for example, if they only touch, the jellyfish does not notice Bob).  Once a jellyfish stung Bob, it happily swims away and no longer poses any threat to Bob. Bob wants to swim the lane to its end and get stung the least possible number of times. He will start swimming on the line $$$y=-h$$$, and finish on the line $$$y=h$$$ where $$$h = 10^{10}$$$.

The first line contains two integers $$$n$$$ and $$$w$$$ ($$$3 \le n \le 200, 1 \le w \le 30000$$$) — the number of vertices in the polygon that constitutes the Bob's shape and the width of the swimming pool lane. Each of the next $$$n$$$ lines contains two integers $$$x_i$$$ and $$$y_i$$$ ($$$0 \le x_i \le w, 0 \le y_i \le 30000$$$) — the coordinates of corresponding vertex of the polygon. The vertices in the polygon are given in counterclockwise order. It is guaranteed that the given polygon is strictly convex. The next line contains an only integer $$$m$$$ ($$$0 \le m \le 200$$$) — the number of the jellyfish in the pool. Each of the next $$$m$$$ lines contains three integers ($$$x_i$$$, $$$y_i$$$, $$$r_i$$$ ($$$0 \le x_i \le w, 0 \le y_i \le 30000, 1 \le r_i \le 30000$$$) — coordinates of the $$$i$$$-th jellyfish in the pool and the radius of her activity. It is guaranteed, that no two jellyfish are located in the same point.

Output a single integer — the least possible number of jellyfish that will sting Bob.

NoteVisualization of the possible solutions to the first and the second sample test cases are below:


Alice has written a program and now tries to improve its readability. One of the ways to improve readability is to give sensible names to the variables, so now Alice wants to rename some variables in her program. In her IDE there is a command called "massive refactoring", which can replace names of many variable in just one run. To use it, Alice needs to select two strings $$$s$$$ and $$$t$$$ and after that for each variable the following algorithm is performed: if the variable's name contains $$$s$$$ as a substring, then the first (and only first) occurrence of $$$s$$$ is replaced with $$$t$$$. If the name doesn't contain $$$s$$$, then this variable's name stays the same.The list of variables is known and for each variable both the initial name and the name Alice wants this variable change to are known. Moreover, for each variable the lengths of the initial name and the target name are equal (otherwise the alignment of the code could become broken). You need to perform renaming of all variables in exactly one run of the massive refactoring command or determine that it is impossible.

The first line contains the only integer $$$n$$$ ($$$1 \le n \le 3000$$$) — the number of variables in Alice's program. The following $$$n$$$ lines contain the initial names of variables $$$w_1, w_2, \ldots, w_n$$$, one per line. After that, $$$n$$$ more lines go, the $$$i$$$-th of them contains the target name $$$w'_i$$$ for the $$$i$$$-th variable. It is guaranteed that $$$1 \le |w_i| = |w'_i| \le 3000$$$. It is guaranteed that there is at least one variable having its target name different from the initial name. Both initial and target names consist of lowercase English letters only. For each variable the length of its initial name is equal to the length of its target name.

If it is impossible to rename all variables with one call of "massive refactoring", print "NO" (quotes for clarity). Otherwise, on the first line print "YES" (quotes for clarity) and on the following lines print $$$s$$$ and $$$t$$$ ($$$1 \le |s|, |t| \le 5000$$$), which should be used for replacement. Strings $$$s$$$ and $$$t$$$ should consist only of lowercase letters of English alphabet. If there are multiple ways to perform a "massive refactoring", you can use any of them.