p03425 AtCoder Beginner Contest 089 - March

There are N people. The name of the i-th person is S_i.

We would like to choose three people so that the following conditions are met:

* The name of every chosen person begins with `M`, `A`, `R`, `C` or `H`.
* There are no multiple people whose names begin with the same letter.

How many such ways are there to choose three people, disregarding order?

Note that the answer may not fit into a 32-bit integer type.

Constraints

* 1 \leq N \leq 10^5
* S_i consists of uppercase English letters.
* 1 \leq |S_i| \leq 10
* S_i \neq S_j (i \neq j)

Input

Input is given from Standard Input in the following format:

N
S_1
:
S_N

Output

If there are x ways to choose three people so that the given conditions are met, print x.

Examples

Input

5
MASHIKE
RUMOI
OBIRA
HABORO
HOROKANAI

Output

2

Input

4
ZZ
ZZZ
Z
ZZZZZZZZZZ

Output

0

Input

5
CHOKUDAI
RNG
MAKOTO
AOKI
RINGO

Output

7

```python
import itertools
N = int(input())
# N=10^5
count={}
for i in range(N):
    c = input()[0]
    count[c] = count.get(c, 0)+1
s = 0
for a,b,c in itertools.combinations("MARCH", 3):
    s += count.get(a,0)*count.get(b,0)*count.get(c,0)
print(s)

```


p03582 CODE FESTIVAL 2017 qual B - Largest Smallest Cyclic Shift

For a string S, let f(S) be the lexicographically smallest cyclic shift of S. For example, if S = `babca`, f(S) = `ababc` because this is the smallest among all cyclic shifts (`babca`, `abcab`, `bcaba`, `cabab`, `ababc`).

You are given three integers X, Y, and Z. You want to construct a string T that consists of exactly X `a`s, exactly Y `b`s, and exactly Z `c`s. If there are multiple such strings, you want to choose one that maximizes f(T) lexicographically.

Compute the lexicographically largest possible value of f(T).

Constraints

* 1 \leq X + Y + Z \leq 50
* X, Y, Z are non-negative integers.

Input

Input is given from Standard Input in the following format:

X Y Z

Output

Print the answer.

Examples

Input

2 2 0

Output

abab

Input

1 1 1

Output

acb

```python
a,b,c = map(int,input().split())

L = [[0] for _ in range(a)] + [[1] for _ in range(b)] + [[2] for _ in range(c)]
while len(L) > 1:
  L[0] += L.pop()
  L.sort()
print(''.join(('a','b','c')[i] for i in L[0]))
```


p03739 AtCoder Beginner Contest 059 - Sequence

You are given an integer sequence of length N. The i-th term in the sequence is a_i. In one operation, you can select a term and either increment or decrement it by one.

At least how many operations are necessary to satisfy the following conditions?

* For every i (1≤i≤n), the sum of the terms from the 1-st through i-th term is not zero.
* For every i (1≤i≤n-1), the sign of the sum of the terms from the 1-st through i-th term, is different from the sign of the sum of the terms from the 1-st through (i+1)-th term.

Constraints

* 2 ≤ n ≤ 10^5
* |a_i| ≤ 10^9
* Each a_i is an integer.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_n

Output

Print the minimum necessary count of operations.

Examples

Input

4
1 -3 1 0

Output

4

Input

5
3 -6 4 -5 7

Output

0

Input

6
-1 4 3 2 -5 4

Output

8

```python
n=int(input())
a=list(map(int,input().split()))
u=0
s=1
x=0
y=0
for i in a:
    u+=i
    if s*u<=0:
      x+=1-s*u
      u=s
    s=s*(-1)
s=-1
u=0
for i in a:
    u+=i
    if s*u<=0:
      y+=1-s*u
      u=s
    s=-1*s
print(min(x,y))
```


p03901 CODE FESTIVAL 2016 Elimination Tournament Round 2 (Parallel) - Takahashi is Missing!

Aoki is in search of Takahashi, who is missing in a one-dimentional world. Initially, the coordinate of Aoki is 0, and the coordinate of Takahashi is known to be x, but his coordinate afterwards cannot be known to Aoki.

Time is divided into turns. In each turn, Aoki and Takahashi take the following actions simultaneously:

* Let the current coordinate of Aoki be a, then Aoki moves to a coordinate he selects from a-1, a and a+1.

* Let the current coordinate of Takahashi be b, then Takahashi moves to the coordinate b-1 with probability of p percent, and moves to the coordinate b+1 with probability of 100-p percent.

When the coordinates of Aoki and Takahashi coincide, Aoki can find Takahashi. When they pass by each other, Aoki cannot find Takahashi.

Aoki wants to minimize the expected number of turns taken until he finds Takahashi. Find the minimum possible expected number of turns.

Constraints

* 1 ≦ x ≦ 1,000,000,000
* 1 ≦ p ≦ 100
* x and p are integers.

Input

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

x
p

Output

Print the minimum possible expected number of turns. The output is considered correct if the absolute or relative error is at most 10^{-6}.

Examples

Input

3
100

Output

2.0000000

Input

6
40

Output

7.5000000

Input

101
80

Output

63.7500000

```python
#!/usr/bin/env python3
import math
x = int(input())
p = int(input())/100
print(math.ceil(x / 2) / p)

```


p00007 Debt Hell

Your friend who lives in undisclosed country is involved in debt. He is borrowing 100,000-yen from a loan shark. The loan shark adds 5% interest of the debt and rounds it to the nearest 1,000 above week by week.

Write a program which computes the amount of the debt in n weeks.

Input

An integer n (0 ≤ n ≤ 100) is given in a line.

Output

Print the amout of the debt in a line.

Example

Input

5

Output

130000

```python
import math
n = int(input())
a = 100000
for _ in range(n):
    a *= 1.05
    a = 1000 * math.ceil(a / 1000)
print(a)

```


p00139 Snakes

In a world, a mysterious snake made of only letters lives. Two types of snakes are currently identified, type A and type B, but there may be other types as well.

For class A, after ">'" is followed by one or more "=", "#" comes, and after the same number of "=" as before, "~" (half-width tilde) finish.

Class B ends with "~~" after "> ^" followed by one or more "Q =".

Example of type A:>'==== # ==== ~>'== # == ~

Example of B type:> ^ Q = Q = Q = Q = ~~> ^ Q = Q = ~~

Receives a snake as character string data, determines what kind it is, and outputs "A" for type A, "B" for type B, and "NA" for other types. Please create a program to do.

Input

The input is given in the following format:

n
S1
S2
::
Sn

The number of snakes identified on the first line n (1 ≤ n ≤ 10000), and the following n lines contain the i-th snake string Si (200 characters or less, without spaces) on each line. Is given to.

Output

Print the i-th snake type A, B or NA on line i.

Example

Input

3
>'======#======~
>^Q=Q=Q=Q=Q=Q=Q=Q=Q=~~
>'===#====~

Output

A
B
NA

```python
import re

SNAKE_A = re.compile(r">'(=+)#\1~")
SNAKE_B = re.compile(r">\^(Q=)+~~")

def answer(regex, string, output):
    result = regex.fullmatch(string)

    if result is not None:
        print(output)
    else:
        print("NA")

for _ in range(int(input())):

    snake = input()

    if snake[1] == "'":
        answer(SNAKE_A, snake, "A")
    else:
        answer(SNAKE_B, snake, "B")

```


p00272 Ticket Sales

Today is the ticket release date for Aizu Entertainment's recommended idol group "Akabeko & Koboushi". There are four types of tickets:

S seat 6000 yen
A seat 4000 yen
B seat 3000 yen
C seat 2000 yen

You, the sales manager, are excitedly waiting for the launch. Finally on sale. It's selling very well!

Shortly after the launch, I received a table summarizing the orders up to that point. Each row of the table shows the type and number of tickets sold so far. However, the ticket types do not always appear in the order of S, A, B, C. Create a program to find the sales amount for each row in this table.

input

Input data is given in the following format.

t1 n1
t2 n2
t3 n3
t4 n4

The input consists of 4 lines. Line i is given the integer ti (1 ≤ ti ≤ 4) for the ticket type and the integer ni (0 ≤ ni ≤ 10000) for the number of tickets. The integers 1, 2, 3, and 4 representing the ticket types represent S seats, A seats, B seats, and C seats, respectively. Numbers from 1 to 4 always appear once as values for t1, t2, t3, and t4, but they are not always given in the order of 1, 2, 3, 4.

output

Output the sales amount for each line.

Example

Input

3 10
1 4
4 1
2 5

Output

30000
24000
2000
20000

```python
for i in range(4):
    t,n=map(int,input().split())
    if t==1:
        print(f'{6000*n}')
    elif t==2:
        print(f'{4000*n}')
    elif t==3:
        print(f'{3000*n}')
    elif t==4:
        print(f'{2000*n}')

```


p00460 Bingo

problem

In one programming contest, it is customary to play a bingo game at a social gathering after the competition. However, the bingo card used in this bingo game is a little special and is created according to the following conditions.

* The Bingo card is divided into squares of N rows and N columns, and one positive integer is written in each square. All those integers are different.
* The integer written in the square is 1 or more and M or less.
* The sum of N × N integers written on the Bingo card is S.
* When looking at any column, the integers are arranged in ascending order from top to bottom.
* The integer in every square is larger than any integer in the column to the left of that square.

The following is an example of a Bingo card when N = 5, M = 50, S = 685.

<image>

I want to make as many bingo cards as possible that meet the above conditions for the social gathering. However, you must not make more than one same card. Create a program that outputs the remainder of the maximum number of Bingo cards that can be created divided by 100000.

input

The input consists of multiple datasets. Each dataset is given in the following format.

The input consists of one line, which contains the size of the bingo card N (1 ≤ N ≤ 7), the upper limit of the integers written in the square M (1 ≤ M ≤ 2000), and the bingo card. Three positive integers representing the sum of integers S (1 ≤ S ≤ 3000) are written separated by blanks. However, you can make one or more bingo cards that meet the conditions for any given input data.

When N, M, S is 0, it indicates the end of input. The number of data sets does not exceed 5.

output

For each dataset, divide the maximum number of Bingo cards that can be created by 100000 and output the remainder on one line.

Examples

Input

3 9 45
3 100 50
5 50 685
0 0 0

Output

1
7
74501

Input

None

Output

None

```python
import itertools
while 1:
    n,m,s=map(int,input().split())
    if n==0:break
    dp=[[0 for _ in range(s+1)] for _ in range(n*n+1)]
    dp[0][0]=1
    for i,j in itertools.product(range(1,n*n+1),range(s+1)):
        if j>=i:dp[i][j]+=dp[i-1][j-i]+dp[i][j-i]
        if j-m>=1:dp[i][j]+=100000-dp[i-1][j-m-1]
        dp[i][j]%=100000
    print(dp[n*n][s])
```


p00650 The House of Huge Family

Mr. Dango's family has an extremely huge number of members. Once it had about 100 members, and now it has as many as population of a city. It is jokingly guessed that the member might fill this planet in the near future.

Mr. Dango's family, the huge family, is getting their new house. Scale of the house is as large as that of town.

They all had warm and gracious personality and were close each other. However, in this year the two members of them became to hate each other. Since the two members had enormous influence in the family, they were split into two groups.

They hope that the two groups don't meet each other in the new house. Though they are in the same building, they can avoid to meet each other by adjusting passageways.

Now, you have a figure of room layout. Your task is written below.

You have to decide the two groups each room should belong to. Besides you must make it impossible that they move from any rooms belonging to one group to any rooms belonging to the other group. All of the rooms need to belong to exactly one group. And any group has at least one room.

To do the task, you can cancel building passageway. Because the house is under construction, to cancel causes some cost. You'll be given the number of rooms and information of passageway. You have to do the task by the lowest cost.

Please answer the lowest cost.

By characteristics of Mr. Dango's family, they move very slowly. So all passageways are escalators. Because of it, the passageways are one-way.

Constraints

* 2 ≤ n  ≤ 100
* -10,000 ≤ Ci ≤ 10,000
* Y1 ... Ym can't be duplicated integer by each other.

Input

The input consists of multiple datasets. Each dataset is given in the following format.

n m
X1 Y1 C1
...
Xm Ym Cm

All numbers in each datasets are integers. The integers in each line are separated by a space.

The first line of each datasets contains two integers. n is the number of rooms in the house, m is the number of passageways in the house. Each room is indexed from 0 to n-1.

Each of following  m  lines gives the details of the passageways in the house. Each line contains three integers. The first integer Xi is an index of the room, the starting point of the passageway. The second integer Yi is an index of the room, the end point of the passageway. The third integer Ci is the cost to cancel construction of the passageway. The passageways, they are escalators, are one-way. The last dataset is followed by a line containing two zeros (separated by a space).

Output

For each dataset, print the lowest cost in a line. You may assume that the all of integers of both the answers and the input can be represented by 32 bits signed integers.

Example

Input

3 2
0 1 2
1 2 1
2 1
0 1 100
2 1
0 1 0
2 1
0 1 -1
0 0

Output

1
100
0
-1

```python
# AOJ 1065 The House of Huge Family
# Python3 2018.7.10 bal4u

# UNION-FIND library
class UnionSet:
	def __init__(self, nmax):
		self.size = [1]*nmax
		self.id = [i for i in range(nmax+1)]
	def root(self, i):
		while i != self.id[i]:
			self.id[i] = self.id[self.id[i]]
			i = self.id[i]
		return i
	def connected(self, p, q): return self.root(p) == self.root(q)
	def unite(self, p, q):
		i, j = self.root(p), self.root(q)
		if i == j: return
		if self.size[i] < self.size[j]:
			self.id[i] = j
			self.size[j] += self.size[i]
		else:
			self.id[j] = i
			self.size[i] += self.size[j]
# UNION-FIND library

while True:
	n, m = map(int, input().split())
	if n == 0: break
	u = UnionSet(n)
	ans, tbl = 0, []
	for i in range(m):
		x, y, c = map(int, input().split())
		if c < 0: ans += c
		else: tbl.append((c, x, y))
	tbl.sort(reverse=True)
	for c, x, y in tbl:
		if not u.connected(x, y):
			if n > 2:
				n -= 1
				u.unite(x, y)
			else: ans += c
	print(ans)

```


p00926 Shopping

Example

Input

10 3
3 7
8 9
2 5

Output

23

```python
import sys
reader=(token for line in sys.stdin for token in line.split())

while 1:
  try:
    n=int(next(reader))
    m=int(next(reader))
  except: break

  a=[1]*(n+1)
  for i in range(m):
    c=int(next(reader))-1
    d=int(next(reader))-1
    for i in range(c,d):
      a[i]=3
  print(sum(a))
```


p01059 Gossip

Problem

N idols, numbered from 1 to n in order, are lined up in a row.
Idle i can transmit information to idle i-1 and idle i + 1 in a unit time. However, idol 1 can transmit information only to idol 2, and idol n can transmit information only to idol n-1.

At time 0, m idols with numbers a1, a2, ..., am have secret information. Find the minimum amount of time all idols can get confidential information.

Constraints

* 2 ≤ n ≤ 105
* 1 ≤ m ≤ n
* 1 ≤ ai ≤ n
* All ai values are different
* ai are given in ascending order

Input

The input is given in the following format.

n m
a1 a2 ... am

Two integers n and m are given on the first line, separated by blanks.
On the second line, m integers a1, a2, ..., am are given, separated by blanks.

Output

Outputs the minimum time that information is transmitted to all idles on one line.

Examples

Input

3 2
1 3

Output

1

Input

10 3
2 5 7

Output

3

Input

10 5
2 5 6 8 10

Output

1

Input

100000 1
1

Output

99999

```python
n, m = map(int, input().split())
a =list(map(int, input().split()))
t = max(a[0] - 1, n - a[-1])
for i in range(1, m):t = max(t, (a[i] - a[i - 1]) // 2)
print(t)

```


p01496 Bicube

Mary Thomas has a number of sheets of squared paper. Some of squares are painted either in black or some colorful color (such as red and blue) on the front side. Cutting off the unpainted part, she will have eight opened-up unit cubes. A unit cube here refers to a cube of which each face consists of one square.

She is going to build those eight unit cubes with the front side exposed and then a bicube with them. A bicube is a cube of the size 2 × 2 × 2, consisting of eight unit cubes, that satisfies the following conditions:

* faces of the unit cubes that comes to the inside of the bicube are all black;
* each face of the bicube has a uniform colorful color; and
* the faces of the bicube have colors all different.

Your task is to write a program that reads the specification of a sheet of squared paper and decides whether a bicube can be built with the eight unit cubes resulting from it.

Input

The input contains the specification of a sheet. The first line contains two integers H and W, which denote the height and width of the sheet (3 ≤ H, W ≤ 50). Then H lines follow, each consisting of W characters. These lines show the squares on the front side of the sheet. A character represents the color of a grid: alphabets and digits ('A' to 'Z', 'a' to 'z', '0' to '9') for colorful squares, a hash ('#') for a black square, and a dot ('.') for an unpainted square. Each alphabet or digit denotes a unique color: squares have the same color if and only if they are represented by the same character.

Each component of connected squares forms one opened-up cube. Squares are regarded as connected when they have a common edge; those just with a common vertex are not.

Output

Print "Yes" if a bicube can be built with the given sheet; "No" otherwise.

Examples

Input

3 40
.a....a....a....a....f....f....f....f...
#bc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#be#.
.#....#....#....#....#....#....#....#...

Output

Yes

Input

3 40
.a....a....a....a....f....f....f....f...
bc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#be#.
.#....#....#....#....#....#....#....#...

Output

Yes

Input

5 35
.a....a....a....a....f....f....f...
bc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.
.#..f.#....#....#....#....#....#...
..e##..............................
.b#................................

Output

Yes

Input

3 40
.a....a....a....a....f....f....f....f...
bc#.#cd#.#de#.#eb#.#cb#.#dc#.#ed#.#eb#.
.#....#....#....#....#....#....#....#...

Output

No

```python
from collections import deque
from string import ascii_lowercase, ascii_uppercase, digits
import sys
readline = sys.stdin.readline
write = sys.stdout.write

D = [
    (1, 5, 2, 3, 0, 4), # 'U'
    (3, 1, 0, 5, 4, 2), # 'R'
    (4, 0, 2, 3, 5, 1), # 'D'
    (2, 1, 5, 0, 4, 3), # 'L'
]
p_dice = (0, 0, 0, 1, 1, 2, 2, 3)*3

ss = digits + ascii_uppercase + ascii_lowercase
L = len(ss)

def rotate_dice(L, k):
    return [L[e] for e in D[k]]
def enumerate_dice(L0):
    L = L0[:]
    for k in p_dice:
        yield L
        L[:] = (L[e] for e in D[k])
def dice_graph(L0 = [0, 1, 2, 3, 4, 5]):
    DA = list(map(tuple, enumerate_dice(L0)))
    DM = {tuple(e): i for i, e in enumerate(DA)}
    G = [list(DM[tuple(rotate_dice(ds, i))] for i in range(4)) for ds in DA]
    return DA, G

def solve():
    H, W = map(int, readline().split())
    S = [readline().strip() for i in range(H)]

    DA, DG = dice_graph()
    dd = ((0, -1), (1, 0), (0, 1), (-1, 0))

    DS = []
    used = [[0]*W for i in range(H)]
    for i in range(H):
        for j in range(W):
            if S[i][j] == '.' or used[i][j]:
                continue
            D = [0]*6
            que = deque([(j, i, 0)])
            used[i][j] = 1
            while que:
                x, y, k = que.popleft()
                v = DA[k][0]
                c = S[y][x]
                if c == '#':
                    D[v] = L
                else:
                    D[v] = ss.index(c)
                for e, (dx, dy) in enumerate(dd):
                    nx = x + dx; ny = y + dy
                    if not 0 <= nx < W or not 0 <= ny < H or S[ny][nx] == '.' or used[ny][nx]:
                        continue
                    used[ny][nx] = 1
                    que.append((nx, ny, DG[k][e]))
            if D.count(L) != 3:
                continue
            for e in enumerate_dice(D):
                if e[3] == e[4] == e[5] == L:
                    if e[0] != e[1] and e[1] != e[2] and e[2] != e[0]:
                        DS.append(e[:3])
                    break
    P = [
        [0, 3, 4],
        [0, 2, 3],
        [0, 1, 2],
        [0, 4, 1],
        [3, 2, 5],
        [2, 1, 5],
        [1, 4, 5],
        [4, 3, 5],
    ]
    DS.sort()
    M = len(DS)
    def dfs(i, used, used_c, state):
        if i == 8:
            return 1
        ps = P[i]
        s = [0]*3
        for j in range(M):
            if used[j]:
                continue
            used[j] = 1
            d = DS[j]
            for b in range(3):
                for k in range(3):
                    p = ps[k]
                    if state[p] == -1:
                        if used_c[d[-b+k]]:
                            break
                    else:
                        if state[p] != d[-b+k]:
                            break
                else:
                    for k in range(3):
                        p = ps[k]
                        if state[p] == -1:
                            used_c[d[-b+k]] = 1
                        s[k], state[p] = state[p], d[-b+k]
                    if dfs(i+1, used, used_c, state):
                        return 1
                    for k in range(3):
                        p = ps[k]
                        state[p] = s[k]
                        if state[p] == -1:
                            used_c[d[-b+k]] = 0
            used[j] = 0
        return 0
    if M >= 8 and dfs(0, [0]*M, [0]*L, [-1]*6):
        write("Yes\n")
    else:
        write("No\n")
solve()

```


p01809 Let's Solve Geometric Problems

Let's solve the geometric problem

Mr. A is still solving geometric problems today. It is important to be aware of floating point errors when solving geometric problems.

Floating-point error is the error caused by the rounding that occurs when representing a number in binary finite decimal numbers. For example, 0.1 in decimal is an infinite decimal number of 0.00011001100110011 ... in binary, but an error occurs when rounding this to a finite number of digits.

Positive integers p and q are given in decimal notation. Find the b-ary system (b is an integer greater than or equal to 2) so that the rational number p / q can be expressed as a decimal number with a finite number of digits. If there are more than one, output the smallest one.

Constraints

* 0 <p <q <10 ^ 9

Input Format

Input is given from standard input in the following format.

p q

Output Format

Print the answer in one line.

Sample Input 1

1 2

Sample Output 1

2

1/2 is binary 0.1

Sample Input 2

21 30

Sample Output 2

Ten

21/30 is 0.7 in decimal

Example

Input

1 2

Output

2

```python
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n
p, q = map(int, input().split())
q //= gcd(p, q)

x = q; y = 1; k = 2
while k*k <= x:
    if x % k == 0:
        while x % k == 0: x //= k
        y *= k
    k += 1
y *= x

print(y)
```


p02377 Minimum Cost Flow

Examples

Input

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

Output

6

Input

Output

```python
# ノードをtupleで渡す
from collections import defaultdict
from heapq import *
class MinCostFlow:
    def __init__(self):
        self.inf=10**9
        self.to = defaultdict(dict)

    def add_edge(self, u, v, cap, cost):
        self.to[u][v]=[cap, cost]
        self.to[v][u]=[0, -cost]

    # s...source,t...sink,f...flow
    # これが本体
    def cal(self,s,t,f):
        min_cost=0
        pot=defaultdict(int)
        while f:
            dist = {}
            pre_u={}   # 最短距離の遷移元の頂点
            # ダイクストラで最短距離を求める
            hp=[]
            heappush(hp,(0,s))
            dist[s]=0
            while hp:
                d,u=heappop(hp)
                if d>dist[u]:continue
                for v,[cap,cost] in self.to[u].items():
                    if cap==0:continue
                    nd=dist[u]+cost+pot[u]-pot[v]
                    dist.setdefault(v, self.inf)
                    if nd>=dist[v]:continue
                    dist[v]=nd
                    pre_u[v]=u
                    heappush(hp,(nd,v))
            # sinkまで届かなかったら不可能ということ
            if t not in dist:return -1
            # ポテンシャルを更新する
            for u,d in dist.items():pot[u]+=d
            # パスs-t上で最小の容量=流す量を求める
            u=t
            min_cap=f
            while u!=s:
                u,v=pre_u[u],u
                min_cap=min(min_cap,self.to[u][v][0])
            # フローから流す量を減らし、コストを加える
            f-=min_cap
            min_cost+=min_cap*pot[t]
            # パスs-tの容量を更新する
            u=t
            while u!=s:
                u,v=pre_u[u],u
                self.to[u][v][0]-=min_cap
                self.to[v][u][0]+=min_cap
        return min_cost

def main():
    n,m,f=map(int,input().split())
    mc=MinCostFlow()
    for _ in range(m):
        u,v,c,d=map(int,input().split())
        mc.add_edge(u,v,c,d)
    print(mc.cal(0,n-1,f))

main()

```