PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FW0000112. Nhu cầu của Chokudai (Chokudai's Demand)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Nhu cầu của Chokudai (Chokudai's Demand)

Chokudai's Demand

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn cities and an undirected direct road between every pair. The road cost Ai,jA_{i,j} is fixed when not equal to −1-1; otherwise its cost is a common unknown positive integer XX. For each XX, count unordered pairs i<ji<j whose shortest-path distance does not exceed PP. Determine how many positive integers XX make this count exactly KK. Print Infinity if there are infinitely many valid values. Travel through intermediate cities is allowed.

Input

First line: n,P,Kn,P,K. Next nn lines: the symmetric matrix AA with Ai,i=0A_{i,i}=0 and off-diagonal entries equal to −1-1 or positive integers.

Output

Print the number of valid values of XX, or Infinity.

Subtasks

  • Subtask 1 (40 points): 2≤n≤52\le n\le 5, 1≤P≤301\le P\le 30, 0≤K≤n(n−1)/20\le K\le n(n-1)/2, Ai,j∈{−1}∪[1,30]A_{i,j}\in\{-1\}\cup[1,30]. All input conditions remain in force.

  • Subtask 2 (60 points): 2≤n≤402\le n\le 40, 1≤P≤1091\le P\le 10^9, 0≤K≤n(n−1)/20\le K\le n(n-1)/2, Ai,j∈{−1}∪[1,108]A_{i,j}\in\{-1\}\cup[1,10^8]. All input conditions remain in force.

Examples

Input

3 4 2
0 3 -1
3 0 5
-1 5 0

Output

3

Explanation

Exactly X=2,3,4 produce two city pairs at distance at most 4; therefore the answer is 3.