Codeforces Round 511 (Div. 2)
A. Little C Loves 3 I
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

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

Output

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.

Examples
Input
3
Output
1 1 1
Input
233
Output
77 77 79

B. Cover Points
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Input

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$$$).

Output

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

Examples
Input
3
1 1
1 2
2 1
Output
3
Input
4
1 1
1 2
2 1
2 2
Output
4
Note

Illustration for the first example:

Illustration for the second example:

C. Enlarge GCD
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Mr. F has $$$n$$$ positive integers, $$$a_1, a_2, \ldots, a_n$$$.

He thinks the greatest common divisor of these integers is too small. So he wants to enlarge it by removing some of the integers.

But this problem is too simple for him, so he does not want to do it by himself. If you help him, he will give you some scores in reward.

Your task is to calculate the minimum number of integers you need to remove so that the greatest common divisor of the remaining integers is bigger than that of all integers.

Input

The first line contains an integer $$$n$$$ ($$$2 \leq n \leq 3 \cdot 10^5$$$) — the number of integers Mr. F has.

The second line contains $$$n$$$ integers, $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq 1.5 \cdot 10^7$$$).

Output

Print an integer — the minimum number of integers you need to remove so that the greatest common divisor of the remaining integers is bigger than that of all integers.

You should not remove all of the integers.

If there is no solution, print «-1» (without quotes).

Examples
Input
3
1 2 4
Output
1
Input
4
6 9 15 30
Output
2
Input
3
1 1 1
Output
-1
Note

In the first example, the greatest common divisor is $$$1$$$ in the beginning. You can remove $$$1$$$ so that the greatest common divisor is enlarged to $$$2$$$. The answer is $$$1$$$.

In the second example, the greatest common divisor is $$$3$$$ in the beginning. You can remove $$$6$$$ and $$$9$$$ so that the greatest common divisor is enlarged to $$$15$$$. There is no solution which removes only one integer. So the answer is $$$2$$$.

In the third example, there is no solution to enlarge the greatest common divisor. So the answer is $$$-1$$$.

D. Little C Loves 3 II
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Little C loves number «3» very much. He loves all things about it.

Now he is playing a game on a chessboard of size $$$n \times m$$$. The cell in the $$$x$$$-th row and in the $$$y$$$-th column is called $$$(x,y)$$$. Initially, The chessboard is empty. Each time, he places two chessmen on two different empty cells, the Manhattan distance between which is exactly $$$3$$$. The Manhattan distance between two cells $$$(x_i,y_i)$$$ and $$$(x_j,y_j)$$$ is defined as $$$|x_i-x_j|+|y_i-y_j|$$$.

He want to place as many chessmen as possible on the chessboard. Please help him find the maximum number of chessmen he can place.

Input

A single line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n,m \leq 10^9$$$) — the number of rows and the number of columns of the chessboard.

Output

Print one integer — the maximum number of chessmen Little C can place.

Examples
Input
2 2
Output
0
Input
3 3
Output
8
Note

In the first example, the Manhattan distance between any two cells is smaller than $$$3$$$, so the answer is $$$0$$$.

In the second example, a possible solution is $$$(1,1)(3,2)$$$, $$$(1,2)(3,3)$$$, $$$(2,1)(1,3)$$$, $$$(3,1)(2,3)$$$.

E. Region Separation
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

There are $$$n$$$ cities in the Kingdom of Autumn, numbered from $$$1$$$ to $$$n$$$. People can travel between any two cities using $$$n-1$$$ two-directional roads.

This year, the government decides to separate the kingdom. There will be regions of different levels. The whole kingdom will be the region of level $$$1$$$. Each region of $$$i$$$-th level should be separated into several (at least two) regions of $$$i+1$$$-th level, unless $$$i$$$-th level is the last level. Each city should belong to exactly one region of each level and for any two cities in the same region, it should be possible to travel between them passing the cities in the same region only.

According to research, for each city $$$i$$$, there is a value $$$a_i$$$, which describes the importance of this city. All regions of the same level should have an equal sum of city importances.

Your task is to find how many plans there are to determine the separation of the regions that all the conditions are satisfied. Two plans are considered different if and only if their numbers of levels are different or there exist two cities in the same region of one level in one plan but in different regions of this level in the other plan. Since the answer may be very large, output it modulo $$$10^9+7$$$.

Input

The first line contains one integer $$$n$$$ ($$$1 \leq n \leq 10^6$$$) — the number of the cities.

The second line contains $$$n$$$ integers, the $$$i$$$-th of which is $$$a_i$$$ ($$$1 \leq a_i \leq 10^9$$$) — the value of each city.

The third line contains $$$n-1$$$ integers, $$$p_1, p_2, \ldots, p_{n-1}$$$; $$$p_i$$$ ($$$p_i \leq i$$$) describes a road between cities $$$p_i$$$ and $$$i+1$$$.

Output

Print one integer — the number of different plans modulo $$$10^9+7$$$.

Examples
Input
4
1 1 1 1
1 2 3
Output
4
Input
4
1 1 1 1
1 2 2
Output
2
Input
4
1 2 1 2
1 1 3
Output
3
Note

For the first example, there are $$$4$$$ different plans:

Plan $$$1$$$: Level-$$$1$$$: $$$\{1,2,3,4\}$$$.

Plan $$$2$$$: Level-$$$1$$$: $$$\{1,2,3,4\}$$$, Level-$$$2$$$: $$$\{1,2\}$$$,$$$\{3,4\}$$$.

Plan $$$3$$$: Level-$$$1$$$: $$$\{1,2,3,4\}$$$, Level-$$$2$$$: $$$\{1\}$$$,$$$\{2\}$$$,$$$\{3\}$$$,$$$\{4\}$$$.

Plan $$$4$$$: Level-$$$1$$$: $$$\{1,2,3,4\}$$$, Level-$$$2$$$: $$$\{1,2\}$$$,$$$\{3,4\}$$$, Level-$$$3$$$: $$$\{1\}$$$,$$$\{2\}$$$,$$$\{3\}$$$,$$$\{4\}$$$.

For the second example, there are $$$2$$$ different plans:

Plan $$$1$$$: Level-$$$1$$$: $$$\{1,2,3,4\}$$$.

Plan $$$2$$$: Level-$$$1$$$: $$$\{1,2,3,4\}$$$, Level-$$$2$$$: $$$\{1\}$$$,$$$\{2\}$$$,$$$\{3\}$$$,$$$\{4\}$$$.

For the third example, there are $$$3$$$ different plans:

Plan $$$1$$$: Level-$$$1$$$: $$$\{1,2,3,4\}$$$.

Plan $$$2$$$: Level-$$$1$$$: $$$\{1,2,3,4\}$$$, Level-$$$2$$$: $$$\{1,2\}$$$,$$$\{3,4\}$$$.

Plan $$$3$$$: Level-$$$1$$$: $$$\{1,2,3,4\}$$$, Level-$$$2$$$: $$$\{1,3\}$$$,$$$\{2\}$$$,$$$\{4\}$$$.