2013-2014 Открытый чемпионат БГУИР по программированию. Финал
A. A+-B
time limit per test
1 second
memory limit per test
64 megabytes
input
stdin
output
stdout

You are given the integer numbers A and B. Output A + B or A - B.

Input

The first line contains two numbers A, B separeted by a single space ( - 263 ≤ A, B < 263).

Output

Output one integer number: A + B or A - B.

Examples
Input
15 27
Output
42
Input
100 58
Output
42
B. Sum of sequences
time limit per test
1 second
memory limit per test
64 megabytes
input
stdin
output
stdout

You finished RIUSB ACBJSO university few years ago and started working hard and growing your carrier. At the some moment you tried to pass an interview at the XEDNAY company. You successfully answered all tricky questions about advanced algorithms and data structures and got the last one. Given two sequences A, B you need to find the following sum:

Input

Input contains three lines. First contains two numbers lengths of sequences |A|, |B|. Second and third line contains |A| and |B| numbers separated by spaces (1 ≤ |A|, |B| ≤ 105, 1 ≤ Ai, Bi ≤ 104).

Output

Single line containing answer to the task.

Examples
Input
5 4
3 4 5 4 4
1 2 3 4
Output
42
C. Substrings
time limit per test
3 seconds
memory limit per test
64 megabytes
input
stdin
output
stdout

You are given a string S consisting of capital Latin letters. Consider the queries consisting of pairs of integer numbers Li and Ri. For each of them you should find the number of substrings which are less than substring S[Li...Ri].

Input

The first line contains the string S(1 ≤ |S| ≤ 105). The second line contains the number N (1 ≤ N ≤ 105), denoting the number of queries. The next N lines contain pairs of numbers Li, Ri (1 ≤ Li ≤ Ri ≤ |S|).

Output

For each query you should output the number of substrings which satisfy specified conditions.

Examples
Input
BSUIROPENPROGRAMMINGCHAMPIONSHIP
1
1 15
Output
42
D. BOPC
time limit per test
1 second
memory limit per test
64 megabytes
input
stdin
output
stdout

You invented a new chess figure and called it BOPC. Suppose it stands at the square grid at the point with coordinates X1, Y1. The point with coordinates X2, Y2 is under attack if |X1 - X2| < |Y1 - Y2|. Let the power of the figure denote the number of fields under attack for all possible starting positions of BOPC. Your goal is to calculate the power of BOPC figure given the field size.

Input

Single line containing one integer N — size of the field (1 ≤ N ≤ 109).

Output

Single line containing power of BOPC figure given the field size modulo 109 + 7.

Examples
Input
3
Output
26
E. Hamilton traversal 2
time limit per test
1 second
memory limit per test
64 megabytes
input
stdin
output
stdout

You have a K-dimentional parallelepiped with dimensions N1, N2... Nk You should traversal the parallelepiped in order to visit each cell only at once and returning into the original one. In one operation you can move into the neighboring cell either by coordinate N1 N2 ... or Nk.

Input

The first line of the input contains one integer K — number of dimensions. The second line contains K integer numbers N1, N2... Nk The third line contains K integers X1, X2... Xk representing your initial position.

Constraints: The product of N1, N2... Nk will be between 1 and 106 inclusive. K will be between 2 and 10.

Output

The output should contain the word No if there is no such traversal. In the other case output the word Yes. The following lines should contain a string in the format “C <+,->” where C is the coordinate, + or - denote the increase or decrease of this coordinate respectively. Please see the samples below for the details.

Examples
Input
3
2 2 2
1 2 2
Output
Yes
2 -
3 -
2 +
1 +
2 -
3 +
2 +
1 -
F. Sexless marriage agency
time limit per test
2 seconds
memory limit per test
64 megabytes
input
stdin
output
stdout

There are N individuals numbered from 1 to N in the database of clients of Martial sexless marriage agency. The founder of the agency is a programmer whose hobby is extrasensory perception, so to determine whether two individuals are happily married or not the agency counts the total number of hairs on their bodies. If the total amount of hairs is a power of two, the couple will live happily, otherwise the agency does not give any guarantees. The agency gave you the database of clients and asked for your help. Determine the maximum number of possible successful marriages given the fact that martians are monogamous and marry once in their lives.

Input

The first line contains the number N (1 ≤ N ≤ 105). The second line contains N integer numbers Ai (0 ≤ Ai < 1018), denoting the quantity of hairs on the martian with number i.

Output

At the first line output the number M, denoting the maximum number of possible successful marriages. At the next M lines output pairs Fi and Si separated by a single space — indexes of married martians.

Examples
Input
6
2 2 6 14 1 30
Output
2
2 6
1 4
G. String generator 2
time limit per test
1 second
memory limit per test
13 megabytes
input
stdin
output
stdout

You are given a sequence of integer numbers B. You should find the lexicographically smallest sequence A, consisting of the numbers from B, for which there is no i (1 ≤ i < |A|) such that Ai = Ai + 1. You can use each number from B only once.

Input

The first line of the input contains a single integer number N (1 ≤ N ≤ 106). The second line contains N integer numbers Bi separated by spaces (1 ≤ Bi ≤ 106).

Output

Output a sequence A which satisfies specified conditions. Output  - 1 if such sequence does not exist.

Examples
Input
5
2 3 1 3 1
Output
1 2 3 1 3 
H. Equalize
time limit per test
1 second
memory limit per test
64 megabytes
input
stdin
output
stdout

One of the most important responsibilities of an officer in the army is finding a task for soldiers. So, a brave platoon got an important mission: to group logs into equal piles. Logs have already been factored, but, unfortunately, the numbers of logs in the piles were different. The execution of this order should not take less than an hour, that is why the officer gave the next restrictions: in one minute they can take exactly one log and shift it only to a neighboring pile. Help soldiers to determine how many minutes they need to equalize all the piles of logs.

Input

The first line contains the number N. The next N lines contain the pairs of integer numbers Ki, Ai (1 ≤ N, Ki ≤ 105, 0 ≤ Ai ≤ 105). It means that Ki piles in a row have Ai logs. Each of the first K1 groups have A1 logs, after that K2 groups have A2 logs and so on.

Output

Output the smallest number of minutes the platoon needs to perform the task. Because the answer may be too large, you should output the answer modulo 109 + 7. It's guaranteed that the answer exists always.

Examples
Input
3
4 8
3 1
2 5
Output
42
I. Pair of paths
time limit per test
1 second
memory limit per test
64 megabytes
input
stdin
output
stdout

The kingdom has N castles numbered from 1 to N. The castles are connected with N - 1 roads. The road construction takes a huge amount of money, that's why thrifty inhabitants of the kingdom decided to plan the kingdom in such way that between every pair of castles there is exactly one path. Two brave knights independently start their journeys. Each knight randomly selects two castles where he starts and also finishes his trip. Then he goes through the kingdom by the shortest possible path and writes down all numbers of castles that he visits to his own list. After that they go to the chronicler and give him two lists of the castles which they have visited. And if there is no such castle which was visited by both knights, the chronicler will write to the annals that this pair of journeys was epic. Your goal is to find the number of existing different epic journeys pairs.

Input

At the first line N — number of castles in the kingdom (1 ≤ N ≤ 105). At the next N - 1 lines Ai Bi — roads between castles.

Output

Single line containing the number of existing different epic journeys.

Examples
Input
6
1 2
1 3
2 4
2 5
3 6
Output
12
J. Lucky tickets
time limit per test
1 second
memory limit per test
64 megabytes
input
stdin
output
stdout

Everyone knows that in less than a month the Ice Hockey World Championship will start in Minsk. But few of the guests of our city know that this is the reason why the new tickets and system of accounting were introduced in the public transport (which at the moment is unstable due to some structural flaws). It is obvious that the new tickets require the new formula for determining whether they are lucky or not. It is such an important task that it was given to the authors of BSUIR Open problems. After months of deliberation and disputes the following formula was proposed: a ticket is lucky if it is divisible by the number of symbol 1 in the binary representation. And then the authors thought that the number of these lucky tickets would be too big. Therefore, they asked you for help. Determine the quantity of lucky tickets with numbers from the interval [1..N].

Input

The first line contains the integer number N (1 ≤ N ≤ 1019).

Output

Output the number of lucky tickets.

Examples
Input
153
Output
42
K. Cards
time limit per test
1 second
memory limit per test
64 megabytes
input
stdin
output
stdout

You have N cards with different numbers on them. Your goal is to find a card with a maximal number. At the beginning all cards are put into the hat. You start getting them one by one and look at the numbers on them. After each card you can select it and stop the process. If it is really the card with the maximal number you win otherwise you lose. Also you can skip the current card and continue process. Fortunately you have a friend who helps with a good strategy: you pull X cards and memorize their values. Then you continue the process and select as answer the first card with value greater than the maximal value you memorized. Unfortunately you don't know the value of X that maximizes you chances of winning. Your task is to find X.

Input

Single line containing one number: N (5 ≤ N ≤ 100).

Output

Single line containing one number: value of X that maximizes you chances of winning.

Examples
Input
5
Output
2