A - Please Sign

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 400

問題文

長さ N の整数列 A=(A_1,A_2,\cdots,A_N),および長さ N-1 の整数列 P=(P_2,\cdots,P_N) が与えられます. P の添字が 2 から始まることに注意してください. また,1 \leq P_i<i が保証されます.

あなたは今から以下の操作を 10^{100} 回繰り返します.

  • i=2,\cdots,N について,この順に,A_{P_i} の値を A_{P_i}+A_{i} で置き換える.

すべての操作が終了したときの A_1 が 正, 負, 0 のいずれになるかを求めてください.

制約

  • 2 \leq N \leq 250000
  • -10^9 \leq A_i \leq 10^9
  • 1 \leq P_i < i
  • 入力される値はすべて整数.

入力

入力は以下の形式で標準入力から与えられる.

N
A_1 A_2 \cdots A_N
P_2 \cdots P_N

出力

すべての操作が終了したときの A_1 が正である場合 + を出力せよ. 負である場合 - を出力せよ. 0 である場合 0 を出力せよ.


入力例 1

4
1 -2 3 -4
1 2 3

出力例 1

-

最初の数回の操作の結果を以下に示します.

  • 1 回目の操作
    • 操作前: A=(1,-2,3,-4)
    • i=2 について処理: A_1 の値を A_1+A_2=1+(-2)=-1 で置き換える.
    • i=3 について処理: A_2 の値を A_2+A_3=-2+3=1 で置き換える.
    • i=4 について処理: A_3 の値を A_3+A_4=3+(-4)=-1 で置き換える.
    • 操作後: A=(-1,1,-1,-4)
  • 2 回目の操作後,A=(0,0,-5,-4) となる.
  • 3 回目の操作後,A=(0,-5,-9,-4) となる.
  • 4 回目の操作後,A=(-5,-14,-13,-4) となる.
  • \vdots

操作を 10^{100} 回行うと,A_1 は負になります. よって - を出力すべきです.


入力例 2

3
0 1 -1
1 1

出力例 2

0

入力例 3

5
1 -1 1 -1 1
1 1 2 2

出力例 3

+

入力例 4

20
568273618 939017124 -32990462 -906026662 403558381 -811698210 56805591 0 436005733 -303345804 96409976 179069924 0 0 0 -626752087 569946496 0 0 0
1 1 1 4 4 6 7 2 2 3 3 8 13 14 9 9 15 18 19

出力例 4

+

Score : 400 points

Problem Statement

You are given an integer sequence A=(A_1,A_2,\cdots,A_N) of length N, and another integer sequence P=(P_2,\cdots,P_N) of length N-1. Note that the index of P starts at 2. It is guaranteed that 1 \leq P_i < i for each i.

You will now repeat the following operation 10^{100} times.

  • For each i=2,\cdots,N, in this order, replace the value of A_{P_i} with A_{P_i}+A_{i}.

Determine whether A_1 will be positive, negative, or zero when all operations are completed.

Constraints

  • 2 \leq N \leq 250000
  • -10^9 \leq A_i \leq 10^9
  • 1 \leq P_i < i
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N
A_1 A_2 \cdots A_N
P_2 \cdots P_N

Output

If A_1 is positive when all operations are completed, print +; if it is negative, print -; if it is zero, print 0.


Sample Input 1

4
1 -2 3 -4
1 2 3

Sample Output 1

-

Shown below are the results of the first few operations.

  • After the first operation:
    • Before the operation: A=(1,-2,3,-4).
    • Processing for i=2: Replace the value of A_1 with A_1+A_2=1+(-2)=-1.
    • Processing for i=3: Replace the value of A_2 with A_2+A_3=-2+3=1.
    • Processing for i=4: Replace the value of A_3 with A_3+A_4=3+(-4)=-1.
    • After the operation: A=(-1,1,-1,-4).
  • After the second operation, A=(0,0,-5,-4).
  • After the third operation, A=(0,-5,-9,-4).
  • After the fourth operation, A=(-5,-14,-13,-4).
  • \vdots

After 10^{100} operations, A_1 will be negative. Thus, you should print -.


Sample Input 2

3
0 1 -1
1 1

Sample Output 2

0

Sample Input 3

5
1 -1 1 -1 1
1 1 2 2

Sample Output 3

+

Sample Input 4

20
568273618 939017124 -32990462 -906026662 403558381 -811698210 56805591 0 436005733 -303345804 96409976 179069924 0 0 0 -626752087 569946496 0 0 0
1 1 1 4 4 6 7 2 2 3 3 8 13 14 9 9 15 18 19

Sample Output 4

+
B - Subsegments with Small Sums

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 500

問題文

正整数 S が与えられます. 正整数列 x に対し,f(x) を以下のように定めます.

  • x をいくつかの連続部分列に分解することを考える. このとき,どの連続部分列についても要素の総和が S 以下でなくてはならない. このような分解における連続部分列の個数の最小値を f(x) の値とする.

なお,この問題の制約下では f の値が必ず定義できることが証明できます.

正整数列 A=(A_1,A_2,\cdots,A_N) が与えられます. \sum_{1 \leq l \leq r \leq N} f((A_l,A_{l+1},\cdots,A_r)) の値を求めてください.

制約

  • 1 \leq N \leq 250000
  • 1 \leq S \leq 10^{15}
  • 1 \leq A_i \leq \min(S,10^9)
  • 入力される値はすべて整数.

入力

入力は以下の形式で標準入力から与えられる.

N S
A_1 A_2 \cdots A_N

出力

答えを出力せよ.


入力例 1

3 3
1 2 3

出力例 1

8

例えば x=(1,2,3) を考えると,(1,2),(3) という分解が条件を満たし, かつ 2 個未満の連続部分列に分解した場合は条件を満たさないため,f((1,2,3))=2 です.

ありうる l,r とそれに対応する f の値は以下の通りです.

  • (l,r)=(1,1): f((1))=1
  • (l,r)=(1,2): f((1,2))=1
  • (l,r)=(1,3): f((1,2,3))=2
  • (l,r)=(2,2): f((2))=1
  • (l,r)=(2,3): f((2,3))=2
  • (l,r)=(3,3): f((3))=1

よって答えは 1+1+2+1+2+1=8 になります.


入力例 2

5 1
1 1 1 1 1

出力例 2

35

入力例 3

5 15
5 4 3 2 1

出力例 3

15

入力例 4

20 1625597454
786820955 250480341 710671229 946667801 19271059 404902145 251317818 22712439 520643153 344670307 274195604 561032101 140039457 543856068 521915711 857077284 499774361 419370025 744280520 249168130

出力例 4

588

Score : 500 points

Problem Statement

You are given a positive integer S. For a sequence of positive integers x, we define f(x) as follows:

  • Consider decomposing x into several contiguous subsequences. For each contiguous subsequence, the sum of its elements must be at most S. The minimum number of contiguous subsequences in such a decomposition is the value of f(x).

It can be proved that the value of f is always definable under the constraints of this problem.

You are given a sequence of positive integers A=(A_1,A_2,\cdots,A_N). Find the value of \sum_{1 \leq l \leq r \leq N} f((A_l,A_{l+1},\cdots,A_r)).

Constraints

  • 1 \leq N \leq 250000
  • 1 \leq S \leq 10^{15}
  • 1 \leq A_i \leq \min(S,10^9)
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N S
A_1 A_2 \cdots A_N

Output

Print the answer.


Sample Input 1

3 3
1 2 3

Sample Output 1

8

For example, consider x=(1,2,3). The decomposition (1,2),(3) satisfies the condition, and no decomposition into fewer than two contiguous subsequences satisfies the condition, so f((1,2,3))=2.

Shown below are the possible l,r and the corresponding values of f:

  • (l,r)=(1,1): f((1))=1
  • (l,r)=(1,2): f((1,2))=1
  • (l,r)=(1,3): f((1,2,3))=2
  • (l,r)=(2,2): f((2))=1
  • (l,r)=(2,3): f((2,3))=2
  • (l,r)=(3,3): f((3))=1

Thus, the answer is 1+1+2+1+2+1=8.


Sample Input 2

5 1
1 1 1 1 1

Sample Output 2

35

Sample Input 3

5 15
5 4 3 2 1

Sample Output 3

15

Sample Input 4

20 1625597454
786820955 250480341 710671229 946667801 19271059 404902145 251317818 22712439 520643153 344670307 274195604 561032101 140039457 543856068 521915711 857077284 499774361 419370025 744280520 249168130

Sample Output 4

588
C - Not So Consecutive

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 600

問題文

整数 N が与えられます. 長さ N の整数列 x=(x_1,x_2,\cdots,x_N) は,以下の条件を満たすとき(そしてそのときのみ)よい数列と呼ばれます.

  • x の各要素は 1 以上 N 以下の整数である.
  • 各整数 i (1 \leq i \leq N) に対し,ii+1 個以上連続して並ぶような場所が x 内に存在しない.

長さ N の整数列 A=(A_1,A_2,\cdots,A_N) が与えられます. A の各要素は 1 以上 N 以下の整数もしくは -1 です. それぞれの -11 以上 N 以下の整数に置き換えることで得られるよい数列の個数を 998244353 で割ったあまりを求めてください.

制約

  • 1 \leq N \leq 5000
  • A_i=-1 もしくは 1 \leq A_i \leq N
  • 入力される値はすべて整数.

入力

入力は以下の形式で標準入力から与えられる.

N
A_1 A_2 \cdots A_N

出力

答えを出力せよ.


入力例 1

2
-1 -1

出力例 1

3

それぞれの -11 以上 2 以下の整数で置き換えて得られる数列は 4 通りあります.

ここで A=(1,1) について考えると,12 個連続してしまうためよい数列ではありません.

それ以外の A=(1,2),(2,1),(2,2) について考えると,これらはすべてよい数列です.

よって答えは 3 です.


入力例 2

3
2 -1 2

出力例 2

2

入力例 3

4
-1 1 1 -1

出力例 3

0

入力例 4

20
9 -1 -1 -1 -1 -1 -1 -1 -1 -1 7 -1 -1 -1 19 4 -1 -1 -1 -1

出力例 4

128282166

Score : 600 points

Problem Statement

You are given an integer N. An integer sequence x=(x_1,x_2,\cdots,x_N) of length N is called a good sequence if and only if the following conditions are satisfied:

  • Each element of x is an integer between 1 and N, inclusive.
  • For each integer i (1 \leq i \leq N), there is no position in x where i appears i+1 or more times in a row.

You are given an integer sequence A=(A_1,A_2,\cdots,A_N) of length N. Each element of A is -1 or an integer between 1 and N. Find the number, modulo 998244353, of good sequences that can be obtained by replacing each -1 in A with an integer between 1 and N.

Constraints

  • 1 \leq N \leq 5000
  • A_i=-1 or 1 \leq A_i \leq N.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N
A_1 A_2 \cdots A_N

Output

Print the answer.


Sample Input 1

2
-1 -1

Sample Output 1

3

You can obtain four sequences by replacing each -1 with an integer between 1 and 2.

A=(1,1) is not a good sequence because 1 appears twice in a row.

The other sequences A=(1,2),(2,1),(2,2) are good.

Thus, the answer is 3.


Sample Input 2

3
2 -1 2

Sample Output 2

2

Sample Input 3

4
-1 1 1 -1

Sample Output 3

0

Sample Input 4

20
9 -1 -1 -1 -1 -1 -1 -1 -1 -1 7 -1 -1 -1 19 4 -1 -1 -1 -1

Sample Output 4

128282166
D - Add to Make a Permutation

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 700

問題文

長さ N の整数列 A=(A_1,A_2,\cdots,A_N) が与えられます. A の各要素は 0 以上 N-1 以下の整数です.

あなたは以下の操作を 0 回以上行うことができます.

  • A の中からちょうど M 個の要素を選ぶ. そして,選んだ要素の値をそれぞれ 1 増加させる. 増加させたあとに値が N になっている要素があれば,その値を 0 に変更する.

あなたの目標は A(0,1,\cdots,N-1) の順列にすることです. 目標が達成可能か判定し,可能ならば必要な最小の操作回数を求めてください.

制約

  • 2 \leq N \leq 250000
  • 1 \leq M \leq N-1
  • 0 \leq A_i \leq N-1
  • 入力される値はすべて整数.

入力

入力は以下の形式で標準入力から与えられる.

N M
A_1 A_2 \cdots A_N

出力

目標が達成不可能な場合,-1 を出力せよ. 可能な場合,必要な最小の操作回数を出力せよ.


入力例 1

3 2
0 1 1

出力例 1

2

以下のように操作すると 2 回の操作で目標を達成できます.

  • 初期状態: A=(0,1,1)
  • 1 回目の操作: A_1,A_2 を選んで操作を行い,A=(1,2,1) になる.
  • 2 回目の操作: A_2,A_3 を選んで操作を行い,A=(1,0,2) になる.

2 回未満の操作で目標を達成することはできないため,答えは 2 になります.


入力例 2

5 2
0 4 2 3 1

出力例 2

0

入力例 3

4 2
0 0 1 2

出力例 3

-1

入力例 4

20 15
5 14 18 0 8 5 0 10 6 5 11 2 10 10 17 9 8 14 4 4

出力例 4

10

Score : 700 points

Problem Statement

You are given an integer sequence A=(A_1,A_2,\cdots,A_N) of length N. Each element of A is an integer between 0 and N-1, inclusive.

You can perform the following operation zero or more times:

  • Choose exactly M elements from A. Then, increase the value of each chosen element by 1. Now, if some elements have the values of N, change those values to 0.

Your goal is to make A a permutation of (0,1,\cdots,N-1). Determine if the goal is achievable. If it is, find the minimum number of operations required.

Constraints

  • 2 \leq N \leq 250000
  • 1 \leq M \leq N-1
  • 0 \leq A_i \leq N-1
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N M
A_1 A_2 \cdots A_N

Output

If the goal is unachievable, print -1. Otherwise, print the minimum number of operations required.


Sample Input 1

3 2
0 1 1

Sample Output 1

2

You can operate as follows to achieve the goal in two operations:

  • Initial state: A=(0,1,1).
  • First operation: Choose A_1 and A_2, making A=(1,2,1).
  • Second operation: Choose A_2 and A_3, making A=(1,0,2).

You cannot achieve the goal in fewer than two operations, so the answer is 2.


Sample Input 2

5 2
0 4 2 3 1

Sample Output 2

0

Sample Input 3

4 2
0 0 1 2

Sample Output 3

-1

Sample Input 4

20 15
5 14 18 0 8 5 0 10 6 5 11 2 10 10 17 9 8 14 4 4

Sample Output 4

10
E - Avoid Boring Matches

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 900

問題文

1 から 2^N までの番号のついた 2^N 人の参加者がいる大会があります.

大会は次のように進行します.

  • まず最初に,それぞれの参加者に赤または青の帽子をかぶせる. ここで,各参加者にかぶせる帽子の色は文字列 S によって与えられる. 具体的には,Si 文字目 (1 \leq i \leq 2^N) が R のときは赤い帽子を,B のときは青い帽子を参加者 i にかぶせる.

  • その後,参加者が 1 人になるまで以下の操作を繰り返す.

    • 現在の参加者の人数を 2k 人とする.参加者を k 個の 2 人組に分ける. この組分けはあなたが自由に選ぶことができる. そしてそれぞれの組で試合を行い,勝者は残り,敗者は大会から去る. なお,参加者は強さ順に番号づけられているため,必ず番号の小さい参加者が勝利する.

あなたは,赤い帽子をかぶった参加者同士の試合をつまらない試合と呼んでいます. あなたの目標は,大会中につまらない試合が発生しないように各組分けを行うことです.

目標が達成可能であるか否かは文字列 S に依存します. そこであなたは,大会の開始前に S に細工することにしました. 具体的には,あなたは次の操作を 0 回以上行えます.

  • S 中の隣接する 2 文字を選び,入れ替える.

操作の結果目標を達成することが可能かどうか判定してください. また,可能な場合は必要な最小の操作回数を求めてください.

制約

  • 1 \leq N \leq 18
  • SR, B からなる長さ 2^N の文字列.
  • 入力される値はすべて整数.

入力

入力は以下の形式で標準入力から与えられる.

N
S

出力

目標を達成することが不可能な場合は -1 を出力せよ. 可能な場合は必要な最小の操作回数を出力せよ.


入力例 1

2
RRBB

出力例 1

1

操作を 1 回も行わないと,目標を達成することができません.

S2 文字目と 3 文字目を入れ替える操作を行い,S=RBRB とすると,以下のようにして目標を達成できます.

  • 参加者 1,2,3,4 にそれぞれ 赤,青,赤,青 の帽子をかぶせる.
  • 4 人の参加者を 2 つの組 (1,4),(2,3) に分ける. ここでつまらない試合は発生しない. 試合の結果,参加者 1,2 が勝ち残る.
  • 2 人の参加者を 1 つの組 (1,2) に分ける. ここでつまらない試合は発生しない. 試合の結果,参加者 1 が勝ち残る.

よって答えは 1 です.


入力例 2

1
RR

出力例 2

-1

入力例 3

4
RBBRRBRBBRBBBRBR

出力例 3

0

入力例 4

5
RBRRBRRRBRRRRRRRRRBBBBBBBBBBBBBB

出力例 4

11

Score : 900 points

Problem Statement

There is a tournament with 2^N participants, numbered 1 to 2^N.

The tournament proceeds as follows:

  • First, each participant is given a red or blue hat. You are given the color of the hat for each participant as the string S. Specifically, participant i is given a red hat if the i-th character (1 \leq i \leq 2^N) of S is R, and a blue hat if it is B.

  • Then, the following operation is repeated until there is only one participant remaining:

    • Let 2k be the current number of participants. Divide the participants into k pairs. You can freely choose how to pair them. Then, a match is held for each pair; the winner remains, and the loser leaves the tournament. The participants are numbered in descending order of strength, so the participant with the smaller number always wins.

A match between two participants wearing red hats is called a boring match. Your goal is to arrange the pairings so that no boring matches occur during the tournament.

Whether the goal is achievable or not depends on the string S. Hence, you have decided to tamper with S before the start of the tournament. Specifically, you can perform the following operation zero or more times:

  • Choose two adjacent characters in S and swap them.

Determine whether it is possible to achieve the goal after operations. If it is, find the minimum number of operations required.

Constraints

  • 1 \leq N \leq 18
  • S is a string of length 2^N consisting of R and B.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N
S

Output

If it is impossible to achieve the goal, print -1. Otherwise, print the minimum number of operations required.


Sample Input 1

2
RRBB

Sample Output 1

1

Without performing any operations, you cannot achieve the goal.

If you swap the second and third characters of S, making S=RBRB, you can achieve the goal as follows:

  • Give red, blue, red, and blue hats to participants 1, 2, 3, and 4, respectively.
  • Divide the four participants into two pairs (1,4),(2,3). No boring matches occur here. After the matches, participants 1 and 2 remain.
  • Divide the two participants into one pair (1,2). No boring matches occur here. After the match, participant 1 remains.

Therefore, the answer is 1.


Sample Input 2

1
RR

Sample Output 2

-1

Sample Input 3

4
RBBRRBRBBRBBBRBR

Sample Output 3

0

Sample Input 4

5
RBRRBRRRBRRRRRRRRRBBBBBBBBBBBBBB

Sample Output 4

11
F - Large DP Table

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 900

問題文

長さ N の整数列 A=(A_1,A_2,\cdots,A_N), B=(B_1,B_2,\cdots,B_N), X=(X_1,X_2,\cdots,X_N), Y=(Y_1,Y_2,\cdots,Y_N) が与えられます. ここで,A,B は以下の性質を満たしています.

  • A_1=1
  • B_1=2
  • (A_1,A_2,\cdots,A_N,B_1,B_2,\cdots,B_N)(1,2,\cdots,2N) の順列.

整数 d_{i,j} (1 \leq i,j \leq N) を以下のように定義します.

  • d_{1,1}=0
  • (i,j) \neq (1,1) かつ A_i<B_j のとき: d_{i,j}=d_{i,j-1}+X_i
  • (i,j) \neq (1,1) かつ A_i>B_j のとき: d_{i,j}=d_{i-1,j}+Y_j

\sum_{1 \leq i \leq N}\sum_{1 \leq j \leq N}d_{i,j}998244353 で割ったあまりを求めてください.

制約

  • 2 \leq N \leq 250000
  • A_1=1
  • B_1=2
  • (A_1,A_2,\cdots,A_N,B_1,B_2,\cdots,B_N)(1,2,\cdots,2N) の順列.
  • 1 \leq X_i \leq 10^9
  • 1 \leq Y_i \leq 10^9
  • 入力される値はすべて整数.

入力

入力は以下の形式で標準入力から与えられる.

N
A_1 A_2 \cdots A_N
B_1 B_2 \cdots B_N
X_1 X_2 \cdots X_N
Y_1 Y_2 \cdots Y_N

出力

答えを出力せよ.


入力例 1

2
1 4
2 3
2 2
1 3

出力例 1

8

d_{i,j} の値は以下のようになります.

  • d_{1,1}=0
  • d_{1,2}=d_{1,1}+X_1=0+2=2
  • d_{2,1}=d_{1,1}+Y_1=0+1=1
  • d_{2,2}=d_{1,2}+Y_2=2+3=5

よって求める答えは 0+2+1+5=8 になります.


入力例 2

3
1 3 5
2 6 4
1 10 100
1000 10000 100000

出力例 2

108153

入力例 3

3
1 6 5
2 4 3
1 10 100
1000 10000 100000

出力例 3

333009

入力例 4

10
1 17 4 7 16 18 9 3 12 6
2 19 20 14 5 11 13 8 15 10
744280520 249168130 239276621 320064892 910500852 164832983 245532751 198319687 715892722 967824729
769431650 80707350 459924868 257261830 777045524 583882654 950300099 438099970 322288793 532405020

出力例 4

746075419

Score : 900 points

Problem Statement

You are given integer sequences of length N: A=(A_1,A_2,\cdots,A_N), B=(B_1,B_2,\cdots,B_N), X=(X_1,X_2,\cdots,X_N), and Y=(Y_1,Y_2,\cdots,Y_N). Here, A and B satisfy the following properties:

  • A_1=1.
  • B_1=2.
  • (A_1,A_2,\cdots,A_N,B_1,B_2,\cdots,B_N) is a permutation of (1,2,\cdots,2N).

Define the integers d_{i,j} (1 \leq i,j \leq N) as follows:

  • d_{1,1}=0.
  • If (i,j) \neq (1,1) and A_i<B_j, then d_{i,j}=d_{i,j-1}+X_i.
  • If (i,j) \neq (1,1) and A_i>B_j, then d_{i,j}=d_{i-1,j}+Y_j.

Find \sum_{1 \leq i \leq N}\sum_{1 \leq j \leq N}d_{i,j}, modulo 998244353.

Constraints

  • 2 \leq N \leq 250000
  • A_1=1
  • B_1=2
  • (A_1,A_2,\cdots,A_N,B_1,B_2,\cdots,B_N) is a permutation of (1,2,\cdots,2N).
  • 1 \leq X_i \leq 10^9
  • 1 \leq Y_i \leq 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N
A_1 A_2 \cdots A_N
B_1 B_2 \cdots B_N
X_1 X_2 \cdots X_N
Y_1 Y_2 \cdots Y_N

Output

Print the answer.


Sample Input 1

2
1 4
2 3
2 2
1 3

Sample Output 1

8

The values of d_{i,j} are as follows:

  • d_{1,1}=0
  • d_{1,2}=d_{1,1}+X_1=0+2=2
  • d_{2,1}=d_{1,1}+Y_1=0+1=1
  • d_{2,2}=d_{1,2}+Y_2=2+3=5

Thus, the answer is 0+2+1+5=8.


Sample Input 2

3
1 3 5
2 6 4
1 10 100
1000 10000 100000

Sample Output 2

108153

Sample Input 3

3
1 6 5
2 4 3
1 10 100
1000 10000 100000

Sample Output 3

333009

Sample Input 4

10
1 17 4 7 16 18 9 3 12 6
2 19 20 14 5 11 13 8 15 10
744280520 249168130 239276621 320064892 910500852 164832983 245532751 198319687 715892722 967824729
769431650 80707350 459924868 257261830 777045524 583882654 950300099 438099970 322288793 532405020

Sample Output 4

746075419