package codforce;

import java.util.Scanner;

public class ABlackSquare {

	private static int[] kal;

	public static void main(String[] args) {
		kal = new int[4];
		Scanner in = new Scanner(System.in);

		for (int i = 0; i < 4; i++) {
			kal[i] = in.nextInt();
		}

		String line = in.next();

		int result = 0;
		int length = line.length();

		int process = Integer.parseInt(line);

		while (process > 0) {
			int a = process % 10;
//			System.out.println("a = " + a +"  "+  result);
			result += kal[a-1];
			process -= a;
			process /= 10;
		}
//
//		System.out.println();
//		System.out.println("================");
//		System.out.println();
		System.out.println(result);
	}

}


import java.io.PrintWriter;
import java.util.Scanner;

public class ABlackSquare {

    private static int[] kal;

    public static void main(String[] args) {
        kal = new int[4];

        @SuppressWarnings("resource")
        Scanner in = new Scanner(System.in);
        PrintWriter out  = new PrintWriter(System.out);

        for (int i = 0; i < 4; i++) {
            kal[i] = in.nextInt();
        }

        String line = in.next();

        int result = 0;

        int process = Integer.parseInt(line);

        while (process > 0) {
            int a = process % 10;
            result += kal[a-1];
            process -= a;
            process /= 10;
        }

        out.print(result);

         out.flush();
    }

}


import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int[]calories=new int[4];
        for(int i=0 ; i<calories.length ; i++)
            calories[i]=in.nextInt();
        String s=in.next();
        int sumCal=0;
        for(int i=0 ; i<s.length() ; i++){
            if(s.charAt(i)==1)
                sumCal+=calories[0];
            else if(s.charAt(i)==2)
                sumCal+=calories[1];
            else if(s.charAt(i)==3)
                sumCal+=calories[2];
            else
                sumCal+=calories[3];
        }//End for
        System.out.println(sumCal);
    }//End main()
}//End class


import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int[]calories=new int[4];
        for(int i=0 ; i<calories.length ; i++)
            calories[i]=in.nextInt();
        String s=in.next();
        int sumCal=0;
        for(int i=0 ; i<s.length() ; i++){
            if(s.charAt(i)=='1')
                sumCal+=calories[0];
            else if(s.charAt(i)=='2')
                sumCal+=calories[1];
            else if(s.charAt(i)=='3')
                sumCal+=calories[2];
            else
                sumCal+=calories[3];
        }//End for
        System.out.println(sumCal);
    }//End main()
}//End class


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        Scanner input = new Scanner(System.in);

int value[] = new int[100];
int process[] = new int[100];
int j=0;
int y=0;
int ans=0;
while (j<5){
 value[j] =input.nextInt();

j++;
}
while(value[4]>0){
process[y]=value[4]%10;

ans=ans+value[(process[y]-1)];
y++;
value[4]=value[4]/10;

}
System.out.println(ans);
    }
}


import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        Scanner input = new Scanner(System.in);

int value[] = new int[100];
int process[] = new int[100];
String a;
int e=0;
int l=0;
int j=0;
int y=0;
int ans=0;
while (j<4){
 value[j] =input.nextInt();

j++;
}
a=input.next();
while(l<a.length()){
e=a.charAt(l)-'0';

ans=ans+value[e-1];

l++;
}

System.out.println(ans);
    }
}


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
 public class Main
{
    public static void main (String[] args) throws java.lang.Exception
    {
        Scanner input = new Scanner(System.in);

int value[] = new int[100];
int process[] = new int[100];
int j=0;
int y=0;
int ans=0;
while (j<5){
 value[j] =input.nextInt();
System.out.println(value[j]);
j++;
}
while(value[4]>0){
process[y]=value[4]%10;
System.out.println(process[y]);
ans=ans+value[(process[y]-1)];
y++;
value[4]=value[4]/10;

}
System.out.println("ans"+ans);
    }
}


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner scan=new Scanner(System.in);
		int first=scan.nextInt();
		int second=scan.nextInt();
		int third=scan.nextInt();
		int fourth=scan.nextInt();

		scan.nextLine();

		String input=scan.nextLine();
		int sum=0;
		for(int i=0;i<input.length();i++)
		{
			if(input.charAt(i)=='1')
				sum+=first;
			else if(input.charAt(i)=='2')
				sum+=second;
			else if(input.charAt(i)=='3')
				sum+=third;
			else
				sum+=fourth;
		}
		System.out.println(sum);

	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int a[] = new int[4];
        a[0]= in.nextInt();
        a[1]  = in.nextInt();
        a[2] = in.nextInt();
        a[3] = in.nextInt();
        in.nextLine();
        String s= in.nextLine();
        int sum = 0;
        for (Character c :s.toCharArray()) {
           sum +=a[c-'1'];
        }
        out.println(sum);
    }
}

class InputReader {

    private InputStream stream;
    int curCharIndex = 0;
    int charsInBuf = 0;
     byte buf[] = new byte[16*1024];

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int readChar() {

        if (curCharIndex >= charsInBuf) {
            curCharIndex = 0;
            try {
                charsInBuf = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (charsInBuf <= 0)
                return -1;
        }
        return buf[curCharIndex++];
    }

    public String nextLine() {
        StringBuilder buf = new StringBuilder();
        int c = readChar();
        while (c != '\n' && c != -1) {
            if (c != '\r')
                buf.appendCodePoint(c);
                c = readChar();
        }
        return buf.toString();
    }

    public int nextInt() {

        int c;
        do {
            c = readChar();
        }while(isWhitespace(c));

        int sign = 1;
        if (c == '-') {
            c = readChar();
            sign = -1;

        }
        int res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = readChar();
        } while (!isWhitespace(c) && c!=-1);
        return sign * res;
    }

    /*
    * For the purpose of compatibilty with Chelper Chrome extension
     */

    private boolean isWhitespace(int c) {
        return  c==' ' || c=='\n'|| c=='\r' || c=='\t';
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }
}

class TaskA {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int a[] = new int[4];
        a[0]= in.nextInt();
        a[1]  = in.nextInt();
        a[2] = in.nextInt();
        a[3] = in.nextInt();
        String s= in.nextLine();
        int sum = 0;
        for (Character c :s.toCharArray()) {
           sum +=a[c-'1'];
        }
        out.println(sum);
    }
}

class InputReader {

    private InputStream stream;
    int curCharIndex = 0;
    int charsInBuf = 0;
     byte buf[] = new byte[16*1024];

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int readChar() {

        if (curCharIndex >= charsInBuf) {
            curCharIndex = 0;
            try {
                charsInBuf = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (charsInBuf <= 0)
                return -1;
        }
        return buf[curCharIndex++];
    }

    public String nextLine() {
        StringBuilder buf = new StringBuilder();
        int c = readChar();
        while (c != '\n' && c != -1) {
            if (c != '\r')
                buf.appendCodePoint(c);
                c = readChar();
        }
        return buf.toString();
    }

    public int nextInt() {

        int c;
        do {
            c = readChar();
        }while(isWhitespace(c));

        int sign = 1;
        if (c == '-') {
            c = readChar();
            sign = -1;

        }
        int res = 0;
        do {
            res *= 10;
            res += c - '0';
            c = readChar();
        } while (!isWhitespace(c) && c!=-1);
        return sign * res;
    }

    /*
    * For the purpose of compatibilty with Chelper Chrome extension
     */

    private boolean isWhitespace(int c) {
        return  c==' ' || c=='\n'|| c=='\r' || c=='\t';
    }
}


//package Codeforces.Div2A_247.Code1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/*
 * some cheeky quote
 */

public class Main
{
    FastScanner in;
    PrintWriter out;

    public void solve() throws IOException
    {
        int a[] = new int[5];
        for (int i = 1; i < a.length; i++)
        {
            a[i] = in.nextInt();
        }
        int total = 0;
        char input[] = in.next().toCharArray();
        for (int i = 0; i < input.length; i++)
        {
            total += a[input[i] - 48];
        }
        System.out.println(total);

    }

    public void run()
    {
        try
        {
            in = new FastScanner();
            out = new PrintWriter(System.out);

            solve();

            out.close();
        } catch (IOException e)
        {
            e.printStackTrace();
        }
    }

    class FastScanner
    {
        BufferedReader br;
        StringTokenizer st;

        FastScanner()
        {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreTokens())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }
    }

    public static void main(String[] arg)
    {
        new Main().run();
    }
}


import java.util.*;
public class Main
{
public static void main(String args[])
{
int a[],num,count=0,i;
String str1;
Scanner s=new Scanner(System.in);
a=new int[10];
for(i=1;i<=4;i++)
{
a[i]=s.nextInt();
}
String str=s.next();
for(i=0;i<str.length();i++)
{
str1=""+str.charAt(i);
num=Integer.parseInt(str1);
count+=a[num];
}
System.out.println(count);
}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class BlackSquare_431A {

    public static void main(String[] args)throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int val[] = new int[5];
        StringTokenizer st = new StringTokenizer(br.readLine());
        for(int i=1; i<5; i++){
            val[i] = Integer.parseInt(st.nextToken());
        }
        String s = br.readLine();
        int ans = 0;
        for(int i=0; i<s.length(); i++){
            ans += val[s.charAt(i)-'0'];
        }
        System.out.println(ans);
    }

}


import java.util.Scanner;

/*
import doge.wow.Shibeforces;
░░░░░░░░░▄░░░░░░░░░░░░░░▄░░░░
░░░░░░░░▌▒█░░░░░░░░░░░▄▀▒▌░░░
░░░░░░░░▌▒▒█░░░░░░░░▄▀▒▒▒▐░░░
░░░░░░░▐▄▀▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐░░░
░░░░░▄▄▀▒░▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐░░░
░░░▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌░░░
░░▐▒▒▒▄▄▒▒▒▒░░░▒▒▒▒▒▒▒▀▄▒▒▌░░
░░▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐░░
░▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌░
░▌░▒▄██▄▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌░
▀▒▀▐▄█▄█▌▄░▀▒▒░░░░░░░░░░▒▒▒▐░
▐▒▒▐▀▐▀▒░▄▄▒▄▒▒▒▒▒▒░▒░▒░▒▒▒▒▌
▐▒▒▒▀▀▄▄▒▒▒▄▒▒▒▒▒▒▒▒░▒░▒░▒▒▐░
░▌▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒░▒░▒░▒░▒▒▒▌░
░▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▄▒▒▐░░
░░▀▄▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▄▒▒▒▒▌░░
░░░░▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀░░░
░░░░░░▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀░░░░░
░░░░░░░░░▒▒▒▒▒▒▒▒▒▒▀▀░░░░░░░░
wow
much code violence
such dangers
hw dis hapen?!!
*/

public class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int a[] = new int[4];
		a[0] = in.nextInt();
		a[1] = in.nextInt();
		a[2] = in.nextInt();
		a[3] = in.nextInt();

		int cal = 0;
		String s = in.next();
		for(int i = 0; i < s.length();i++)
			cal += a[Integer.parseInt(s.charAt(i) + "")-1];
		System.out.println(cal);
	}
}


import java.awt.Toolkit;
import java.io.*;
import java.util.*;

public class Main {
public static int count(int[]ar,int s,int e, int c){

    for (int i = s; i <=e; i++) {

            if(ar[i]==0)c++;
            else c--;
    }
    return c;
}
    public static void main(String args[]) throws IOException {
        Reader.init(System.in);

    int ar [] = new int[4];
        for (int i = 0; i < ar.length; i++) {
          ar[i] = Reader.nextInt();

        }
        String s = Reader.next();
        int sum = 0 ;
        for (int i = 0; i < s.length(); i++) {
              sum+=ar[Character.getNumericValue(s.charAt(i))-1];
        }
        System.out.println(sum);

    }
}

class dragons implements Comparable<dragons> {

    int power, bounes;

    public dragons(int p, int b) {
        this.power = p;
        this.bounes = b;
    }

    @Override
    public int compareTo(dragons o) {
        return Integer.compare(this.power, o.power);
    }

}

class Reader {

    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /**
     * call this method to initialize reader for InputStream
     */
    static void init(InputStream input) {
        reader = new BufferedReader(
                new InputStreamReader(input));
        tokenizer = new StringTokenizer("");
    }

    /**
     * get next word
     */
    static String next() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                    reader.readLine());
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
     static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static public void nextIntArrays(int[]... arrays) throws IOException {
        for (int i = 1; i < arrays.length; ++i) {
            if (arrays[i].length != arrays[0].length) {
                throw new InputMismatchException("Lengths are different");
            }
        }
        for (int i = 0; i < arrays[0].length; ++i) {
            for (int[] array : arrays) {
                array[i] = nextInt();
            }
        }
    }

    static public void nextLineArrays(String[]... arrays) throws IOException {
        for (int i = 1; i < arrays.length; ++i) {
            if (arrays[i].length != arrays[0].length) {
                throw new InputMismatchException("Lengths are different");
            }
        }
        for (int i = 0; i < arrays[0].length; ++i) {
            for (String[] array : arrays) {
                array[i] = reader.readLine();
            }
        }
    }}


import java.io.*;
import java.math.*;
import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		while(in.hasNext())
		{
			int a1 = in.nextInt(),a2 = in.nextInt(),a3 = in.nextInt(),a4 = in.nextInt();
			String s = in.next();
			int length = s.length(),sum = 0;
			for(int i = 0; i < length; i++)
			{
				if(s.charAt(i) == '1')
					sum += a1;
				else if(s.charAt(i) == '2')
					sum += a2;
				else if(s.charAt(i) == '3')
					sum += a3;
				else
					sum += a4;
			}
			System.out.println(sum);
		}
	}
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);

        //inputs
        int a1 = in.nextInt();
        int a2 = in.nextInt();
        int a3 = in.nextInt();
        int a4 = in.nextInt();
        String s = in.next();

        int cnt=0;
        for(int i=0 ; i<s.length() ; i++)
            if(s.charAt(i) == '1')
                cnt +=a1;
            else if(s.charAt(i) == '2')
                cnt += a2;
            else if(s.charAt(i) == '3')
                cnt += a3;
            else
                cnt += a4;

        System.out.println(cnt);
            }
    }


import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Hasan0504 {

    public static void main(String[] args) throws IOException {
    // BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
        // BufferedReader b1=new BufferedReader(new InputStreamReader(System.in));
        Scanner input = new Scanner(System.in);
        int []a=new int[4];
        for(int i=0;i<a.length;i++)
            a[i]=input.nextInt();
        String A=input.next();
        int sum=0;
        for(int i=0;i<A.length();i++){

           sum+=a[Integer.parseInt(String.valueOf(A.charAt(i)))-1];
        }
        System.out.println(sum);
    }
}


package c247;

import java.util.Scanner;

public class A {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a[] = new int[4];
        for(int i = 0; i < 4; i++)
            a[i] =  scan.nextInt();
        String str = scan.next();
        String num = "1234";
        int ans = 0;
        for(int i = 0; i < str.length(); i++) {
            for(int j = 0; j < num.length(); j++) {
                if(str.charAt(i) == num.charAt(j))
                    ans += a[num.charAt(j) - '1'];
            }
        }
        System.out.println(ans);
    }
}


package c247;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a[] = new int[4];
        for(int i = 0; i < 4; i++)
            a[i] =  scan.nextInt();
        String str = scan.next();
        String num = "1234";
        int ans = 0;
        for(int i = 0; i < str.length(); i++) {
            for(int j = 0; j < num.length(); j++) {
                if(str.charAt(i) == num.charAt(j))
                    ans += a[num.charAt(j) - '1'];
            }
        }
        System.out.println(ans);
    }
}


import java.util.Scanner;

public class A {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a[] = new int[4];
        for (int i = 0; i < 4; i++)
            a[i] = scan.nextInt();
        String str = scan.next();
        String num = "1234";
        int ans = 0;
        for (int i = 0; i < str.length(); i++) {
            for (int j = 0; j < num.length(); j++) {
                if (str.charAt(i) == num.charAt(j))
                    ans += a[num.charAt(j) - '1'];
            }
        }
        System.out.println(ans);
        scan.close();
    }
}


import java.util.Scanner;

public class A {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a[] = new int[4];
        for(int i = 0; i < 4; i++)
            a[i] =  scan.nextInt();
        String str = scan.next();
        String num = "1234";
        int ans = 0;
        for(int i = 0; i < str.length(); i++) {
            for(int j = 0; j < num.length(); j++) {
                if(str.charAt(i) == num.charAt(j))
                    ans += a[num.charAt(j) - '1'];
            }
        }
        System.out.println(ans);
    }
}


import java.io.*;
import java.util.*;

public class Solution {

    public void solve() throws IOException {
        int[] lines = { 0, in.nextInt(), in.nextInt(), in.nextInt(), in.nextInt() };
        String s = in.nextLine();
        StringBuilder sb = new StringBuilder(s);
        int sum = 0;
        for (int i = 0; i < s.length(); i++) {
            sum += lines[Integer.parseInt(sb.substring(0, 1))];
            sb.delete(0, 1);
        }
        System.out.println(sum);

    }

    public static String fileName = "";
    public PrintWriter out;
    MyScanner in;

    public void run() throws IOException {
        in = new MyScanner();
        out = new PrintWriter(System.out);
        solve();
        in.close();
        out.close();
    }

    public class MyScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public MyScanner() throws IOException {
            this.br = new BufferedReader(new InputStreamReader(System.in));
        }

        public MyScanner(String fileTitle) throws IOException {
            this.br = new BufferedReader(new FileReader(fileTitle));
        }

        public String nextLine() throws IOException {
            String s = br.readLine();
            return s == null ? "-1" : s;
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens()) {
                String s = br.readLine();
                if (s == null) {
                    return "-1";
                }
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(this.next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(this.next());
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public void close() throws IOException {
            this.br.close();
        }
    }

    public static void main(String[] args) throws IOException {
        Locale.setDefault(Locale.US);
        new Solution().run();
    }
}


#include<iostream>
#include<vector>
#include<queue>

#define SOURCE_V 1
#define SINK_V n
#define inv(e) (e^1)

using namespace std;

const int MAX_N = 50;
const int MAX_M = 500;
const int MAX_X = 100000;
const int INF = __INT32_MAX__;

int n, m, x;
int V, E;
vector<int> startEdges; // Indexed by V
vector<int> nextEdges;  // Indexed by E
vector<int> toNodes;   // Indexed by E
vector<int> capacities; // Indexed by E
vector<int> originalCapacities; // Indexed by E
vector<int> levels;     // Indexed by V
vector<int> nextChild;  // Indexed by V

void addEdge(int from, int to, int capacity) {
    originalCapacities.push_back(capacity);
    capacities.push_back(0);
    toNodes.push_back(to);
    nextEdges.push_back(startEdges[from]);
    startEdges[from] = E;
    E++;
}

bool bfsInitLevelGraph() {
    levels.clear();
    levels.resize(V, -1);
    nextChild.clear();
    nextChild.resize(V, -1);
    queue<int> q;
    q.push(SOURCE_V);
    levels[SOURCE_V] = 0;
    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        nextChild[cur] = startEdges[cur];
        for (int e = startEdges[cur]; ~e; e = nextEdges[e]) {
            int next = toNodes[e];
            if (capacities[e] > 0 && levels[next] == -1) {
                levels[next] = levels[cur] + 1;
                q.push(next);
            }
        }
    }
    return levels[SINK_V] != -1;
}

int dfsAugmentPath(int cur, int minFlow) {
    if (cur == SINK_V) return minFlow;
    for (int &e = nextChild[cur]; ~e; e = nextEdges[e]) {
        int next = toNodes[e];
        if (capacities[e] > 0 && levels[next] == levels[cur] + 1) {
            int resultFlow = dfsAugmentPath(next, min(minFlow, capacities[e]));

            if (resultFlow > 0) {
                capacities[e] -= resultFlow;
                capacities[inv(e)] += resultFlow;
                return resultFlow;
            }
        }
    }
    return 0;
}

void resetCapacities(double F) {
    for (int i = 0; i < E; i++) {
        capacities[i] = originalCapacities[i] / F;
    }
}

bool maxFlowDecisionProblem(double F) {
    resetCapacities(F);

    int totalFlow = 0;
    while (bfsInitLevelGraph()) {
        while (int flow = dfsAugmentPath(SOURCE_V, INF)) {
            totalFlow += flow;
        }
    }
    return (totalFlow >= x);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(9);

    cin >> n >> m >> x;
    V = n + 1;
    E = 0;
    startEdges.resize(V + 1, -1);

    for (int i = 0; i < m; i++) {
        int from, to, capacity;
        cin >> from >> to >> capacity;
        addEdge(from, to, capacity);
        addEdge(to, from, 0);
    }

    double lo = 1e-6;   // definitely works
    double hi = 1e6;    // definitely doesn't work
    for (int it = 0; it < 70; it++) {
        double mid = (lo + hi) / 2;
        if (maxFlowDecisionProblem(mid)) {
            lo = mid;
        } else {
            hi = mid;
        }
    }
    cout << lo * x << '\n';

    return 0;
}


#include<iostream>
#include<vector>
#include<queue>

#define SOURCE_V 1
#define SINK_V n
#define inv(e) (e^1)

using namespace std;

typedef long long longL;

const int MAX_N = 50;
const int MAX_M = 500;
const int MAX_X = 100000;
const int INF = __INT32_MAX__;

int n, m, x;
int V, E;
vector<int> startEdges; // Indexed by V
vector<int> nextEdges;  // Indexed by E
vector<int> toNodes;   // Indexed by E
vector<longL> capacities; // Indexed by E
vector<int> originalCapacities; // Indexed by E
vector<int> levels;     // Indexed by V
vector<int> nextChild;  // Indexed by V

void addEdge(int from, int to, int capacity) {
    originalCapacities.push_back(capacity);
    capacities.push_back(0);
    toNodes.push_back(to);
    nextEdges.push_back(startEdges[from]);
    startEdges[from] = E;
    E++;
}

bool bfsInitLevelGraph() {
    levels.clear();
    levels.resize(V, -1);
    nextChild.clear();
    nextChild.resize(V, -1);
    queue<int> q;
    q.push(SOURCE_V);
    levels[SOURCE_V] = 0;
    while (!q.empty()) {
        int cur = q.front();
        q.pop();
        nextChild[cur] = startEdges[cur];
        for (int e = startEdges[cur]; ~e; e = nextEdges[e]) {
            int next = toNodes[e];
            if (capacities[e] > 0 && levels[next] == -1) {
                levels[next] = levels[cur] + 1;
                q.push(next);
            }
        }
    }
    return levels[SINK_V] != -1;
}

int dfsAugmentPath(int cur, longL minFlow) {
    if (cur == SINK_V) return minFlow;
    for (int &e = nextChild[cur]; ~e; e = nextEdges[e]) {
        int next = toNodes[e];
        if (capacities[e] > 0 && levels[next] == levels[cur] + 1) {
            int resultFlow = dfsAugmentPath(next, min(minFlow, capacities[e]));

            if (resultFlow > 0) {
                capacities[e] -= resultFlow;
                capacities[inv(e)] += resultFlow;
                return resultFlow;
            }
        }
    }
    levels[cur] = -1;
    return 0;
}

void resetCapacities(double F) {
    for (int i = 0; i < E; i++) {
        capacities[i] = (originalCapacities[i] / F);
    }
}

bool maxFlowDecisionProblem(double F) {
    resetCapacities(F);

    int totalFlow = 0;
    while (bfsInitLevelGraph()) {
        while (int flow = dfsAugmentPath(SOURCE_V, INF)) {
            totalFlow += flow;
        }
    }
    return (totalFlow >= x);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(9);

    cin >> n >> m >> x;
    V = n + 1;
    E = 0;
    startEdges.resize(V + 1, -1);

    for (int i = 0; i < m; i++) {
        int from, to, capacity;
        cin >> from >> to >> capacity;
        addEdge(from, to, capacity);
        addEdge(to, from, 0);
    }

    double lo = 1e-6;   // definitely works
    double hi = 1e6;    // definitely doesn't work
    for (int it = 0; it < 70; it++) {
        double mid = (lo + hi) / 2;
        if (maxFlowDecisionProblem(mid)) {
            lo = mid;
        } else {
            hi = mid;
        }
    }
    cout << lo * x << '\n';

    return 0;
}


#include<iostream>
#include<cstring>
#include<vector>
#include<queue>

using namespace std;

struct Edge {
    int succ;
    int to;
    int capacity;
    int originalCapacity;
};

const int INF = __INT32_MAX__;
double EPS;

int n, m, x;
int SOURCE_V, SINK_V;

int V = 0, E = 0;
vector<int> start;
vector<Edge> edges;
vector<int> levels;
vector<int> nextChild;

void addEdge(int from, int to, int capacity) {
    edges[E] = { start[from], to, 0, capacity };
    start[from] = E;
    E++;
    edges[E] = { start[to], from, 0, 0 };
    start[to] = E;
    E++;
}

void debug() {
    for (int i = 1; i <= V; i++) {
        cout << "vertex " << i << ": ";
        for (int j = start[i]; j != -1; j = edges[j].succ) {
            cout << "(" << edges[j].to << ", " << edges[j].capacity << ", " << edges[j].originalCapacity << ") ";
        }
        cout << endl;
    }
}

int inv(int e) { return e^1; }

bool bfsInitLevelGraph() {
    levels.clear();
    nextChild.clear();
    levels.resize(V + 1, -1);
    nextChild.resize(V + 1, -1);
    queue<int> q;
    q.push(SOURCE_V);
    levels[SOURCE_V] = 0;
    while (!q.empty()) {
        int curNode = q.front();
        q.pop();
        nextChild[curNode] = start[curNode];
        for (int i = start[curNode]; i != -1; i = edges[i].succ) {
            Edge e = edges[i];
            if (e.capacity > 0 && levels[e.to] == -1) {
                levels[e.to] = levels[curNode] + 1;
                q.push(e.to);
            }
        }
    }
    return levels[SINK_V] != -1;
}

int dfsAugmentPath(int cur, int minFlow) {
    if (cur == SINK_V) return minFlow;
    for (int &i = nextChild[cur]; i != -1; i = edges[i].succ) {
        Edge &e = edges[i];
        if (e.capacity > 0) {
            if (levels[e.to] != levels[cur] + 1) continue;

            int resultFlow = dfsAugmentPath(e.to, min(e.capacity, minFlow));

            if (resultFlow > 0) {
                e.capacity -= resultFlow;
                edges[inv(i)].capacity += resultFlow;
                return resultFlow;
            }
        }
    }
    levels[SOURCE_V] = -1;
    return 0;
}

void resetCapacities(double F) {
    for (Edge &e: edges) {
        e.capacity = e.originalCapacity / F;
    }
}

bool maxFlowDecisionProblem(double F) {
    resetCapacities(F);

    int totalFlow = 0;

    while (bfsInitLevelGraph()) {
        for (int flow = dfsAugmentPath(SOURCE_V, INF); flow != 0; flow = dfsAugmentPath(SOURCE_V, INF)) {
            totalFlow += flow;
        }
    }

    return totalFlow >= x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(8);

    cin >> n >> m >> x;

    SOURCE_V = 1;
    SINK_V = n;
    V = n;
    start.resize(V + 1, -1);
    edges.resize((m << 1), { 0, 0, 0, 0 });

    double maxF = 0;

    for (int i = 0; i < m; i++) {
        int from, to, cap;
        cin >> from >> to >> cap;
        addEdge(from, to, cap);

        if (cap > maxF) maxF = cap;
    }

    long double lo = 0; // definitely works
    long double hi = maxF + 1; // definitely not

    EPS = 0.0000001 / x;
    while (hi - lo > EPS) {
    cout << lo << " " << hi << endl;
        long double mid = (lo + hi) / 2;
        if (maxFlowDecisionProblem(mid)) {
            lo = mid;
        } else {
            hi = mid;
        }
    }

    cout << x * lo << endl;
}


#include<iostream>
#include<cstring>
#include<vector>
#include<queue>

using namespace std;

struct Edge {
    int succ;
    int to;
    int capacity;
    int originalCapacity;
};

const int INF = __INT32_MAX__;
double EPS;

int n, m, x;
int SOURCE_V, SINK_V;

int V = 0, E = 0;
vector<int> start;
vector<Edge> edges;
vector<int> levels;
vector<int> nextChild;

void addEdge(int from, int to, int capacity) {
    edges[E] = { start[from], to, 0, capacity };
    start[from] = E;
    E++;
    edges[E] = { start[to], from, 0, 0 };
    start[to] = E;
    E++;
}

void debug() {
    for (int i = 1; i <= V; i++) {
        cout << "vertex " << i << ": ";
        for (int j = start[i]; j != -1; j = edges[j].succ) {
            cout << "(" << edges[j].to << ", " << edges[j].capacity << ", " << edges[j].originalCapacity << ") ";
        }
        cout << endl;
    }
}

int inv(int e) { return e^1; }

bool bfsInitLevelGraph() {
    levels.clear();
    nextChild.clear();
    levels.resize(V + 1, -1);
    nextChild.resize(V + 1, -1);
    queue<int> q;
    q.push(SOURCE_V);
    levels[SOURCE_V] = 0;
    while (!q.empty()) {
        int curNode = q.front();
        q.pop();
        nextChild[curNode] = start[curNode];
        for (int i = start[curNode]; i != -1; i = edges[i].succ) {
            Edge e = edges[i];
            if (e.capacity > 0 && levels[e.to] == -1) {
                levels[e.to] = levels[curNode] + 1;
                q.push(e.to);
            }
        }
    }
    return levels[SINK_V] != -1;
}

int dfsAugmentPath(int cur, int minFlow) {
    if (cur == SINK_V) return minFlow;
    for (int &i = nextChild[cur]; i != -1; i = edges[i].succ) {
        Edge &e = edges[i];
        if (e.capacity > 0) {
            if (levels[e.to] != levels[cur] + 1) continue;

            int resultFlow = dfsAugmentPath(e.to, min(e.capacity, minFlow));

            if (resultFlow > 0) {
                e.capacity -= resultFlow;
                edges[inv(i)].capacity += resultFlow;
                return resultFlow;
            }
        }
    }
    levels[SOURCE_V] = -1;
    return 0;
}

void resetCapacities(double F) {
    for (Edge &e: edges) {
        e.capacity = e.originalCapacity / F;
    }
}

bool maxFlowDecisionProblem(double F) {
    resetCapacities(F);

    int totalFlow = 0;

    while (bfsInitLevelGraph()) {
        for (int flow = dfsAugmentPath(SOURCE_V, INF); flow != 0; flow = dfsAugmentPath(SOURCE_V, INF)) {
            totalFlow += flow;
        }
    }

    return totalFlow >= x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout.precision(9);

    cin >> n >> m >> x;

    SOURCE_V = 1;
    SINK_V = n;
    V = n;
    start.resize(V + 1, -1);
    edges.resize((m << 1), { 0, 0, 0, 0 });

    double maxF = 0;

    for (int i = 0; i < m; i++) {
        int from, to, cap;
        cin >> from >> to >> cap;
        addEdge(from, to, cap);

        if (cap > maxF) maxF = cap;
    }

    long double lo = 0; // definitely works
    long double hi = maxF + 1; // definitely not

    EPS = 0.000001 / x;
    while (hi - lo > EPS) {
        long double mid = (lo + hi) / 2;
        if (maxFlowDecisionProblem(mid)) {
            lo = mid;
        } else {
            hi = mid;
        }
    }

    cout << x * lo << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Edge {
	int j,C;
};

int n,s,t;
vector<Edge> el;
vvi al;

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}
int x;
ll maxflow() {
	ll Mf=0,f=1;
	while (f && Mf<x) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX);
		Mf+=f;
	}
	return Mf;
}

int oc[1000];

int main() {
	int m;
	scanf("%d%d%d",&n,&m,&x);
	s=0;t=n-1;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		oc[2*i]=c;
		oc[2*i+1]=0;
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
	}

	double l=0,u=1000000;
	//while (u-l>1e-9) {
	for (int c=0;c<60;c++) {
		double mid=(l+u)/2;
		for (int i=0;i<2*m;i+=2) el[i].C=oc[i]/mid;
		if (maxflow() >= x) l=mid;
		else u=mid;
	}

	cout << fixed << setprecision(10) << (l+u)/2 << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Edge {
	int j,C;
};

int n,s,t;
vector<Edge> el;
vvi al;

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}
int x;
ll maxflow() {
	ll Mf=0,f=1;
	while (f && Mf<x) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX);
		Mf+=f;
	}
	return Mf;
}

int oc[1000];

int main() {
	int m;
	scanf("%d%d%d",&n,&m,&x);
	s=0;t=n-1;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		oc[2*i]=c;
		oc[2*i+1]=0;
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
	}

	double l=0,u=1000000;
	double mid=(l+u)/2;
	//while (u-l>1e-9) {
	while ((mid-l)*x/max(1.0,l*x)>1e-7) {
	//for (int c=0;c<60;c++) {
		//double mid=(l+u)/2;
		for (int i=0;i<2*m;i+=2) el[i].C=oc[i]/mid;
		if (maxflow() >= x) l=mid;
		else u=mid;
		mid=(l+u)/2;
	}

	cout << fixed << setprecision(10) << mid*x << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Edge {
	int j,C;
};

int n,s,t;
vector<Edge> el;
vvi al;

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}
int x;
ll maxflow() {
	ll Mf=0,f=1;
	while (f && Mf<x) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX);
		Mf+=f;
	}
	return Mf;
}

int oc[1000];

int main() {
	int m;
	scanf("%d%d%d",&n,&m,&x);
	s=0;t=n-1;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		oc[2*i]=c;
		oc[2*i+1]=0;
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
	}

	double l=0,u=1000000;
	double mid=(l+u)/2;
	//while (u-l>1e-9) {
	while ((mid-l)/max(1.0,l)>1e6) {
	//for (int c=0;c<60;c++) {
		//double mid=(l+u)/2;
		for (int i=0;i<2*m;i+=2) el[i].C=oc[i]/mid;
		if (maxflow() >= x) l=mid;
		else u=mid;
		mid=(l+u)/2;
	}

	cout << fixed << setprecision(10) << (l+u)/2*x << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Edge {
	int j,C;
};

int n,s,t;
vector<Edge> el;
vvi al;

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}
int x;
ll maxflow() {
	ll Mf=0,f=1;
	while (f && Mf<x) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX);
		Mf+=f;
	}
	return Mf;
}

int oc[1000];

int main() {
	int m;
	scanf("%d%d%d",&n,&m,&x);
	s=0;t=n-1;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		oc[2*i]=c;
		oc[2*i+1]=0;
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
	}

	double l=0,u=1000000;
	double mid=(l+u)/2;
	//while (u-l>1e-9) {
	while ((mid-l)*x/max(1.0,l*x)>1e-6) {
	//for (int c=0;c<60;c++) {
		//double mid=(l+u)/2;
		for (int i=0;i<2*m;i+=2) el[i].C=oc[i]/mid;
		if (maxflow() >= x) l=mid;
		else u=mid;
		mid=(l+u)/2;
	}

	cout << fixed << setprecision(10) << mid*x << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Edge {
	int j,C;
};

int n,s,t;
vector<Edge> el;
vvi al;

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}
int x;
ll maxflow() {
	ll Mf=0,f=1;
	while (f && Mf<x) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX);
		Mf+=f;
	}
	return Mf;
}

int oc[1000];

int main() {
	int m;
	scanf("%d%d%d",&n,&m,&x);
	s=0;t=n-1;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		oc[2*i]=c;
		oc[2*i+1]=0;
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
	}

	double l=0,u=1000000;
	while (u-l>1e-10) {
		double mid=(l+u)/2;
		for (int i=0;i<2*m;i+=2) el[i].C=oc[i]/mid;
		if (maxflow() >= x) l=mid;
		else u=mid;
	}

	cout << fixed << setprecision(10) << l*x << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Edge {
	int j,C;
};

int n,s,t;
vector<Edge> el;
vvi al;

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}
int x;
ll maxflow() {
	ll Mf=0,f=1;
	while (f && Mf<x) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX);
		Mf+=f;
	}
	return Mf;
}

int oc[1000];

int main() {
	int m;
	scanf("%d%d%d",&n,&m,&x);
	s=0;t=n-1;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		oc[2*i]=c;
		oc[2*i+1]=0;
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
	}

	double l=0,u=5e10;
	double mid=(l+u)/2;
	//while (u-l>1e-9) {
	while ((mid-l)*x/max(1.0,l*x)>1e-7) {
	//for (int c=0;c<60;c++) {
		//double mid=(l+u)/2;
		for (int i=0;i<2*m;i+=2) el[i].C=oc[i]/mid;
		if (maxflow() >= x) l=mid;
		else u=mid;
		mid=(l+u)/2;
	}

	cout << fixed << setprecision(20) << mid*x << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Edge {
	int j,C;
};

int n,s,t;
vector<Edge> el;
vvi al;

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}
int x;
ll maxflow() {
	ll Mf=0,f=1;
	while (f && Mf<x) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX);
		Mf+=f;
	}
	return Mf;
}

int oc[1000];

int main() {
	int m;
	scanf("%d%d%d",&n,&m,&x);
	s=0;t=n-1;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		oc[2*i]=c;
		oc[2*i+1]=0;
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
	}

	double l=0,u=1000000;
	//while (u-l>1e-9) {
	for (int c=0;c<60;c++) {
		double mid=(l+u)/2;
		for (int i=0;i<2*m;i+=2) el[i].C=oc[i]/mid;
		if (maxflow() >= x) l=mid;
		else u=mid;
	}

	cout << fixed << setprecision(10) << l*x << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Edge {
	int j,C;
};

int n,s,t;
vector<Edge> el;
vvi al;

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}
int x;
ll maxflow() {
	ll Mf=0,f=1;
	while (f && Mf<x) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX);
		Mf+=f;
	}
	return Mf;
}

int oc[1000];

int main() {
	int m;
	scanf("%d%d%d",&n,&m,&x);
	s=0;t=n-1;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		oc[2*i]=c;
		oc[2*i+1]=0;
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
	}

	double l=0,u=5e10;
	double mid=(l+u)/2;
	//while (u-l>1e-9) {
	while ((mid-l)*x/max(1.0,l*x)>1e-7) {
	//for (int c=0;c<60;c++) {
		//double mid=(l+u)/2;
		for (int i=0;i<2*m;i+=2) el[i].C=min((double)INT_MAX,oc[i]/mid);
		if (maxflow() >= x) l=mid;
		else u=mid;
		mid=(l+u)/2;
	}

	cout << fixed << setprecision(20) << mid*x << endl;
}


// Create your own template by modifying this file!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
} dbg;

int n,m,x;
struct Edge {
	int i[2];
	int w[2];

	int o(int v) {return v==i[0]?i[1]:i[0];}
	int p(int v) {return v==i[0]?w[0]:w[1];}
	void rem(int v,int f) {
		int c=v==i[0]?0:1;
		w[c]-=f;
		w[!c]+=f;
	}
};
vvi al;
vvi aug;
vector<Edge> es;
vi wws;

vi vis;

int dfs(int i,int cf) {
	int f;
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==n-1) return cf;
	for (int c=0;c<aug[i].size();c++) {
		if (es[aug[i][c]].p(i)==0) continue;
		f=dfs(es[aug[i][c]].o(i),min(cf,es[aug[i][c]].p(i)));
		if (f) {
			es[aug[i][c]].rem(i,f);
			return f;
		}
	}

	return 0;
}

bool cando() {
	int mf=0;
	while (mf<x) {
		vis.assign(n,false);
		int cur = dfs(0,INT_MAX);
		if (cur==0) break;
		mf+=cur;
	}

	return mf>=x;
}

int main()
{
	cin >> n >> m >> x;
	//if (n!=4) return 0;
	int i,j,k;
	al.resize(n);wws.resize(m);aug.resize(n);
	es.resize(m);

	for (int c=0;c<m;c++) {
		scanf("%d%d%d",&i,&j,&k);i--;j--;
		al[i].push_back(j);
		aug[i].push_back(c);
		aug[j].push_back(c);
		es[c].i[0]=i;
		es[c].i[1]=j;
		wws[c]=k;

		//ws[i].push_back(k);
	}

	double l=0,u=5e10;
	for (int it=0;it<400;it++) {
		double mid=(l+u)/2;
		for (int c=0;c<m;c++) {
			es[c].w[0]=wws[c]/(mid/x);
			//cout << es[c].w[0] << endl;
			es[c].w[1]=0;
		}

		if (cando()) l=mid;
		else u=mid;
	}

	cout << fixed << setprecision(20) << l << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Edge {
	int j,C;
};

int n,s,t;
vector<Edge> el;
vvi al;

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}
int x;
ll maxflow() {
	ll Mf=0,f=1;
	while (f) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX);
		Mf+=f;
	}
	return Mf;
}

int oc[1000];

int main() {
	int m;
	scanf("%d%d%d",&n,&m,&x);
	s=0;t=n-1;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		oc[2*i]=c;
		oc[2*i+1]=0;
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
	}

	double l=0,u=5e10;
	double mid=(l+u)/2;
	//while (u-l>1e-9) {
	while ((mid-l)*x/max(1.0,l*x)>1e-7) {
	//for (int c=0;c<60;c++) {
		//double mid=(l+u)/2;
		for (int i=0;i<2*m;i+=2) el[i].C=min((double)INT_MAX,oc[i]/mid);
		if (maxflow() >= x) l=mid;
		else u=mid;
		mid=(l+u)/2;
	}

	cout << fixed << setprecision(20) << mid*x << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Edge {
	int j,C;
};

int n,s,t;
vector<Edge> el;
vvi al;

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}
int x;
ll maxflow() {
	ll Mf=0,f=1;
	while (f && Mf<x) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX);
		Mf+=f;
	}
	return Mf;
}

int oc[1000];

int main() {
	int m;
	scanf("%d%d%d",&n,&m,&x);
	s=0;t=n-1;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		oc[2*i]=c;
		oc[2*i+1]=0;
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
	}

	double l=0,u=1000000;
	//while (u-l>1e-9) {
	for (int c=0;c<60;c++) {
		double mid=(l+u)/2;
		for (int i=0;i<2*m;i+=2) el[i].C=oc[i]/mid;
		if (maxflow() >= x) l=mid;
		else u=mid;
	}

	cout << fixed << setprecision(10) << (l+u)/2*x << endl;
}


// Create your own template by modifying this file!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
} dbg;

int n,m,x;
struct Edge {
	int i[2];
	int w[2];

	int o(int v) {return v==i[0]?i[1]:i[0];}
	int p(int v) {return v==i[0]?w[0]:w[1];}
	void rem(int v,int f) {
		int c=v==i[0]?0:1;
		w[c]-=f;
		w[!c]+=f;
	}
};
vvi al;
vvi aug;
vector<Edge> es;
vi wws;

vi vis;

int dfs(int i,int cf) {
	int f;
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==n-1) return cf;
	for (int c=0;c<aug[i].size();c++) {
		if (es[aug[i][c]].p(i)==0) continue;
		f=dfs(es[aug[i][c]].o(i),min(cf,es[aug[i][c]].p(i)));
		if (f) {
			es[aug[i][c]].rem(i,f);
			return f;
		}
	}

	return 0;
}

bool cando() {
	int mf=0;
	while (mf<x) {
		vis.assign(n,false);
		int cur = dfs(0,INT_MAX);
		if (cur==0) break;
		mf+=cur;
	}

	return mf>=x;
}

int main()
{
	cin >> n >> m >> x;
	//if (n!=4) return 0;
	int i,j,k;
	al.resize(n);wws.resize(m);aug.resize(n);
	es.resize(m);

	for (int c=0;c<m;c++) {
		scanf("%d%d%d",&i,&j,&k);i--;j--;
		al[i].push_back(j);
		aug[i].push_back(c);
		aug[j].push_back(c);
		es[c].i[0]=i;
		es[c].i[1]=j;
		wws[c]=k;

		//ws[i].push_back(k);
	}

	long double l=0,u=5e10;
	for (int it=0;it<400;it++) {
		long double mid=(l+u)/2;
		for (int c=0;c<m;c++) {
			es[c].w[0]=wws[c]/(mid/x);
			//cout << es[c].w[0] << endl;
			es[c].w[1]=0;
		}

		if (cando()) l=mid;
		else u=mid;
	}

	cout << fixed << setprecision(20) << l << endl;
    return 0;
}


// Create your own template by modifying this file!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
} dbg;

int n,m,x;
struct Edge {
	int i[2];
	int w[2];

	int o(int v) {return v==i[0]?i[1]:i[0];}
	int p(int v) {return v==i[0]?w[0]:w[1];}
	void rem(int v,int f) {
		int c=v==i[0]?0:1;
		w[c]-=f;
		w[!c]+=f;
	}
};
vvi al;
vvi aug;
vector<Edge> es;
vi wws;

vi vis;

int dfs(int i,int cf) {
	int f;
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==n-1) return cf;
	for (int c=0;c<aug[i].size();c++) {
		if (es[aug[i][c]].p(i)==0) continue;
		f=dfs(es[aug[i][c]].o(i),min(cf,es[aug[i][c]].p(i)));
		if (f) {
			es[aug[i][c]].rem(i,f);
			return f;
		}
	}

	return 0;
}

bool cando() {
	int mf=0;
	while (mf<x) {
		vis.assign(n,false);
		int cur = dfs(0,INT_MAX);
		if (cur==0) break;
		mf+=cur;
	}

	return mf>=x;
}

int main()
{
	cin >> n >> m >> x;
	//if (n!=4) return 0;
	int i,j,k;
	al.resize(n);wws.resize(m);aug.resize(n);
	es.resize(m);

	for (int c=0;c<m;c++) {
		scanf("%d%d%d",&i,&j,&k);i--;j--;
		al[i].push_back(j);
		aug[i].push_back(c);
		aug[j].push_back(c);
		es[c].i[0]=i;
		es[c].i[1]=j;
		wws[c]=k;

		//ws[i].push_back(k);
	}

	double l=0,u=5e8;
	for (int it=0;it<200;it++) {
		double mid=(l+u)/2;
		for (int c=0;c<m;c++) {
			es[c].w[0]=wws[c]/(mid/x);
			//cout << es[c].w[0] << endl;
			es[c].w[1]=0;
		}

		if (cando()) l=mid;
		else u=mid;
	}

	cout << fixed << setprecision(20) << l << endl;
    return 0;
}


// Create your own template by modifying this file!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
} dbg;

int n,m,x;
struct Edge {
	int i[2];
	int w[2];

	int o(int v) {return v==i[0]?i[1]:i[0];}
	int p(int v) {return v==i[0]?w[0]:w[1];}
	void rem(int v,int f) {
		int c=v==i[0]?0:1;
		w[c]-=f;
		w[!c]+=f;
	}
};
vvi al;
vvi aug;
vector<Edge> es;
vi wws;

vi vis;

int dfs(int i,int cf) {
	int f;
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==n-1) return cf;
	for (int c=0;c<aug[i].size();c++) {
		if (es[aug[i][c]].p(i)==0) continue;
		f=dfs(es[aug[i][c]].o(i),min(cf,es[aug[i][c]].p(i)));
		if (f) {
			es[aug[i][c]].rem(i,f);
			return f;
		}
	}

	return 0;
}

bool cando() {
	int mf=0;
	while (mf<x) {
		vis.assign(n,false);
		int cur = dfs(0,INT_MAX);
		if (cur==0) break;
		mf+=cur;
	}

	return mf>=x;
}

int main()
{
	cin >> n >> m >> x;
	//if (n!=4) return 0;
	int i,j,k;
	al.resize(n);wws.resize(m);aug.resize(n);
	es.resize(m);

	for (int c=0;c<m;c++) {
		scanf("%d%d%d",&i,&j,&k);i--;j--;
		al[i].push_back(j);
		aug[i].push_back(c);
		aug[j].push_back(c);
		es[c].i[0]=i;
		es[c].i[1]=j;
		wws[c]=k;

		//ws[i].push_back(k);
	}

	long double l=0,u=5e10;
	for (int it=0;it<400;it++) {
		long double mid=(l+u)/2;
		for (int c=0;c<m;c++) {
			es[c].w[0]=min((long double) (INT_MAX),wws[c]/(mid/x));
			//cout << es[c].w[0] << endl;
			es[c].w[1]=0;
		}

		if (cando()) l=mid;
		else u=mid;
	}

	cout << fixed << setprecision(20) << l << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Edge {
	int j,C;
};

int n,s,t;
vector<Edge> el;
vvi al;

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}
int x;
ll maxflow() {
	ll Mf=0,f=1;
	while (f && Mf<x) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX);
		Mf+=f;
	}
	return Mf;
}

int oc[1000];

int main() {
	int m;
	scanf("%d%d%d",&n,&m,&x);
	s=0;t=n-1;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		oc[2*i]=c;
		oc[2*i+1]=0;
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
	}

	double l=0,u=1000000;
	while (u-l>1e-12) {
		double mid=(l+u)/2;
		for (int i=0;i<2*m;i+=2) el[i].C=oc[i]/mid;
		if (maxflow() >= x) l=mid;
		else u=mid;
	}

	cout << fixed << setprecision(10) << l*x << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

//see CF 653D
// Ford Fulkerson (DFS) Max Flow
//
// Author      : Peter Whalan
// Date        : September 1, 2016
// Reliability : 2
// Tested On   : CF:653/D, Tuesday Tutorial
//
// Computes the max flow of a graph using Ford Fulkerson's method, implemented
// with DFS.
//
// This code works if the value of a residual edge cannot exceed an int. For a
// directed graph, this is the case if each edge in the input fits in an int.
// For an undirected graph this is the case if 2 * (max undirected capacity)
// fits in an int.
//
// Remember that the residual graph has twice as many edges as the input graph.
//
// There will be an infinite loop if s == t.
//
// Complexity: O((V+E)F) where F is the max flow

// Represents an edge going from some vertex i, to vertex j, with capacity C.
struct Edge {
	int j,C; // Incoming vertex (ie. el[ al[i][c] ] != i), Capacity
};

// Your code must set the variables in this block. al and el are for the
// residual graph.
int n,s,t;// Number of vertices, Source, Sink
vector<Edge> el; // Edge list. Ensure pairs of edges are together (xor trick).
vvi al; // Adjacency list. Stores indices of outgoing edges in edge list.

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}

ll maxflow() {
	ll Mf=0,f=1;
	while (f) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX); // Change to LLONG_MAX if single flow can exceed it.
		Mf+=f;
	}
	return Mf;
}

int main() {
	int m;
	scanf("%d%d%d%d",&n,&m,&s,&t);
	s--;t--;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		if (u!=v) {al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
		}
	}

	cout << maxflow() << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Edge {
	int j,C;
};

int n,s,t;
vector<Edge> el;
vvi al;

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}
int x;
ll maxflow() {
	ll Mf=0,f=1;
	while (f && Mf<x) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX);
		Mf+=f;
	}
	return Mf;
}

int oc[1000];

int main() {
	int m;
	scanf("%d%d%d",&n,&m,&x);
	s=0;t=n-1;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		oc[2*i]=c;
		oc[2*i+1]=0;
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
	}

	double l=0,u=1000000;
	while (u-l>1e-9) {
		double mid=(l+u)/2;
		for (int i=0;i<2*m;i+=2) el[i].C=oc[i]/mid;
		if (maxflow() >= x) l=mid;
		else u=mid;
	}

	cout << fixed << setprecision(10) << l*x << endl;
}


// Create your own template by modifying this file!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

#ifdef DEBUG
     #define debug(args...)            {dbg,args; cerr<<endl;}
#else
    #define debug(args...)              // Just strip off all debug tokens
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {
        cerr<<v<<" ";
        return *this;
    }
} dbg;

int n,m,x;
struct Edge {
	int i[2];
	int w[2];

	int o(int v) {return v==i[0]?i[1]:i[0];}
	int p(int v) {return v==i[0]?w[0]:w[1];}
	void rem(int v,int f) {
		int c=v==i[0]?0:1;
		w[c]-=f;
		w[!c]+=f;
	}
};
vvi al;
vvi aug;
vector<Edge> es;
vi wws;

vi vis;

int dfs(int i,int cf) {
	int f;
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==n-1) return cf;
	for (int c=0;c<aug[i].size();c++) {
		if (es[aug[i][c]].p(i)==0) continue;
		f=dfs(es[aug[i][c]].o(i),min(cf,es[aug[i][c]].p(i)));
		if (f) {
			es[aug[i][c]].rem(i,f);
			return f;
		}
	}

	return 0;
}

bool cando() {
	int mf=0;
	while (mf<x) {
		vis.assign(n,false);
		int cur = dfs(0,INT_MAX);
		if (cur==0) break;
		mf+=cur;
	}

	return mf>=x;
}

int main()
{
	cin >> n >> m >> x;
	//if (n!=4) return 0;
	int i,j,k;
	al.resize(n);wws.resize(m);aug.resize(n);
	es.resize(m);

	for (int c=0;c<m;c++) {
		scanf("%d%d%d",&i,&j,&k);i--;j--;
		al[i].push_back(j);
		aug[i].push_back(c);
		aug[j].push_back(c);
		es[c].i[0]=i;
		es[c].i[1]=j;
		wws[c]=k;

		//ws[i].push_back(k);
	}

	long double l=0,u=5e10;
	for (int it=0;it<400;it++) {
		long double mid=(l+u)/2;
		for (int c=0;c<m;c++) {
			es[c].w[0]=min(long double (INT_MAX),wws[c]/(mid/x));
			//cout << es[c].w[0] << endl;
			es[c].w[1]=0;
		}

		if (cando()) l=mid;
		else u=mid;
	}

	cout << fixed << setprecision(20) << l << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

struct Edge {
	int j,C;
};

int n,s,t;
vector<Edge> el;
vvi al;

vector<bool> vis;

int dfs(int i,int cf) {
	if (vis[i]) return 0;
	vis[i]=1;
	if (i==t) return cf;
	for (int c:al[i]) {
		int ncf = min(cf,el[c].C),f;
		if (ncf && (f=dfs(el[c].j,ncf))) {
			el[c].C-=f;
			el[c^1].C+=f;
			return f;
		}
	}

	return 0;
}
int x;
ll maxflow() {
	ll Mf=0,f=1;
	while (f && Mf<x) {
		vis.assign(n,0);
		f=dfs(s,INT_MAX);
		Mf+=f;
	}
	return Mf;
}

int oc[1000];

int main() {
	int m;
	scanf("%d%d%d",&n,&m,&x);
	s=0;t=n-1;
	al.assign(n,{});
	el.resize(2*m);
	for(int i=0;i<m;i++){
		int u,v,c;
		scanf("%d%d%d",&u,&v,&c);
		u--;v--;
		al[u].push_back(2*i);
		al[v].push_back(2*i+1);
		oc[2*i]=c;
		oc[2*i+1]=0;
		el[2*i]={v,c};
		el[2*i+1]={u,0};//change 0 to c for undirected egde
	}

	double l=0,u=1000000;
	double mid=(l+u)/2;
	//while (u-l>1e-9) {
	while ((mid-l)/max(1,l)>1e6) {
	//for (int c=0;c<60;c++) {
		//double mid=(l+u)/2;
		for (int i=0;i<2*m;i+=2) el[i].C=oc[i]/mid;
		if (maxflow() >= x) l=mid;
		else u=mid;
		mid=(l+u)/2;
	}

	cout << fixed << setprecision(10) << (l+u)/2*x << endl;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<bitset>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define LL long long
#define fi first
#define se second
using namespace std;

int getint()
{
    char c;
    for (c=getchar();c<'0' || c>'9';c=getchar());
    int t=c-48;
    for (c=getchar();c>='0' && c<='9';c=getchar())
        t=t*10+c-48;
    return t;
}

void putint(int n)
{
     char a[9];
     int size=0;
     if (n==0)
        putchar('0');
     while (n)
     {
           a[size++]=n%10+48;
           n/=10;
     }
     for (int i=size-1;i>=0;i--)
         putchar(a[i]);
     putchar('\n');
}
const int oo=1000000000;
struct edge{
	int nxt,cap,too;
}e[2000];
int n,m,be,x[1000],y[1000],z[1000],nedge,d[500],q[500],hed[500];
double l,r,o,eps=1e-10;

inline void ae(int x,int y,int z){
	e[++nedge].nxt=hed[x];
	hed[x]=nedge;
	e[nedge].too=y;
	e[nedge].cap=z;
}

bool build(){
	int x,y,l=1,r=1;
	memset(d,-1,sizeof(d));
	q[1]=1;
	d[1]=0;
	while (l<=r){
		x=q[l];
		for (int i=hed[x];i;i=e[i].nxt){
			y=e[i].too;
			if (e[i].cap && d[y]==-1){
				d[y]=d[x]+1;
				r++;
				q[r]=y;
				if (y==n)
					return 1;
			}
		}
		l++;
	}
	return 0;
}
int find(int now,int flow){
	int ret,y,w=0;
	if (now==n)return flow;
	for (int i=hed[now];i && w<flow;i=e[i].nxt){
		y=e[i].too;
		if (e[i].cap&&d[y]==d[now]+1&&(ret=find(y,min(flow-w,e[i].cap))))
			e[i].cap-=ret,e[i^1].cap+=ret,w+=ret;
	}
	if (!w)d[now]=-1;
	return w;
}
int dinic(){
	int ans=0;
	while (build())
		while (1){
			int flow=find(1,oo);
			if (!flow) break;
			ans+=flow;
		}
	return ans;
}

int main()
{
	scanf("%d%d%d",&n,&m,&be);
	for (int i=1;i<=m;i++)
		scanf("%d%d%d",&x[i],&y[i],&z[i]);
	l=0.0;
	r=1.5;
	for (int p=0;p<200;p++)
	{
		o=(l+r)/2;
		nedge=0;
		for (int i=1;i<=n;i++)
			hed[i]=0;
		for (int i=1;i<=m;i++)
		{
			ae(x[i],y[i],int(z[i]/o));
			ae(y[i],x[i],0);
		}
		if (dinic()>=be)
			l=o;
		else
			r=o;
	}
	printf("%.10f\n",r*be);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<bitset>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define LL long long
#define fi first
#define se second
using namespace std;

int getint()
{
    char c;
    for (c=getchar();c<'0' || c>'9';c=getchar());
    int t=c-48;
    for (c=getchar();c>='0' && c<='9';c=getchar())
        t=t*10+c-48;
    return t;
}

void putint(int n)
{
     char a[9];
     int size=0;
     if (n==0)
        putchar('0');
     while (n)
     {
           a[size++]=n%10+48;
           n/=10;
     }
     for (int i=size-1;i>=0;i--)
         putchar(a[i]);
     putchar('\n');
}
const int oo=1000000000;
struct edge{
	int nxt,cap,too;
}e[2000];
int n,m,be,x[1000],y[1000],z[1000],nedge,d[500],q[500],hed[500];
long double l,r,o,eps=1e-10;

inline void ae(int x,int y,int z){
	e[++nedge].nxt=hed[x];
	hed[x]=nedge;
	e[nedge].too=y;
	e[nedge].cap=z;
}

bool build(){
	int x,y,l=1,r=1;
	memset(d,-1,sizeof(d));
	q[1]=1;
	d[1]=0;
	while (l<=r){
		x=q[l];
		for (int i=hed[x];i;i=e[i].nxt){
			y=e[i].too;
			if (e[i].cap && d[y]==-1){
				d[y]=d[x]+1;
				r++;
				q[r]=y;
				if (y==n)
					return 1;
			}
		}
		l++;
	}
	return 0;
}
int find(int now,int flow){
	int ret,y,w=0;
	if (now==n)return flow;
	for (int i=hed[now];i && w<flow;i=e[i].nxt){
		y=e[i].too;
		if (e[i].cap&&d[y]==d[now]+1&&(ret=find(y,min(flow-w,e[i].cap))))
			e[i].cap-=ret,e[i^1].cap+=ret,w+=ret;
	}
	if (!w)d[now]=-1;
	return w;
}
int dinic(){
	int ans=0;
	while (build())
		while (1){
			int flow=find(1,oo);
			if (!flow) break;
			ans+=flow;
		}
	return ans;
}

int main()
{
	scanf("%d%d%d",&n,&m,&be);
	for (int i=1;i<=m;i++)
		scanf("%d%d%d",&x[i],&y[i],&z[i]);
	l=0.0;
	r=1.5;
	for (int p=0;p<200;p++)
	{
		o=(l+r)/2;
		nedge=0;
		for (int i=1;i<=n;i++)
			hed[i]=0;
		for (int i=1;i<=m;i++)
		{
			ae(x[i],y[i],int(z[i]/o));
			ae(y[i],x[i],0);
		}
		if (dinic()>=be)
			l=o;
		else
			r=o;
	}
	cout<<setprecision(10)<<r*be<<endl;
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<bitset>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define LL long long
#define fi first
#define se second
using namespace std;

int getint()
{
    char c;
    for (c=getchar();c<'0' || c>'9';c=getchar());
    int t=c-48;
    for (c=getchar();c>='0' && c<='9';c=getchar())
        t=t*10+c-48;
    return t;
}

void putint(int n)
{
     char a[9];
     int size=0;
     if (n==0)
        putchar('0');
     while (n)
     {
           a[size++]=n%10+48;
           n/=10;
     }
     for (int i=size-1;i>=0;i--)
         putchar(a[i]);
     putchar('\n');
}
const int oo=1000000000;
struct edge{
	int nxt,cap,too;
}e[2000];
int n,m,be,x[1000],y[1000],z[1000],nedge,d[500],q[500],hed[500];
double l,r,o,eps=1e-10;

inline void ae(int x,int y,int z){
	e[++nedge].nxt=hed[x];
	hed[x]=nedge;
	e[nedge].too=y;
	e[nedge].cap=z;
}

bool build(){
	int x,y,l=1,r=1;
	memset(d,-1,sizeof(d));
	q[1]=1;
	d[1]=0;
	while (l<=r){
		x=q[l];
		for (int i=hed[x];i;i=e[i].nxt){
			y=e[i].too;
			if (e[i].cap && d[y]==-1){
				d[y]=d[x]+1;
				r++;
				q[r]=y;
				if (y==n)
					return 1;
			}
		}
		l++;
	}
	return 0;
}
int find(int now,int flow){
	int ret,y,w=0;
	if (now==n)return flow;
	for (int i=hed[now];i && w<flow;i=e[i].nxt){
		y=e[i].too;
		if (e[i].cap&&d[y]==d[now]+1&&(ret=find(y,min(flow-w,e[i].cap))))
			e[i].cap-=ret,e[i^1].cap+=ret,w+=ret;
	}
	if (!w)d[now]=-1;
	return w;
}
int dinic(){
	int ans=0;
	while (build())
		while (1){
			int flow=find(1,oo);
			if (!flow) break;
			ans+=flow;
		}
	return ans;
}

int main()
{
	scanf("%d%d%d",&n,&m,&be);
	for (int i=1;i<=m;i++)
		scanf("%d%d%d",&x[i],&y[i],&z[i]);
	l=0.0;
	r=1000000000.0;
	for (int p=0;p<200;p++)
	{
		o=(l+r)/2;
		nedge=0;
		for (int i=1;i<=n;i++)
			hed[i]=0;
		for (int i=1;i<=m;i++)
		{
			ae(x[i],y[i],int(z[i]/o));
			ae(y[i],x[i],0);
		}
		if (dinic()>=be)
			l=o;
		else
			r=o;
	}
	printf("%.10f\n",r*be);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<bitset>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define LL long long
#define fi first
#define se second
using namespace std;

int getint()
{
    char c;
    for (c=getchar();c<'0' || c>'9';c=getchar());
    int t=c-48;
    for (c=getchar();c>='0' && c<='9';c=getchar())
        t=t*10+c-48;
    return t;
}

void putint(int n)
{
     char a[9];
     int size=0;
     if (n==0)
        putchar('0');
     while (n)
     {
           a[size++]=n%10+48;
           n/=10;
     }
     for (int i=size-1;i>=0;i--)
         putchar(a[i]);
     putchar('\n');
}
const int oo=1000000000;
struct edge{
	int nxt,cap,too;
}e[2000];
int n,m,be,x[1000],y[1000],z[1000],nedge,d[500],q[500],hed[500];
double l,r,o,eps=1e-10;

inline void ae(int x,int y,int z){
	e[++nedge].nxt=hed[x];
	hed[x]=nedge;
	e[nedge].too=y;
	e[nedge].cap=z;
}

bool build(){
	int x,y,l=1,r=1;
	memset(d,-1,sizeof(d));
	q[1]=1;
	d[1]=0;
	while (l<=r){
		x=q[l];
		for (int i=hed[x];i;i=e[i].nxt){
			y=e[i].too;
			if (e[i].cap && d[y]==-1){
				d[y]=d[x]+1;
				r++;
				q[r]=y;
				if (y==n)
					return 1;
			}
		}
		l++;
	}
	return 0;
}
int find(int now,int flow){
	int ret,y,w=0;
	if (now==n)return flow;
	for (int i=hed[now];i && w<flow;i=e[i].nxt){
		y=e[i].too;
		if (e[i].cap&&d[y]==d[now]+1&&(ret=find(y,min(flow-w,e[i].cap))))
			e[i].cap-=ret,e[i^1].cap+=ret,w+=ret;
	}
	if (!w)d[now]=-1;
	return w;
}
int dinic(){
	int ans=0;
	while (build())
		while (1){
			int flow=find(1,be);
			if (!flow) break;
			ans+=flow;
		}
	return ans;
}

int main()
{
	scanf("%d%d%d",&n,&m,&be);
	for (int i=1;i<=m;i++)
		scanf("%d%d%d",&x[i],&y[i],&z[i]);
	l=0.0;
	r=1000000000.0;
	for (int p=0;p<200;p++)
	{
		o=(l+r)/2;
		nedge=1;
		for (int i=1;i<=n;i++)
			hed[i]=0;
		for (int i=1;i<=m;i++)
		{
			ae(x[i],y[i],int(z[i]/o));
			ae(y[i],x[i],0);
		}
		if (dinic()>=be)
			l=o;
		else
			r=o;
	}
	printf("%.10f\n",r*be);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<bitset>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define LL long long
#define fi first
#define se second
using namespace std;

int getint()
{
    char c;
    for (c=getchar();c<'0' || c>'9';c=getchar());
    int t=c-48;
    for (c=getchar();c>='0' && c<='9';c=getchar())
        t=t*10+c-48;
    return t;
}

void putint(int n)
{
     char a[9];
     int size=0;
     if (n==0)
        putchar('0');
     while (n)
     {
           a[size++]=n%10+48;
           n/=10;
     }
     for (int i=size-1;i>=0;i--)
         putchar(a[i]);
     putchar('\n');
}
const int oo=1000000000;
struct edge{
	int nxt,cap,too;
}e[2000];
int n,m,be,x[1000],y[1000],z[1000],nedge,d[500],q[500],hed[500];
double l,r,o,eps=1e-10;

inline void ae(int x,int y,int z){
	e[++nedge].nxt=hed[x];
	hed[x]=nedge;
	e[nedge].too=y;
	e[nedge].cap=z;
}

bool build(){
	int x,y,l=1,r=1;
	memset(d,-1,sizeof(d));
	q[1]=1;
	d[1]=0;
	while (l<=r){
		x=q[l];
		for (int i=hed[x];i;i=e[i].nxt){
			y=e[i].too;
			if (e[i].cap && d[y]==-1){
				d[y]=d[x]+1;
				r++;
				q[r]=y;
				if (y==n)
					return 1;
			}
		}
		l++;
	}
	return 0;
}
int find(int now,int flow){
	int ret,y,w=0;
	if (now==n)return flow;
	for (int i=hed[now];i && w<flow;i=e[i].nxt){
		y=e[i].too;
		if (e[i].cap&&d[y]==d[now]+1&&(ret=find(y,min(flow-w,e[i].cap))))
			e[i].cap-=ret,e[i^1].cap+=ret,w+=ret;
	}
	if (!w)d[now]=-1;
	return w;
}
int dinic(){
	int ans=0;
	while (build())
		while (1){
			int flow=find(1,oo);
			if (!flow) break;
			ans+=flow;
		}
	return ans;
}

int main()
{
	scanf("%d%d%d",&n,&m,&be);
	for (int i=1;i<=m;i++)
		scanf("%d%d%d",&x[i],&y[i],&z[i]);
	l=0.0;
	r=1000000000.0;
	for (int p=0;p<200;p++)
	{
		o=(l+r)/2;
		nedge=1;
		for (int i=1;i<=n;i++)
			hed[i]=0;
		for (int i=1;i<=m;i++)
		{
			ae(x[i],y[i],int(z[i]/o));
			ae(y[i],x[i],0);
		}
		if (dinic()>=be)
			l=o;
		else
			r=o;
	}
	printf("%.10f\n",r*be);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<bitset>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define LL long long
#define fi first
#define se second
using namespace std;

int getint()
{
    char c;
    for (c=getchar();c<'0' || c>'9';c=getchar());
    int t=c-48;
    for (c=getchar();c>='0' && c<='9';c=getchar())
        t=t*10+c-48;
    return t;
}

void putint(int n)
{
     char a[9];
     int size=0;
     if (n==0)
        putchar('0');
     while (n)
     {
           a[size++]=n%10+48;
           n/=10;
     }
     for (int i=size-1;i>=0;i--)
         putchar(a[i]);
     putchar('\n');
}
const int oo=1000000000;
struct edge{
	int nxt,cap,too;
}e[2000];
int n,m,be,x[1000],y[1000],z[1000],nedge,d[500],q[500],hed[500];
long double l,r,o,eps=1e-10;

inline void ae(int x,int y,int z){
	e[++nedge].nxt=hed[x];
	hed[x]=nedge;
	e[nedge].too=y;
	e[nedge].cap=z;
}

bool build(){
	int x,y,l=1,r=1;
	memset(d,-1,sizeof(d));
	q[1]=1;
	d[1]=0;
	while (l<=r){
		x=q[l];
		for (int i=hed[x];i;i=e[i].nxt){
			y=e[i].too;
			if (e[i].cap && d[y]==-1){
				d[y]=d[x]+1;
				r++;
				q[r]=y;
				if (y==n)
					return 1;
			}
		}
		l++;
	}
	return 0;
}
int find(int now,int flow){
	int ret,y,w=0;
	if (now==n)return flow;
	for (int i=hed[now];i && w<flow;i=e[i].nxt){
		y=e[i].too;
		if (e[i].cap&&d[y]==d[now]+1&&(ret=find(y,min(flow-w,e[i].cap))))
			e[i].cap-=ret,e[i^1].cap+=ret,w+=ret;
	}
	if (!w)d[now]=-1;
	return w;
}
int dinic(){
	int ans=0;
	while (build())
		while (1){
			int flow=find(1,oo);
			if (!flow) break;
			ans+=flow;
		}
	return ans;
}

int main()
{
	scanf("%d%d%d",&n,&m,&be);
	for (int i=1;i<=m;i++)
		scanf("%d%d%d",&x[i],&y[i],&z[i]);
	l=0.0;
	r=1.5;
	for (int p=0;p<200;p++)
	{
		o=(l+r)/2;
		nedge=0;
		for (int i=1;i<=n;i++)
			hed[i]=0;
		for (int i=1;i<=m;i++)
		{
			ae(x[i],y[i],int(z[i]/o));
			ae(y[i],x[i],0);
		}
		if (dinic()>=be)
			l=o;
		else
			r=o;
	}
	cout<<r*m<<endl;
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<bitset>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define LL long long
#define fi first
#define se second
using namespace std;

int getint()
{
    char c;
    for (c=getchar();c<'0' || c>'9';c=getchar());
    int t=c-48;
    for (c=getchar();c>='0' && c<='9';c=getchar())
        t=t*10+c-48;
    return t;
}

void putint(int n)
{
     char a[9];
     int size=0;
     if (n==0)
        putchar('0');
     while (n)
     {
           a[size++]=n%10+48;
           n/=10;
     }
     for (int i=size-1;i>=0;i--)
         putchar(a[i]);
     putchar('\n');
}
const int oo=1000000000;
struct edge{
	int nxt,cap,too;
}e[2000];
int n,m,be,x[1000],y[1000],z[1000],nedge,d[500],q[500],hed[500];
double l,r,o,eps=1e-10;

inline void ae(int x,int y,int z){
	e[++nedge].nxt=hed[x];
	hed[x]=nedge;
	e[nedge].too=y;
	e[nedge].cap=z;
}

bool build(){
	int x,y,l=1,r=1;
	memset(d,-1,sizeof(d));
	q[1]=1;
	d[1]=0;
	while (l<=r){
		x=q[l];
		for (int i=hed[x];i;i=e[i].nxt){
			y=e[i].too;
			if (e[i].cap && d[y]==-1){
				d[y]=d[x]+1;
				r++;
				q[r]=y;
				if (y==n)
					return 1;
			}
		}
		l++;
	}
	return 0;
}
int find(int now,int flow){
	int ret,y,w=0;
	if (now==n)return flow;
	for (int i=hed[now];i && w<flow;i=e[i].nxt){
		y=e[i].too;
		if (e[i].cap&&d[y]==d[now]+1&&(ret=find(y,min(flow-w,e[i].cap))))
			e[i].cap-=ret,e[i^1].cap+=ret,w+=ret;
	}
	if (!w)d[now]=-1;
	return w;
}
int dinic(){
	int ans=0;
	while (build())
		while (1){
			int flow=find(1,oo);
			if (!flow) break;
			ans+=flow;
		}
	return ans;
}

int main()
{
	scanf("%d%d%d",&n,&m,&be);
	for (int i=1;i<=m;i++)
		scanf("%d%d%d",&x[i],&y[i],&z[i]);
	l=0.0;
	r=1000000000.0;
	for (int p=0;p<200;p++)
	{
		o=(l+r)/2;
		nedge=1;
		for (int i=1;i<=n;i++)
			hed[i]=0;
		for (int i=1;i<=m;i++)
		{
			ae(x[i],y[i],(int)min((double)z[i]/o,(double)be));
			ae(y[i],x[i],0);
		}
		if (dinic()>=be)
			l=o;
		else
			r=o;
	}
	printf("%.10f\n",r*be);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<bitset>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define LL long long
#define fi first
#define se second
using namespace std;

int getint()
{
    char c;
    for (c=getchar();c<'0' || c>'9';c=getchar());
    int t=c-48;
    for (c=getchar();c>='0' && c<='9';c=getchar())
        t=t*10+c-48;
    return t;
}

void putint(int n)
{
     char a[9];
     int size=0;
     if (n==0)
        putchar('0');
     while (n)
     {
           a[size++]=n%10+48;
           n/=10;
     }
     for (int i=size-1;i>=0;i--)
         putchar(a[i]);
     putchar('\n');
}
const int oo=1000000000;
struct edge{
	int nxt,cap,too;
}e[2000];
int n,m,be,x[1000],y[1000],z[1000],nedge,d[500],q[500],hed[500];
long double l,r,o,eps=1e-10;

inline void ae(int x,int y,int z){
	e[++nedge].nxt=hed[x];
	hed[x]=nedge;
	e[nedge].too=y;
	e[nedge].cap=z;
}

bool build(){
	int x,y,l=1,r=1;
	memset(d,-1,sizeof(d));
	q[1]=1;
	d[1]=0;
	while (l<=r){
		x=q[l];
		for (int i=hed[x];i;i=e[i].nxt){
			y=e[i].too;
			if (e[i].cap && d[y]==-1){
				d[y]=d[x]+1;
				r++;
				q[r]=y;
				if (y==n)
					return 1;
			}
		}
		l++;
	}
	return 0;
}
int find(int now,int flow){
	int ret,y,w=0;
	if (now==n)return flow;
	for (int i=hed[now];i && w<flow;i=e[i].nxt){
		y=e[i].too;
		if (e[i].cap&&d[y]==d[now]+1&&(ret=find(y,min(flow-w,e[i].cap))))
			e[i].cap-=ret,e[i^1].cap+=ret,w+=ret;
	}
	if (!w)d[now]=-1;
	return w;
}
int dinic(){
	int ans=0;
	while (build())
		while (1){
			int flow=find(1,oo);
			if (!flow) break;
			ans+=flow;
		}
	return ans;
}

int main()
{
	scanf("%d%d%d",&n,&m,&be);
	for (int i=1;i<=m;i++)
		scanf("%d%d%d",&x[i],&y[i],&z[i]);
	l=0.0;
	r=1.5;
	for (int p=0;p<200;p++)
	{
		o=(l+r)/2;
		nedge=0;
		for (int i=1;i<=n;i++)
			hed[i]=0;
		for (int i=1;i<=m;i++)
		{
			ae(x[i],y[i],int(z[i]/o));
			ae(y[i],x[i],0);
		}
		if (dinic()>=be)
			l=o;
		else
			r=o;
	}
	cout<<r*be<<endl;
	return 0;
}


#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>
#include<bitset>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define LL long long
#define fi first
#define se second
using namespace std;

int getint()
{
    char c;
    for (c=getchar();c<'0' || c>'9';c=getchar());
    int t=c-48;
    for (c=getchar();c>='0' && c<='9';c=getchar())
        t=t*10+c-48;
    return t;
}

void putint(int n)
{
     char a[9];
     int size=0;
     if (n==0)
        putchar('0');
     while (n)
     {
           a[size++]=n%10+48;
           n/=10;
     }
     for (int i=size-1;i>=0;i--)
         putchar(a[i]);
     putchar('\n');
}
const int oo=1000000000;
struct edge{
	int nxt,cap,too;
}e[2000];
int n,m,be,x[1000],y[1000],z[1000],nedge,d[500],q[500],hed[500];
double l,r,o,eps=1e-10;

inline void ae(int x,int y,int z){
	e[++nedge].nxt=hed[x];
	hed[x]=nedge;
	e[nedge].too=y;
	e[nedge].cap=z;
}

bool build(){
	int x,y,l=1,r=1;
	memset(d,-1,sizeof(d));
	q[1]=1;
	d[1]=0;
	while (l<=r){
		x=q[l];
		for (int i=hed[x];i;i=e[i].nxt){
			y=e[i].too;
			if (e[i].cap && d[y]==-1){
				d[y]=d[x]+1;
				r++;
				q[r]=y;
				if (y==n)
					return 1;
			}
		}
		l++;
	}
	return 0;
}
int find(int now,int flow){
	int ret,y,w=0;
	if (now==n)return flow;
	for (int i=hed[now];i && w<flow;i=e[i].nxt){
		y=e[i].too;
		if (e[i].cap&&d[y]==d[now]+1&&(ret=find(y,min(flow-w,e[i].cap))))
			e[i].cap-=ret,e[i^1].cap+=ret,w+=ret;
	}
	if (!w)d[now]=-1;
	return w;
}
int dinic(){
	int ans=0;
	while (build())
		while (1){
			int flow=find(1,oo);
			if (!flow) break;
			ans+=flow;
		}
	return ans;
}

int main()
{
	scanf("%d%d%d",&n,&m,&be);
	for (int i=1;i<=m;i++)
		scanf("%d%d%d",&x[i],&y[i],&z[i]);
	l=0.0;
	r=1.5;
	for (int p=0;p<200;p++)
	{
		o=(l+r)/2;
		nedge=0;
		for (int i=1;i<=n;i++)
			hed[i]=0;
		for (int i=1;i<=m;i++)
		{
			ae(x[i],y[i],int(z[i]/o));
			ae(y[i],x[i],0);
		}
		if (dinic()>=be)
			l=o;
		else
			r=o;
	}
	printf("%.10f\n",r);
	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <ctime>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <iomanip>
#include <fstream>
using namespace std;
#define fname ""
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define inf 1000000000

const int N = 550;
struct edge {
    ll from, to, cap, flow;
};
vector <edge> allEdges;
vector <int> edges[N];
ll n;

void add(int x, int y, ll z) {
    edge e1 = {x, y, z, 0}, e2 = {y, x, 0, 0};
    edges[x].push_back((int)allEdges.size());
    allEdges.push_back(e1);
    edges[y].push_back((int)allEdges.size());
    allEdges.push_back(e2);
}

ll nxt[N], block[N];

queue <ll> q;

bool bfs() {
    memset(block, 0, sizeof block);
    block[0] = 1;
    q.push(0);
    while (!q.empty()) {
        ll v = q.front();
        q.pop();
        for (ll i = 0; i < (int)edges[v].size(); ++i) {
            ll id = edges[v][i];
            if (!block[allEdges[id].to] && allEdges[id].cap > allEdges[id].flow) {
                block[allEdges[id].to] = block[v] + 1;
                q.push(allEdges[id].to);
            }
        }
    }
    return (block[n - 1] > 0);
}

ll dfs(ll v, ll mn = inf) {
    if (!mn || v == n - 1) {
        return mn;
    }
    for (; nxt[v] < (int)edges[v].size(); ++nxt[v]) {
        ll id = edges[v][nxt[v]];
        if (block[v] + 1 == block[allEdges[id].to] &&
            allEdges[id].cap - allEdges[id].flow > 0) {
            ll Min = min(mn + 0ll, allEdges[id].cap - allEdges[id].flow);
            ll cur = dfs(allEdges[id].to, Min);
            if (cur != 0) {
                allEdges[id].flow += cur;
                allEdges[id ^ 1].flow -= cur;
                return cur;
            }
        }
    }
    return 0;
}

long long MaxFlow() {
    long long flow = 0;
    while (bfs()) {
//	   cout << "asd";
       memset(nxt, 0, sizeof nxt);
       while (ll pushed = dfs(0)) flow += pushed;
    }
    return flow;
}

int xx[777], yy[777], zz[777], m, k;

inline bool ok(double weight) {

//	for (int i = 0; i <= n; ++ i) edges[i].clear();
//	allEdges.clear();

	for (int i = 1; i <= m; ++ i) {
		ll ss = (double)zz[i] / weight;
		ss = min(ss, inf + 0ll);
//		cout << xx[i] << " " << yy[i] << " " << ss << endl;
		add(xx[i] - 1, yy[i] - 1, ss);
	}

//	cout << "bfs: " << bfs();
//	exit(0);

	long long curr = MaxFlow();

//	cout << curr << endl;

	return (curr >= k);
}

int main()
{
 	#ifndef ONLINE_JUDGE
    freopen(fname"in", "r", stdin);
    freopen(fname"out", "w", stdout);
	#endif

	cin >> n >> m >> k;

	for (int i = 1; i <= m; ++ i) {
		cin >> xx[i] >> yy[i] >> zz[i];
	}

	double l = 0, r = inf;

	for (int it = 0; it < 100; ++ it) {
		double mid = (l + r) / 2.0;
		if (ok(mid)) l = mid;
		else r = mid;
	}

	l *= k;
	printf("%.10f", l);

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <ctime>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <iomanip>
#include <fstream>
using namespace std;
#define fname ""
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define inf 1000000000

const int N = 550;
struct edge {
    ll from, to, cap, flow;
};
vector <edge> allEdges;
vector <int> edges[N];
int n;

void add(int x, int y, ll z) {
    edge e1 = {x, y, z, 0}, e2 = {y, x, 0, 0};
    edges[x].push_back((int)allEdges.size());
    allEdges.push_back(e1);
    edges[y].push_back((int)allEdges.size());
    allEdges.push_back(e2);
}

int nxt[N], block[N];

queue <int> q;

bool bfs() {
    memset(block, 0, sizeof block);
    block[0] = 1;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int i = 0; i < (int)edges[v].size(); ++i) {
            int id = edges[v][i];
            if (!block[allEdges[id].to] && allEdges[id].cap > allEdges[id].flow) {
                block[allEdges[id].to] = block[v] + 1;
                q.push(allEdges[id].to);
            }
        }
    }
    return (block[n - 1] > 0);
}

ll dfs(int v, int mn = inf) {
    if (!mn || v == n - 1) {
        return mn;
    }
    for (; nxt[v] < (int)edges[v].size(); ++nxt[v]) {
        int id = edges[v][nxt[v]];
        if (block[v] + 1 == block[allEdges[id].to] &&
            allEdges[id].cap - allEdges[id].flow > 0) {
            ll Min = min(mn + 0ll, allEdges[id].cap - allEdges[id].flow);
            ll cur = dfs(allEdges[id].to, Min);
            if (cur != 0) {
                allEdges[id].flow += cur;
                allEdges[id ^ 1].flow -= cur;
                return cur;
            }
        }
    }
    return 0;
}

long long MaxFlow() {
    long long flow = 0;
    while (bfs()) {
//	   cout << "asd";
       memset(nxt, 0, sizeof nxt);
       while (int pushed = dfs(0)) flow += pushed;
    }
    return flow;
}

int xx[777], yy[777], zz[777], m, k;

inline bool ok(double weight) {

//	for (int i = 0; i <= n; ++ i) edges[i].clear();
//	allEdges.clear();

	for (int i = 1; i <= m; ++ i) {
		ll ss = (double)zz[i] / weight;
		ss = min(ss, inf + 0ll);
//		cout << xx[i] << " " << yy[i] << " " << ss << endl;
		add(xx[i] - 1, yy[i] - 1, ss);
	}

//	cout << "bfs: " << bfs();
//	exit(0);

	long long curr = MaxFlow();

//	cout << curr << endl;

	return (curr >= k);
}

int main()
{
 	#ifndef ONLINE_JUDGE
    freopen(fname"in", "r", stdin);
    freopen(fname"out", "w", stdout);
	#endif

	scanf("%d%d%d", &n, &m, &k);

	for (int i = 1; i <= m; ++ i) {
		scanf("%d%d%d", &xx[i], &yy[i], &zz[i]);
	}

	double l = 0, r = inf;

	for (int it = 0; it < 100; ++ it) {
		double mid = (l + r) / 2.0;
		if (ok(mid)) l = mid;
		else r = mid;
	}

	l *= k;
	printf("%.10f", l);

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <ctime>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <iomanip>
#include <fstream>
using namespace std;
#define fname ""
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define inf 1000000

const int N = 550;
struct edge {
    ll from, to, cap, flow;
};
vector <edge> allEdges;
vector <ll> edges[N];
ll n;

void add(ll x, ll y, ll z) {
    edge e1 = {x, y, z, 0}, e2 = {y, x, 0, 0};
    edges[x].push_back((int)allEdges.size());
    allEdges.push_back(e1);
    edges[y].push_back((int)allEdges.size());
    allEdges.push_back(e2);
}

ll nxt[N], block[N];

queue <ll> q;

bool bfs() {
    memset(block, 0, sizeof block);
    block[0] = 1;
    q.push(0);
    while (!q.empty()) {
        ll v = q.front();
        q.pop();
        for (ll i = 0; i < (int)edges[v].size(); ++i) {
            ll id = edges[v][i];
            if (!block[allEdges[id].to] && allEdges[id].cap > allEdges[id].flow) {
                block[allEdges[id].to] = block[v] + 1;
                q.push(allEdges[id].to);
            }
        }
    }
    return (block[n - 1] > 0);
}

ll dfs(ll v, ll mn = inf) {
    if (!mn || v == n - 1) {
        return mn;
    }
    for (; nxt[v] < (ll)edges[v].size(); ++nxt[v]) {
        ll id = edges[v][nxt[v]];
        if (block[v] + 1 == block[allEdges[id].to] &&
            allEdges[id].cap - allEdges[id].flow > 0) {
            ll Min = min(mn + 0ll, allEdges[id].cap - allEdges[id].flow);
            ll cur = dfs(allEdges[id].to, Min);
            if (cur != 0) {
                allEdges[id].flow += cur;
                allEdges[id ^ 1].flow -= cur;
                return cur;
            }
        }
    }
    return 0;
}

long long MaxFlow() {
    long long flow = 0;
    while (bfs()) {
//	   cout << "asd";
       memset(nxt, 0, sizeof nxt);
       while (ll pushed = dfs(0)) flow += pushed;
    }
    return flow;
}

ll xx[777], yy[777], zz[777], m, k;

inline bool ok(double weight) {

	for (int i = 0; i <= n; ++ i) edges[i].clear();
	allEdges.clear();

	for (int i = 1; i <= m; ++ i) {
		ll ss = min((double)zz[i] / weight,	(double)k);
//		cout << xx[i] << " " << yy[i] << " " << ss << endl;
		add(xx[i] - 1, yy[i] - 1, ss);
	}

//	cout << "bfs: " << bfs();
//	exit(0);

	long long curr = MaxFlow();

//	cout << curr << endl;

	return (curr >= k);
}

int main()
{
 	#ifndef ONLINE_JUDGE
    freopen(fname"in", "r", stdin);
    freopen(fname"out", "w", stdout);
	#endif

	cin >> n >> m >> k;

	for (int i = 1; i <= m; ++ i) {
		cin >> xx[i] >> yy[i] >> zz[i];
	}

	double l = 0, r = inf;

	for (int it = 0; it < 200; ++ it) {
		double mid = (l + r) / 2.0;
		if (ok(mid)) l = mid;
		else r = mid;
	}

	l *= k;
	printf("%.10f", l);

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <ctime>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <iomanip>
#include <fstream>
using namespace std;
#define fname ""
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define inf 1000000

const int N = 550;
struct edge {
    ll from, to, cap, flow;
};
vector <edge> allEdges;
vector <ll> edges[N];
ll n;

void add(ll x, ll y, ll z) {
    edge e1 = {x, y, z, 0}, e2 = {y, x, 0, 0};
    edges[x].push_back((int)allEdges.size());
    allEdges.push_back(e1);
    edges[y].push_back((int)allEdges.size());
    allEdges.push_back(e2);
}

ll nxt[N], block[N];

queue <ll> q;

bool bfs() {
    memset(block, 0, sizeof block);
    block[0] = 1;
    q.push(0);
    while (!q.empty()) {
        ll v = q.front();
        q.pop();
        for (ll i = 0; i < (int)edges[v].size(); ++i) {
            ll id = edges[v][i];
            if (!block[allEdges[id].to] && allEdges[id].cap > allEdges[id].flow) {
                block[allEdges[id].to] = block[v] + 1;
                q.push(allEdges[id].to);
            }
        }
    }
    return (block[n - 1] > 0);
}

ll dfs(ll v, ll mn = inf) {
    if (!mn || v == n - 1) {
        return mn;
    }
    for (; nxt[v] < (ll)edges[v].size(); ++nxt[v]) {
        ll id = edges[v][nxt[v]];
        if (block[v] + 1 == block[allEdges[id].to] &&
            allEdges[id].cap - allEdges[id].flow > 0) {
            ll Min = min(mn + 0ll, allEdges[id].cap - allEdges[id].flow);
            ll cur = dfs(allEdges[id].to, Min);
            if (cur != 0) {
                allEdges[id].flow += cur;
                allEdges[id ^ 1].flow -= cur;
                return cur;
            }
        }
    }
    return 0;
}

long long MaxFlow() {
    long long flow = 0;
    while (bfs()) {
//	   cout << "asd";
       memset(nxt, 0, sizeof nxt);
       while (ll pushed = dfs(0)) flow += pushed;
    }
    return flow;
}

ll xx[777], yy[777], zz[777], m, k;

inline bool ok(double weight) {

//	for (int i = 0; i <= n; ++ i) edges[i].clear();
//	allEdges.clear();

	for (int i = 1; i <= m; ++ i) {
		ll ss = (double)zz[i] / weight;
		ss = min(ss, inf + 0ll);
//		cout << xx[i] << " " << yy[i] << " " << ss << endl;
		add(xx[i] - 1, yy[i] - 1, ss);
	}

//	cout << "bfs: " << bfs();
//	exit(0);

	long long curr = MaxFlow();

//	cout << curr << endl;

	return (curr >= k);
}

int main()
{
 	#ifndef ONLINE_JUDGE
    freopen(fname"in", "r", stdin);
    freopen(fname"out", "w", stdout);
	#endif

	cin >> n >> m >> k;

	for (int i = 1; i <= m; ++ i) {
		cin >> xx[i] >> yy[i] >> zz[i];
	}

	double l = 0, r = inf;

	for (int it = 0; it < 200; ++ it) {
		double mid = (l + r) / 2.0;
		if (ok(mid)) l = mid;
		else r = mid;
	}

	l *= k;
	printf("%.10f", l);

	return 0;
}


#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <ctime>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <iomanip>
#include <fstream>
using namespace std;
#define fname ""
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define inf 1000000000

const int N = 550;
struct edge {
    int from, to, cap, flow;
};
vector <edge> allEdges;
vector <int> edges[N];
int n;

void add(int x, int y, int z) {
    edge e1 = {x, y, z, 0}, e2 = {y, x, 0, 0};
    edges[x].push_back((int)allEdges.size());
    allEdges.push_back(e1);
    edges[y].push_back((int)allEdges.size());
    allEdges.push_back(e2);
}

int nxt[N], block[N];

queue <int> q;

bool bfs() {
    memset(block, 0, sizeof block);
    block[0] = 1;
    q.push(0);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int i = 0; i < (int)edges[v].size(); ++i) {
            int id = edges[v][i];
            if (!block[allEdges[id].to] && allEdges[id].cap > allEdges[id].flow) {
                block[allEdges[id].to] = block[v] + 1;
                q.push(allEdges[id].to);
            }
        }
    }
    return (block[n - 1] > 0);
}

int dfs(int v, int mn = inf) {
    if (!mn || v == n - 1) {
        return mn;
    }
    for (; nxt[v] < (int)edges[v].size(); ++nxt[v]) {
        int id = edges[v][nxt[v]];
        if (block[v] + 1 == block[allEdges[id].to] &&
            allEdges[id].cap - allEdges[id].flow > 0) {
            int Min = min(mn, allEdges[id].cap - allEdges[id].flow);
            int cur = dfs(allEdges[id].to, Min);
            if (cur != 0) {
                allEdges[id].flow += cur;
                allEdges[id ^ 1].flow -= cur;
                return cur;
            }
        }
    }
    return 0;
}

long long MaxFlow() {
    long long flow = 0;
    while (bfs()) {
//	   cout << "asd";
       memset(nxt, 0, sizeof nxt);
       while (int pushed = dfs(0)) flow += pushed;
    }
    return flow;
}

int xx[777], yy[777], zz[777], m, k;

inline bool ok(double weight) {

//	for (int i = 0; i <= n; ++ i) edges[i].clear();
//	allEdges.clear();

	for (int i = 1; i <= m; ++ i) {
		int ss = (double)zz[i] / weight;
//		cout << xx[i] << " " << yy[i] << " " << ss << endl;
		add(xx[i] - 1, yy[i] - 1, ss);
	}

//	cout << "bfs: " << bfs();
//	exit(0);

	long long curr = MaxFlow();

//	cout << curr << endl;

	return (curr >= k);
}

int main()
{
 	#ifndef ONLINE_JUDGE
    freopen(fname"in", "r", stdin);
    freopen(fname"out", "w", stdout);
	#endif

	scanf("%d%d%d", &n, &m, &k);

	for (int i = 1; i <= m; ++ i) {
		scanf("%d%d%d", &xx[i], &yy[i], &zz[i]);
	}

	double l = 0, r = inf;

	for (int it = 0; it < 100; ++ it) {
		double mid = (l + r) / 2.0;
		if (ok(mid)) l = mid;
		else r = mid;
	}

	l *= k;
	printf("%.10f", l);

	return 0;
}