#include <bits/stdc++.h>

using namespace std;

typedef int INT;
typedef long long ll;
typedef long double ld;
#define int ll

typedef pair<int, int> pii;
#define one first
#define two second

#define isize(a) static_cast<int>(a.size())

#define qfor(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define fori(n) qfor(i, 0, n)
#define forj(n) qfor(j, 0, n)

const ld EPS = 1e-10L;

struct edge {
    int x, w, pair;
    edge(int _x, int _w, int _pair): x(_x), w(_w), pair(_pair) {};
};

vector<vector<edge>> g0, g;
int n, x;
vector<int> used;
int iter = 0;

bool dfs(int v, int w) {
    if (used[v] == iter) {
        return false;
    }
    if (v == n - 1) {
        return true;
    }
    used[v] = iter;
    for (e : g[v]) {
        if (e.w >= w) {
            e.w -= w;
            g[e.x][e.pair].w += w;
            if (dfs(e.x, w)) {
                return true;
            }
            e.w += w;
            g[e.x][e.pair].w -= w;
        }
    }
    return false;
}

bool check(ld val) {
    // cerr << val << endl;
    int cnt = x;

    fori (n) {
        g[i].clear();
        for (e : g0[i]) {
            g[i].emplace_back(e.x, int(ld(e.w) / val + EPS), e.pair);
            // cerr << g[i].back().w << ' ';
        }
        // cerr << endl;
    }

    for (int w = cnt; w > 0 && cnt > 0; w /= 2) {
        ++iter;
        while (w <= cnt && dfs(0, w)) {
            cnt -= w;
            ++iter;
        }
    }

    // fori (x) {
    //     ++iter;
    //     if (!dfs(0, 1)) {
    //         return false;
    //     }
    // }

    // return true;
    return cnt == 0;
}

INT main() {
    #ifdef _GLIBCXX_DEBUG
    if (!freopen("test.in", "r", stdin))
        throw logic_error("failed to read test file");
        cerr << fixed << setprecision(10);
    #else
    cin.tie(0);
    #endif
    ios_base::sync_with_stdio(0);
    /// =======================================

    int m;
    cin >> n >> m >> x;

    g.resize(n);
    g0.resize(n);
    used.resize(n);

    vector<int> we;

    fori (m) {
        int a, b, w;
        cin >> a >> b >> w;
        --a, --b;
        g0[a].emplace_back(b, w, g0[b].size());
        g0[b].emplace_back(a, w, g0[a].size() - 1);
        we.push_back(w);
    }

    sort(we.begin(), we.end());
    we.resize(unique(we.begin(), we.end()) - we.begin());

    vector<int> left_w(we.size(), -1), right_w(we.size(), -1);
    vector<int> cur_w(we.size());

    ld l = 0, r = 1e6L + 1;//accumulate(g0[n - 1].begin(), g0[n - 1].end(), 0, [](int res, const edge &b) { return res + b.w; }) / x + 5;
    while (r - l > EPS) {
        ld mid = (l + r) / 2.L;
        fori (we.size()) {
            cur_w[i] = int(ld(we[i]) / mid + EPS);
        }
        if (cur_w == left_w) {
            l = mid;
            continue;
        }
        if (cur_w == right_w) {
            r = mid;
            continue;
        }
        if (check(mid)) {
            l = mid;
            left_w = cur_w;
        } else {
            r = mid;
            right_w = cur_w;
        }
    }
    cout << fixed << setprecision(9) << x * l << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef int INT;
typedef long long ll;
typedef long double ld;
#define int ll

typedef pair<int, int> pii;
#define one first
#define two second

#define isize(a) static_cast<int>(a.size())

#define qfor(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define fori(n) qfor(i, 0, n)
#define forj(n) qfor(j, 0, n)

const ld EPS = 1e-10L;
const int INF = 1e9;

struct edge {
    int to, w, pair;
    edge(int _to, int _w, int _pair): to(_to), w(_w), pair(_pair) {};
};

vector<vector<edge>> g0, g;
int n, x;
vector<int> used;
int iter = 0;

int dfs(int v, int flow = INF) {
    if (v == n - 1) {
        return flow;
    }
    used[v] = iter;
    for (e : g[v]) {
        if (e.w > 0 && used[e.to] != iter) {
            int res = dfs(e.to, min(flow, e.w));
            if (res != 0) {
                e.w -= res;
                g[e.to][e.pair].w += res;
                return res;
            }
        }
    }
    return 0;
}

bool check(ld val) {
    fori (n) {
        g[i].clear();
        for (e : g0[i]) {
            g[i].emplace_back(e.to, int(ld(e.w) / val + EPS), e.pair);
        }
    }
    int cnt = x;
    while (cnt > 0) {
        ++iter;
        int res = dfs(0);
        if (res == 0) {
            break;
        }
        cnt -= res;
    }
    return cnt <= 0;
}

INT main() {
    #ifdef _GLIBCXX_DEBUG
    if (!freopen("test.in", "r", stdin))
        throw logic_error("failed to read test file");
        cerr << fixed << setprecision(10);
    #else
    cin.tie(0);
    #endif
    ios_base::sync_with_stdio(0);
    /// =======================================

    int m;
    cin >> n >> m >> x;

    g.resize(n);
    g0.resize(n);
    used.resize(n);

    fori (m) {
        int a, b, w;
        cin >> a >> b >> w;
        --a, --b;
        g0[a].emplace_back(b, w, g0[b].size());
        g0[b].emplace_back(a, w, g0[a].size() - 1);
    }

    ld l = 0, r = 1e6L + 1;
    while (r - l > EPS) {
        ld mid = (l + r) / 2.L;
        if (check(mid)) {
            l = mid;
        } else {
            r = mid;
        }
    }
    cout << fixed << setprecision(9) << ld(x) * l << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef int INT;
typedef long long ll;
typedef long double ld;
#define int ll

typedef pair<int, int> pii;
#define one first
#define two second

#define isize(a) static_cast<int>(a.size())

#define qfor(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define fori(n) qfor(i, 0, n)
#define forj(n) qfor(j, 0, n)

const ld EPS = 1e-15L;
const int INF = 1e9;

struct edge {
    int to, w, pair;
    edge(int _to, int _w, int _pair): to(_to), w(_w), pair(_pair) {};
};

vector<vector<edge>> g0, g;
int n, x;
vector<int> used;
int iter = 0;

int dfs(int v, int flow = INF) {
    if (v == n - 1) {
        return flow;
    }
    used[v] = iter;
    for (e : g[v]) {
        if (e.w > 0 && used[e.to] != iter) {
            int res = dfs(e.to, min(flow, e.w));
            if (res != 0) {
                e.w -= res;
                g[e.to][e.pair].w += res;
                return res;
            }
        }
    }
    return 0;
}

bool check(ld val) {
    fori (n) {
        g[i].clear();
        for (e : g0[i]) {
            g[i].emplace_back(e.to, int((ld(e.w) > val * 1e6L) ? (1e6L) : (ld(e.w) / val + EPS)), e.pair);
        }
    }
    int cnt = x;
    while (cnt > 0) {
        ++iter;
        int res = dfs(0);
        if (res == 0) {
            return false;
        }
        cnt -= res;
    }
    return true;
}

INT main() {
    #ifdef _GLIBCXX_DEBUG
    if (!freopen("test.in", "r", stdin))
        throw logic_error("failed to read test file");
        cerr << fixed << setprecision(10);
    #else
    cin.tie(0);
    #endif
    ios_base::sync_with_stdio(0);
    /// =======================================

    int m;
    cin >> n >> m >> x;

    g.resize(n);
    g0.resize(n);
    used.resize(n);

    fori (m) {
        int a, b, w;
        cin >> a >> b >> w;
        --a, --b;
        g0[a].emplace_back(b, w, g0[b].size());
        g0[b].emplace_back(a, 0, g0[a].size() - 1);
    }

    ld l = 0, r = 1e6L + 1;
    fori (100) {
        ld mid = (l + r) / 2.L;
        if (check(mid)) {
            l = mid;
        } else {
            r = mid;
        }
    }
    cout << fixed << setprecision(10) << ld(x) * l << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef int INT;
typedef long long ll;
typedef long double ld;
#define int ll

typedef pair<int, int> pii;
#define one first
#define two second

#define isize(a) static_cast<int>(a.size())

#define qfor(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define fori(n) qfor(i, 0, n)
#define forj(n) qfor(j, 0, n)

const ld EPS = 1e-10L;
const int INF = 1e9;

struct edge {
    int to, w, pair;
    edge(int _to, int _w, int _pair): to(_to), w(_w), pair(_pair) {};
};

vector<vector<edge>> g0, g;
int n, x;
vector<int> used;
int iter = 0;

int dfs(int v, int flow = INF) {
    if (used[v] == iter) {
        return 0;
    }
    if (v == n - 1) {
        return flow;
    }
    used[v] = iter;
    for (e : g[v]) {
        if (e.w > 0 && used[e.to] != iter) {
            int res = dfs(e.to, min(flow, e.w));
            if (res != 0) {
                e.w -= res;
                g[e.to][e.pair].w += res;
                return res;
            }
        }
    }
    return 0;
}

bool check(ld val) {
    fori (n) {
        g[i].clear();
        for (e : g0[i]) {
            g[i].emplace_back(e.to, int(ld(e.w) / val + EPS), e.pair);
        }
    }
    int cnt = x;
    while (cnt > 0) {
        ++iter;
        int res = dfs(0);
        if (res == 0) {
            break;
        }
        cnt -= res;
    }
    return cnt <= 0;
}

INT main() {
    #ifdef _GLIBCXX_DEBUG
    if (!freopen("test.in", "r", stdin))
        throw logic_error("failed to read test file");
        cerr << fixed << setprecision(10);
    #else
    cin.tie(0);
    #endif
    ios_base::sync_with_stdio(0);
    /// =======================================

    int m;
    cin >> n >> m >> x;

    g.resize(n);
    g0.resize(n);
    used.resize(n);

    fori (m) {
        int a, b, w;
        cin >> a >> b >> w;
        --a, --b;
        g0[a].emplace_back(b, w, g0[b].size());
        g0[b].emplace_back(a, w, g0[a].size() - 1);
    }

    ld l = 0, r = 1e6L + 1;
    while (r - l > EPS) {
        ld mid = (l + r) / 2.L;
        if (check(mid)) {
            l = mid;
        } else {
            r = mid;
        }
    }
    cout << fixed << setprecision(9) << x * l << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef int INT;
typedef long long ll;
typedef long double ld;
#define int ll

typedef pair<int, int> pii;
#define one first
#define two second

#define isize(a) static_cast<int>(a.size())

#define qfor(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define fori(n) qfor(i, 0, n)
#define forj(n) qfor(j, 0, n)

const ld EPS = 1e-10L;

struct edge {
    int x, w, pair;
    edge(int _x, int _w, int _pair): x(_x), w(_w), pair(_pair) {};
};

vector<vector<edge>> g0, g;
int n, x;
vector<int> used;
int iter = 0;

bool dfs(int v, int w) {
    if (used[v] == iter) {
        return false;
    }
    if (v == n - 1) {
        return true;
    }
    used[v] = iter;
    for (e : g[v]) {
        if (e.w >= w) {
            e.w -= w;
            g[e.x][e.pair].w += w;
            if (dfs(e.x, w)) {
                return true;
            }
            e.w += w;
            g[e.x][e.pair].w -= w;
        }
    }
    return false;
}

bool check(ld val) {
    // cerr << val << endl;
    int cnt = x;

    fori (n) {
        g[i].clear();
        for (e : g0[i]) {
            g[i].emplace_back(e.x, int(ld(e.w) / val + EPS), e.pair);
            // cerr << g[i].back().w << ' ';
        }
        // cerr << endl;
    }

    for (int w = cnt; w > 0 && cnt > 0; w /= 2) {
        ++iter;
        while (w <= cnt && dfs(0, w)) {
            cnt -= w;
            ++iter;
        }
    }

    // fori (x) {
    //     ++iter;
    //     if (!dfs(0, 1)) {
    //         return false;
    //     }
    // }

    // return true;
    return cnt == 0;
}

INT main() {
    #ifdef _GLIBCXX_DEBUG
    if (!freopen("test.in", "r", stdin))
        throw logic_error("failed to read test file");
        cerr << fixed << setprecision(10);
    #else
    cin.tie(0);
    #endif
    ios_base::sync_with_stdio(0);
    /// =======================================

    int m;
    cin >> n >> m >> x;

    g.resize(n);
    g0.resize(n);
    used.resize(n);

    vector<int> we;

    fori (m) {
        int a, b, w;
        cin >> a >> b >> w;
        --a, --b;
        g0[a].emplace_back(b, w, g0[b].size());
        g0[b].emplace_back(a, 0, g0[a].size() - 1);
        we.push_back(w);
    }

    sort(we.begin(), we.end());
    we.resize(unique(we.begin(), we.end()) - we.begin());

    vector<int> left_w(we.size(), -1), right_w(we.size(), -1);
    vector<int> cur_w(we.size());

    ld l = 0, r = accumulate(g0[n - 1].begin(), g0[n - 1].end(), 0, [](int res, const edge &b) { return res + b.w; }) / x + 5;
    while (r - l > EPS) {
        ld mid = (l + r) / 2.L;
        fori (we.size()) {
            cur_w[i] = int(ld(we[i]) / mid + EPS);
        }
        if (cur_w == left_w) {
            l = mid;
            continue;
        }
        if (cur_w == right_w) {
            r = mid;
            continue;
        }
        if (check(mid)) {
            l = mid;
            left_w = cur_w;
        } else {
            r = mid;
            right_w = cur_w;
        }
    }
    cout << fixed << setprecision(9) << x * l << endl;
}


#include <bits/stdc++.h>

using namespace std;

typedef int INT;
typedef long long ll;
typedef long double ld;
#define int ll

typedef pair<int, int> pii;
#define one first
#define two second

#define isize(a) static_cast<int>(a.size())

#define qfor(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define fori(n) qfor(i, 0, n)
#define forj(n) qfor(j, 0, n)

const ld EPS = 1e-10L;

struct edge {
    int x, w, pair;
    edge(int _x, int _w, int _pair): x(_x), w(_w), pair(_pair) {};
};

vector<vector<edge>> g0, g;
int n, x;
vector<int> used;
int iter = 0;

bool dfs(int v, int w) {
    if (used[v] == iter) {
        return false;
    }
    if (v == n - 1) {
        return true;
    }
    used[v] = iter;
    for (e : g[v]) {
        if (e.w >= w) {
            e.w -= w;
            g[e.x][e.pair].w += w;
            if (dfs(e.x, w)) {
                return true;
            }
            e.w += w;
            g[e.x][e.pair].w -= w;
        }
    }
    return false;
}

bool check(ld val) {
    // cerr << val << endl;
    int cnt = x;

    fori (n) {
        g[i].clear();
        for (e : g0[i]) {
            g[i].emplace_back(e.x, int(ld(e.w) / val + EPS), e.pair);
            // cerr << g[i].back().w << ' ';
        }
        // cerr << endl;
    }

    for (int w = cnt; w > 0 && cnt > 0; w /= 2) {
        ++iter;
        while (w <= cnt && dfs(0, w)) {
            cnt -= w;
            ++iter;
        }
    }

    // fori (x) {
    //     ++iter;
    //     if (!dfs(0, 1)) {
    //         return false;
    //     }
    // }

    // return true;
    return cnt == 0;
}

INT main() {
    #ifdef _GLIBCXX_DEBUG
    if (!freopen("test.in", "r", stdin))
        throw logic_error("failed to read test file");
        cerr << fixed << setprecision(10);
    #else
    cin.tie(0);
    #endif
    ios_base::sync_with_stdio(0);
    /// =======================================

    int m;
    cin >> n >> m >> x;

    g.resize(n);
    g0.resize(n);
    used.resize(n);

    vector<int> we;

    fori (m) {
        int a, b, w;
        cin >> a >> b >> w;
        --a, --b;
        g0[a].emplace_back(b, w, g0[b].size());
        g0[b].emplace_back(a, w, g0[a].size() - 1);
        we.push_back(w);
    }

    sort(we.begin(), we.end());
    we.resize(unique(we.begin(), we.end()) - we.begin());

    vector<int> left_w(we.size(), -1), right_w(we.size(), -1);
    vector<int> cur_w(we.size());

    ld l = 0, r = accumulate(g0[n - 1].begin(), g0[n - 1].end(), 0, [](int res, const edge &b) { return res + b.w; }) / x + 5;
    while (r - l > EPS) {
        ld mid = (l + r) / 2.L;
        fori (we.size()) {
            cur_w[i] = int(ld(we[i]) / mid + EPS);
        }
        if (cur_w == left_w) {
            l = mid;
            continue;
        }
        if (cur_w == right_w) {
            r = mid;
            continue;
        }
        if (check(mid)) {
            l = mid;
            left_w = cur_w;
        } else {
            r = mid;
            right_w = cur_w;
        }
    }
    cout << fixed << setprecision(9) << x * l << endl;
}


/***********************

  	root8950

***********************/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppii pair< pii,pii >
#define ppll pair< pll,pll >
#define vi vector<int>
#define vll vector< ll >
#define vvi vector< vi >
#define vvll vector< vll >

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define traverse(container, it) for(auto it:container)

#define ft first
#define sd second
#define mp make_pair
#define pb push_back

#define root 1
#define lft (idx << 1)
#define rgt ((idx << 1 ) + 1)
#define cllft lft,st,mid
#define clrgt rgt,mid+1,ed

#define inf INT_MAX/2
#define linf llONG_MAX/2

#define all(p) p.begin(),p.end()
#define set(p) memset(p, -1, sizeof(p))
#define clr(p) memset(p, 0, sizeof(p))
#define mem(p, v) memset(p, v, sizeof(p))
#define cpy(d, s) memcpy(d, s, sizeof(s))
#define asst(X,L,R) assert(X >= L && X <= R)

/*
#define gc getchar_unlocked
int rd_int(){ int num=0; char c=gc(); bool flag=0; while(!((c>='0' & c<='9') || c == '-')) c=gc(); if(c=='-'){ flag=1; c=gc(); } while(c>='0' && c<='9'){ num=(num<<1)+(num<<3)+c-'0'; c=gc(); } if(flag) return -num; return num; }
#define pc putchar_unlocked
void wr_int(int num){ if(num<0){pc('-');num=-num;} char snum[20];int i=0;do{snum[i++]=num%10+48;num/=10;}while(num);i--;while(i>=0){pc(snum[i--]);}pc('\n');}
*/

template <class T> T max(T a,T b,T c){return ( ( a > b ) ? ( ( a > c) ? a : c ) : ( ( b > c ) ? b : c ) );}
template <class T> T min(T a,T b,T c){return ( ( a < b ) ? ( ( a < c) ? a : c ) : ( ( b < c ) ? b : c ) );}
// compiling with gcc11 or above
// g++ -std=c++0x
// Lambdas [capture list](parameters) -> return_type { body }     eg.   auto f = [] (int a,int b) -> int { return a+b; };
// PIE is defined as M_PI

/////////////////////////////////////////////////////////////////////////MACRO ENDS//////////////////////////////////////////////////////////////////////////

const int MOD = 1000000000 + 7 ;
const int MAXN = 100000 + 9 ;
//////////////////////////////////////////////////////////////MAX FLOW - PUSH REALBEL/////////////////////////////////////////////////////////

// Adjacency list implementation of FIFO push relabel maximum flow
// with the gap relabeling heuristic.  This implementation is
// significantly faster than straight Ford-Fulkerson.  It solves
// random problems with 10000 vertices and 1000000 edges in a few
// seconds, though it is possible to construct test cases that
// achieve the worst-case.
//
// Running time:
//     O(|V|^3)
//
// INPUT:
//     - graph, constructed using AddEdge()
//     - source
//     - sink
//
// OUTPUT:
//     - maximum flow value
//     - To obtain the actual flow values, look at all edges with
//       capacity > 0 (zero capacity edges are residual edges).

class Edge{
	public:
	int from, to, cap, flow, index;
	//constructor
	Edge(int init_from, int init_to, int init_cap, int init_flow, int init_index){
		tie(this->from, this->to, this->cap, this->flow, this->index) = mt(init_from, init_to, init_cap, init_flow, init_index);
	}
};

class PushRelabel{
	public:
	int N;
	vector< vector<Edge> > G;
	vll excess;
	vi dist,  count;
	vector<bool> active;
	queue<int> Q;

	PushRelabel(int n){
		this->N = n;
		(this->G).resize(N);
		(this->excess).resize(N);
		(this->dist).resize(N);
		(this->active).resize(N);
		(this->count).resize(2*N);
	}

	void AddEdge(int from, int to, int cap) {
		G[from].pb(Edge(from, to, cap, 0, G[to].size()));
		if (from == to){
			G[from].back().index++;
		}
		G[to].pb(Edge(to, from, 0, 0, G[from].size() - 1));
	}

	void Enqueue(int v){
		if(!active[v] && excess[v] > 0){
			active[v] = true;
			Q.push(v);
		}
	}

	void Push(Edge &e) {
		int amt = (int)(min(excess[e.from], (ll)(e.cap - e.flow)));
		if( (dist[e.from] <= dist[e.to]) || (amt == 0) ) return;
		e.flow += amt;
		G[e.to][e.index].flow -= amt;
		excess[e.to] += amt;
		excess[e.from] -= amt;
		Enqueue(e.to);
	}

	void Gap(int k) {
		for (int v = 0; v < N; v++) {
			if (dist[v] < k){
				continue;
			}
			count[dist[v]]--;
			dist[v] = max(dist[v], N+1);
			count[dist[v]]++;
			Enqueue(v);
		}
	}

	void Relabel(int v) {
		count[dist[v]]--;
		dist[v] = 2*N;
		int sz = G[v].size();
		for (int i = 0; i < sz; i++){
			if (G[v][i].cap - G[v][i].flow > 0){
				dist[v] = min(dist[v], dist[G[v][i].to] + 1);
			}
		}
		count[dist[v]]++;
		Enqueue(v);
	}

	void Discharge(int v) {
		int sz = G[v].size();
		for (int i = 0; excess[v] > 0 && i < sz; i++){
			Push(G[v][i]);
		}
		if (excess[v] > 0) {
			if (count[dist[v]] == 1){
				Gap(dist[v]);
			}
			else{
				Relabel(v);
			}
		}
	}

	ll GetMaxFlow(int s, int t) {
		count[0] = N-1;
		count[N] = 1;
		dist[s] = N;
		active[s] = active[t] = true;
		int sz = G[s].size();
		for (int i = 0; i < sz; i++) {
			excess[s] += G[s][i].cap;
			Push(G[s][i]);
		}

		while (!Q.empty()) {
			int v = Q.front();
			Q.pop();
			active[v] = false;
			Discharge(v);
		}

		ll totflow = 0;
		sz = G[s].size();
		for (int i = 0; i < sz; i++){
			totflow += G[s][i].flow;
		}
		return totflow;
  	}
};

int n,m,bears;
bool check(double wt, vector< vector< pii > > &nxt){
	PushRelabel mxflow(n);
	for(int i=0;i<n;i++){
		int sz=nxt[i].size();
		for(int j=0;j<sz;j++){
			int cap=nxt[i][j].sd/wt;
			mxflow.AddEdge(i,nxt[i][j].ft,cap);
		}
	}
	return mxflow.GetMaxFlow(0,n-1) >= bears;
}

double eps=0.000000001;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	//freopen("tests.txt","r",stdin)
	//freopen("out.txt","w",stdout)
	int t=1;
	//cin >> t;
	while(t--){
		cin >> n >> m >> bears;
		vector< vector< pii > > nxt(n);
		int x,y,c;
		for(int i=0;i<m;i++){
			cin >> x >> y >> c;
			x--;y--;
			nxt[x].pb(mp(y,c));
		}
		/*cout << mxflow.GetMaxFlow(0,n-1) << "\n";
		int sz=mxflow.G[0].size();
		for(int i=0;i<sz;i++){
			trace(mxflow.G[0][i].to ,mxflow.G[0][i].flow);
		}*/
		double lo=0,hi=1e6;
		while(hi - lo > eps){
			double mid=(lo+hi)/2;
			if(check(mid,nxt)){
				lo=mid;
			}
			else{
				hi=mid;
			}
		}
		printf("%lf\n",lo*(double)bears);
	}
	return 0;
}


/***********************

  	root8950

***********************/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppii pair< pii,pii >
#define ppll pair< pll,pll >
#define vi vector<int>
#define vll vector< ll >
#define vvi vector< vi >
#define vvll vector< vll >

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define traverse(container, it) for(auto it:container)

#define ft first
#define sd second
#define mp make_pair
#define pb push_back

#define root 1
#define lft (idx << 1)
#define rgt ((idx << 1 ) + 1)
#define cllft lft,st,mid
#define clrgt rgt,mid+1,ed

#define inf INT_MAX/2
#define linf llONG_MAX/2

#define all(p) p.begin(),p.end()
#define set(p) memset(p, -1, sizeof(p))
#define clr(p) memset(p, 0, sizeof(p))
#define mem(p, v) memset(p, v, sizeof(p))
#define cpy(d, s) memcpy(d, s, sizeof(s))
#define asst(X,L,R) assert(X >= L && X <= R)

/*
#define gc getchar_unlocked
int rd_int(){ int num=0; char c=gc(); bool flag=0; while(!((c>='0' & c<='9') || c == '-')) c=gc(); if(c=='-'){ flag=1; c=gc(); } while(c>='0' && c<='9'){ num=(num<<1)+(num<<3)+c-'0'; c=gc(); } if(flag) return -num; return num; }
#define pc putchar_unlocked
void wr_int(int num){ if(num<0){pc('-');num=-num;} char snum[20];int i=0;do{snum[i++]=num%10+48;num/=10;}while(num);i--;while(i>=0){pc(snum[i--]);}pc('\n');}
*/

template <class T> T max(T a,T b,T c){return ( ( a > b ) ? ( ( a > c) ? a : c ) : ( ( b > c ) ? b : c ) );}
template <class T> T min(T a,T b,T c){return ( ( a < b ) ? ( ( a < c) ? a : c ) : ( ( b < c ) ? b : c ) );}
// compiling with gcc11 or above
// g++ -std=c++0x
// Lambdas [capture list](parameters) -> return_type { body }     eg.   auto f = [] (int a,int b) -> int { return a+b; };
// PIE is defined as M_PI

/////////////////////////////////////////////////////////////////////////MACRO ENDS//////////////////////////////////////////////////////////////////////////

const int MOD = 1000000000 + 7 ;
const int MAXN = 100000 + 9 ;
//////////////////////////////////////////////////////////////MAX FLOW - PUSH REALBEL/////////////////////////////////////////////////////////

// Adjacency list implementation of FIFO push relabel maximum flow
// with the gap relabeling heuristic.  This implementation is
// significantly faster than straight Ford-Fulkerson.  It solves
// random problems with 10000 vertices and 1000000 edges in a few
// seconds, though it is possible to construct test cases that
// achieve the worst-case.
//
// Running time:
//     O(|V|^3)
//
// INPUT:
//     - graph, constructed using AddEdge()
//     - source
//     - sink
//
// OUTPUT:
//     - maximum flow value
//     - To obtain the actual flow values, look at all edges with
//       capacity > 0 (zero capacity edges are residual edges).

class Edge{
	public:
	int from, to, cap, flow, index;
	//constructor
	Edge(int init_from, int init_to, int init_cap, int init_flow, int init_index){
		tie(this->from, this->to, this->cap, this->flow, this->index) = mt(init_from, init_to, init_cap, init_flow, init_index);
	}
};

class PushRelabel{
	public:
	int N;
	vector< vector<Edge> > G;
	vll excess;
	vi dist,  count;
	vector<bool> active;
	queue<int> Q;

	PushRelabel(int n){
		this->N = n;
		(this->G).resize(N);
		(this->excess).resize(N);
		(this->dist).resize(N);
		(this->active).resize(N);
		(this->count).resize(2*N);
	}

	void AddEdge(int from, int to, int cap) {
		G[from].pb(Edge(from, to, cap, 0, G[to].size()));
		if (from == to){
			G[from].back().index++;
		}
		G[to].pb(Edge(to, from, 0, 0, G[from].size() - 1));
	}

	void Enqueue(int v){
		if(!active[v] && excess[v] > 0){
			active[v] = true;
			Q.push(v);
		}
	}

	void Push(Edge &e) {
		int amt = (int)(min(excess[e.from], (ll)(e.cap - e.flow)));
		if( (dist[e.from] <= dist[e.to]) || (amt == 0) ) return;
		e.flow += amt;
		G[e.to][e.index].flow -= amt;
		excess[e.to] += amt;
		excess[e.from] -= amt;
		Enqueue(e.to);
	}

	void Gap(int k) {
		for (int v = 0; v < N; v++) {
			if (dist[v] < k){
				continue;
			}
			count[dist[v]]--;
			dist[v] = max(dist[v], N+1);
			count[dist[v]]++;
			Enqueue(v);
		}
	}

	void Relabel(int v) {
		count[dist[v]]--;
		dist[v] = 2*N;
		int sz = G[v].size();
		for (int i = 0; i < sz; i++){
			if (G[v][i].cap - G[v][i].flow > 0){
				dist[v] = min(dist[v], dist[G[v][i].to] + 1);
			}
		}
		count[dist[v]]++;
		Enqueue(v);
	}

	void Discharge(int v) {
		int sz = G[v].size();
		for (int i = 0; excess[v] > 0 && i < sz; i++){
			Push(G[v][i]);
		}
		if (excess[v] > 0) {
			if (count[dist[v]] == 1){
				Gap(dist[v]);
			}
			else{
				Relabel(v);
			}
		}
	}

	ll GetMaxFlow(int s, int t) {
		count[0] = N-1;
		count[N] = 1;
		dist[s] = N;
		active[s] = active[t] = true;
		int sz = G[s].size();
		for (int i = 0; i < sz; i++) {
			excess[s] += G[s][i].cap;
			Push(G[s][i]);
		}

		while (!Q.empty()) {
			int v = Q.front();
			Q.pop();
			active[v] = false;
			Discharge(v);
		}

		ll totflow = 0;
		sz = G[s].size();
		for (int i = 0; i < sz; i++){
			totflow += G[s][i].flow;
		}
		return totflow;
  	}
};

int n,m,bears;
bool check(double wt, vector< vector< pii > > &nxt){
	PushRelabel mxflow(n);
	for(int i=0;i<n;i++){
		int sz=nxt[i].size();
		for(int j=0;j<sz;j++){
			int cap=nxt[i][j].sd/wt;
			mxflow.AddEdge(i,nxt[i][j].ft,cap);
		}
	}
	return mxflow.GetMaxFlow(0,n-1) >= bears;
}

double eps=0.0000000001;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	//freopen("tests.txt","r",stdin)
	//freopen("out.txt","w",stdout)
	int t=1;
	//cin >> t;
	while(t--){
		cin >> n >> m >> bears;
		vector< vector< pii > > nxt(n);
		int x,y,c;
		for(int i=0;i<m;i++){
			cin >> x >> y >> c;
			x--;y--;
			nxt[x].pb(mp(y,c));
		}
		/*cout << mxflow.GetMaxFlow(0,n-1) << "\n";
		int sz=mxflow.G[0].size();
		for(int i=0;i<sz;i++){
			trace(mxflow.G[0][i].to ,mxflow.G[0][i].flow);
		}*/
		double lo=0,hi=1e8;
		while(hi - lo >= eps){
			double mid=(lo+hi)/2;
			if(check(mid,nxt)){
				lo=mid;
			}
			else{
				hi=mid;
			}
		}
		printf("%.8lf\n",lo*(double)bears);
	}
	return 0;
}


/***********************

  	root8950

***********************/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppii pair< pii,pii >
#define ppll pair< pll,pll >
#define vi vector<int>
#define vll vector< ll >
#define vvi vector< vi >
#define vvll vector< vll >

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define traverse(container, it) for(auto it:container)

#define ft first
#define sd second
#define mp make_pair
#define pb push_back

#define root 1
#define lft (idx << 1)
#define rgt ((idx << 1 ) + 1)
#define cllft lft,st,mid
#define clrgt rgt,mid+1,ed

#define inf INT_MAX/2
#define linf llONG_MAX/2

#define all(p) p.begin(),p.end()
#define set(p) memset(p, -1, sizeof(p))
#define clr(p) memset(p, 0, sizeof(p))
#define mem(p, v) memset(p, v, sizeof(p))
#define cpy(d, s) memcpy(d, s, sizeof(s))
#define asst(X,L,R) assert(X >= L && X <= R)

/*
#define gc getchar_unlocked
int rd_int(){ int num=0; char c=gc(); bool flag=0; while(!((c>='0' & c<='9') || c == '-')) c=gc(); if(c=='-'){ flag=1; c=gc(); } while(c>='0' && c<='9'){ num=(num<<1)+(num<<3)+c-'0'; c=gc(); } if(flag) return -num; return num; }
#define pc putchar_unlocked
void wr_int(int num){ if(num<0){pc('-');num=-num;} char snum[20];int i=0;do{snum[i++]=num%10+48;num/=10;}while(num);i--;while(i>=0){pc(snum[i--]);}pc('\n');}
*/

template <class T> T max(T a,T b,T c){return ( ( a > b ) ? ( ( a > c) ? a : c ) : ( ( b > c ) ? b : c ) );}
template <class T> T min(T a,T b,T c){return ( ( a < b ) ? ( ( a < c) ? a : c ) : ( ( b < c ) ? b : c ) );}
// compiling with gcc11 or above
// g++ -std=c++0x
// Lambdas [capture list](parameters) -> return_type { body }     eg.   auto f = [] (int a,int b) -> int { return a+b; };
// PIE is defined as M_PI

/////////////////////////////////////////////////////////////////////////MACRO ENDS//////////////////////////////////////////////////////////////////////////

const int MOD = 1000000000 + 7 ;
const int MAXN = 100000 + 9 ;
//////////////////////////////////////////////////////////////MAX FLOW - PUSH REALBEL/////////////////////////////////////////////////////////

// Adjacency list implementation of FIFO push relabel maximum flow
// with the gap relabeling heuristic.  This implementation is
// significantly faster than straight Ford-Fulkerson.  It solves
// random problems with 10000 vertices and 1000000 edges in a few
// seconds, though it is possible to construct test cases that
// achieve the worst-case.
//
// Running time:
//     O(|V|^3)
//
// INPUT:
//     - graph, constructed using AddEdge()
//     - source
//     - sink
//
// OUTPUT:
//     - maximum flow value
//     - To obtain the actual flow values, look at all edges with
//       capacity > 0 (zero capacity edges are residual edges).

class Edge{
	public:
	int from, to, cap, flow, index;
	//constructor
	Edge(int init_from, int init_to, int init_cap, int init_flow, int init_index){
		tie(this->from, this->to, this->cap, this->flow, this->index) = mt(init_from, init_to, init_cap, init_flow, init_index);
	}
};

class PushRelabel{
	public:
	int N;
	vector< vector<Edge> > G;
	vll excess;
	vi dist,  count;
	vector<bool> active;
	queue<int> Q;

	PushRelabel(int n){
		this->N = n;
		(this->G).resize(N);
		(this->excess).resize(N);
		(this->dist).resize(N);
		(this->active).resize(N);
		(this->count).resize(2*N);
	}

	void AddEdge(int from, int to, int cap) {
		G[from].pb(Edge(from, to, cap, 0, G[to].size()));
		if (from == to){
			G[from].back().index++;
		}
		G[to].pb(Edge(to, from, 0, 0, G[from].size() - 1));
	}

	void Enqueue(int v){
		if(!active[v] && excess[v] > 0){
			active[v] = true;
			Q.push(v);
		}
	}

	void Push(Edge &e) {
		int amt = (int)(min(excess[e.from], (ll)(e.cap - e.flow)));
		if( (dist[e.from] <= dist[e.to]) || (amt == 0) ) return;
		e.flow += amt;
		G[e.to][e.index].flow -= amt;
		excess[e.to] += amt;
		excess[e.from] -= amt;
		Enqueue(e.to);
	}

	void Gap(int k) {
		for (int v = 0; v < N; v++) {
			if (dist[v] < k){
				continue;
			}
			count[dist[v]]--;
			dist[v] = max(dist[v], N+1);
			count[dist[v]]++;
			Enqueue(v);
		}
	}

	void Relabel(int v) {
		count[dist[v]]--;
		dist[v] = 2*N;
		int sz = G[v].size();
		for (int i = 0; i < sz; i++){
			if (G[v][i].cap - G[v][i].flow > 0){
				dist[v] = min(dist[v], dist[G[v][i].to] + 1);
			}
		}
		count[dist[v]]++;
		Enqueue(v);
	}

	void Discharge(int v) {
		int sz = G[v].size();
		for (int i = 0; excess[v] > 0 && i < sz; i++){
			Push(G[v][i]);
		}
		if (excess[v] > 0) {
			if (count[dist[v]] == 1){
				Gap(dist[v]);
			}
			else{
				Relabel(v);
			}
		}
	}

	ll GetMaxFlow(int s, int t) {
		count[0] = N-1;
		count[N] = 1;
		dist[s] = N;
		active[s] = active[t] = true;
		int sz = G[s].size();
		for (int i = 0; i < sz; i++) {
			excess[s] += G[s][i].cap;
			Push(G[s][i]);
		}

		while (!Q.empty()) {
			int v = Q.front();
			Q.pop();
			active[v] = false;
			Discharge(v);
		}

		ll totflow = 0;
		sz = G[s].size();
		for (int i = 0; i < sz; i++){
			totflow += G[s][i].flow;
		}
		return totflow;
  	}
};

int n,m,bears;
bool check(double wt, vector< vector< pii > > &nxt){
	PushRelabel mxflow(n);
	for(int i=0;i<n;i++){
		int sz=nxt[i].size();
		for(int j=0;j<sz;j++){
			int cap=nxt[i][j].sd/wt;
			mxflow.AddEdge(i,nxt[i][j].ft,cap);
		}
	}
	return mxflow.GetMaxFlow(0,n-1) >= bears;
}

double eps=0.000000000001;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	//freopen("tests.txt","r",stdin)
	//freopen("out.txt","w",stdout)
	int t=1;
	//cin >> t;
	while(t--){
		cin >> n >> m >> bears;
		vector< vector< pii > > nxt(n);
		int x,y,c;
		for(int i=0;i<m;i++){
			cin >> x >> y >> c;
			x--;y--;
			nxt[x].pb(mp(y,c));
		}
		/*cout << mxflow.GetMaxFlow(0,n-1) << "\n";
		int sz=mxflow.G[0].size();
		for(int i=0;i<sz;i++){
			trace(mxflow.G[0][i].to ,mxflow.G[0][i].flow);
		}*/
		double lo=0,hi=1e6;
		while(hi - lo > eps){
			double mid=(lo+hi)/2;
			if(check(mid,nxt)){
				lo=mid;
			}
			else{
				hi=mid;
			}
		}
		printf("%lf\n",lo*(double)bears);
	}
	return 0;
}


/***********************

  	root8950

***********************/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppii pair< pii,pii >
#define ppll pair< pll,pll >
#define vi vector<int>
#define vll vector< ll >
#define vvi vector< vi >
#define vvll vector< vll >

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define traverse(container, it) for(auto it:container)

#define ft first
#define sd second
#define mp make_pair
#define pb push_back

#define root 1
#define lft (idx << 1)
#define rgt ((idx << 1 ) + 1)
#define cllft lft,st,mid
#define clrgt rgt,mid+1,ed

#define inf INT_MAX/2
#define linf llONG_MAX/2

#define all(p) p.begin(),p.end()
#define set(p) memset(p, -1, sizeof(p))
#define clr(p) memset(p, 0, sizeof(p))
#define mem(p, v) memset(p, v, sizeof(p))
#define cpy(d, s) memcpy(d, s, sizeof(s))
#define asst(X,L,R) assert(X >= L && X <= R)

/*
#define gc getchar_unlocked
int rd_int(){ int num=0; char c=gc(); bool flag=0; while(!((c>='0' & c<='9') || c == '-')) c=gc(); if(c=='-'){ flag=1; c=gc(); } while(c>='0' && c<='9'){ num=(num<<1)+(num<<3)+c-'0'; c=gc(); } if(flag) return -num; return num; }
#define pc putchar_unlocked
void wr_int(int num){ if(num<0){pc('-');num=-num;} char snum[20];int i=0;do{snum[i++]=num%10+48;num/=10;}while(num);i--;while(i>=0){pc(snum[i--]);}pc('\n');}
*/

template <class T> T max(T a,T b,T c){return ( ( a > b ) ? ( ( a > c) ? a : c ) : ( ( b > c ) ? b : c ) );}
template <class T> T min(T a,T b,T c){return ( ( a < b ) ? ( ( a < c) ? a : c ) : ( ( b < c ) ? b : c ) );}
// compiling with gcc11 or above
// g++ -std=c++0x
// Lambdas [capture list](parameters) -> return_type { body }     eg.   auto f = [] (int a,int b) -> int { return a+b; };
// PIE is defined as M_PI

/////////////////////////////////////////////////////////////////////////MACRO ENDS//////////////////////////////////////////////////////////////////////////

const int MOD = 1000000000 + 7 ;
const int MAXN = 100000 + 9 ;
//////////////////////////////////////////////////////////////MAX FLOW - DINIC/////////////////////////////////////////////////////////////////////

// Adjacency list implementation of Dinic's blocking flow algorithm.
// This is very fast in practice, and only loses to push-relabel flow.
//
// Running time:
//     O(|V|^2 |E|)
//
// INPUT:
//     - graph, constructed using AddEdge()
//     - source and sink
//
// OUTPUT:
//     - maximum flow value
//     - To obtain actual flow values, look at edges with capacity > 0
//       (zero capacity edges are residual edges).

class Edge{
	public:
	int from, to, cap, flow, index;
	Edge(int init_from, int init_to, int init_cap, int init_flow, int init_index){
		tie(this->from, this->to, this->cap, this->flow, this->index) = mt(init_from, init_to, init_cap, init_flow, init_index);
	}
	ll rcap(){
		return cap - flow;
	}
};

class Dinic{
	public:
	int N;
	vector<vector<Edge> > G;
	vector<vector<Edge *> > Lf;
	vi layer;
	vi Q;

	Dinic(int n){
		this->N = n;
		(this->G).resize(n);
		(this->Q).resize(n);
	}

	void AddEdge(int from, int to, int cap) {
		if (from == to) return;
		G[from].push_back(Edge(from, to, cap, 0, G[to].size()));
		G[to].push_back(Edge(to, from, 0, 0, G[from].size() - 1));
	}

	ll BlockingFlow(int s, int t){
		layer.clear(); layer.resize(N, -1);
		layer[s] = 0;
		Lf.clear(); Lf.resize(N);

		int head = 0, tail = 0;
		Q[tail++] = s;
		while(head < tail){
			int x = Q[head++];
			int sz = G[x].size();
			for (int i = 0; i < sz; i++) {
				Edge &e = G[x][i];
				if(e.rcap() <= 0){
					continue;
				}
				if(layer[e.to] == -1) {
					layer[e.to] = layer[e.from] + 1;
					Q[tail++] = e.to;
				}
				if (layer[e.to] > layer[e.from]) {
					Lf[e.from].push_back(&e);
				}
			}
		}
		if (layer[t] == -1) return 0;

		ll totflow = 0;
		vector<Edge *> P;
		while (!Lf[s].empty()) {
			int curr = P.empty() ? s : P.back()->to;
			if (curr == t) { // Augment
				ll amt = P.front()->rcap();
				int sz = P.size();
				for (int i = 0; i < sz; ++i) {
					amt = min(amt, P[i]->rcap());
				}
				totflow += amt;
				for(int i = P.size() - 1; i >= 0; --i){
					P[i]->flow += amt;
					G[P[i]->to][P[i]->index].flow -= amt;
					if (P[i]->rcap() <= 0){
						Lf[P[i]->from].pop_back();
						P.resize(i);
					}
				}
			}
			else if (Lf[curr].empty()) { // Retreat
				P.pop_back();
				for (int i = 0; i < N; ++i){
					int sz = Lf[i].size();
					for (int j = 0; j < sz; ++j){
						if (Lf[i][j]->to == curr){
							Lf[i].erase(Lf[i].begin() + j);
						}
						sz = Lf[i].size();
					}
				}
			}
			else { // Advance
				P.push_back(Lf[curr].back());
			}
		}
		return totflow;
	}

	ll GetMaxFlow(int s, int t) {
		ll totflow = 0;
		while (ll flow = BlockingFlow(s, t))
			totflow += flow;
		return totflow;
	}
};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int n,m,bears;
bool check(double wt, vector< vector< pii > > &nxt){
	wt=wt/bears;
	Dinic mxflow(n);
	for(int i=0;i<n;i++){
		int sz=nxt[i].size();
		for(int j=0;j<sz;j++){
			int cap=nxt[i][j].sd/wt;
			mxflow.AddEdge(i,nxt[i][j].ft,cap);
		}
	}
	return mxflow.GetMaxFlow(0,n-1) >= bears;
}

double eps=0.0000001;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	//freopen("tests.txt","r",stdin)
	//freopen("out.txt","w",stdout)
	int t=1;
	//cin >> t;
	while(t--){
		cin >> n >> m >> bears;
		vector< vector< pii > > nxt(n);
		int x,y,c;
		for(int i=0;i<m;i++){
			cin >> x >> y >> c;
			x--;y--;
			nxt[x].pb(mp(y,c));
		}
		/*cout << mxflow.GetMaxFlow(0,n-1) << "\n";
		int sz=mxflow.G[0].size();
		for(int i=0;i<sz;i++){
			trace(mxflow.G[0][i].to ,mxflow.G[0][i].flow);
		}*/
		double lo=1,hi=1e8;
		while(hi - lo >= eps){
			double mid=(lo+hi)/2;
			if(check(mid,nxt)){
				lo=mid;
			}
			else{
				hi=mid;
			}
		}
		printf("%.9lf\n",lo);
	}
	return 0;
}


/***********************

  	root8950

***********************/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppii pair< pii,pii >
#define ppll pair< pll,pll >
#define vi vector<int>
#define vll vector< ll >
#define vvi vector< vi >
#define vvll vector< vll >

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define traverse(container, it) for(auto it:container)

#define ft first
#define sd second
#define mp make_pair
#define pb push_back

#define root 1
#define lft (idx << 1)
#define rgt ((idx << 1 ) + 1)
#define cllft lft,st,mid
#define clrgt rgt,mid+1,ed

#define inf INT_MAX/2
#define linf llONG_MAX/2

#define all(p) p.begin(),p.end()
#define set(p) memset(p, -1, sizeof(p))
#define clr(p) memset(p, 0, sizeof(p))
#define mem(p, v) memset(p, v, sizeof(p))
#define cpy(d, s) memcpy(d, s, sizeof(s))
#define asst(X,L,R) assert(X >= L && X <= R)

/*
#define gc getchar_unlocked
int rd_int(){ int num=0; char c=gc(); bool flag=0; while(!((c>='0' & c<='9') || c == '-')) c=gc(); if(c=='-'){ flag=1; c=gc(); } while(c>='0' && c<='9'){ num=(num<<1)+(num<<3)+c-'0'; c=gc(); } if(flag) return -num; return num; }
#define pc putchar_unlocked
void wr_int(int num){ if(num<0){pc('-');num=-num;} char snum[20];int i=0;do{snum[i++]=num%10+48;num/=10;}while(num);i--;while(i>=0){pc(snum[i--]);}pc('\n');}
*/

template <class T> T max(T a,T b,T c){return ( ( a > b ) ? ( ( a > c) ? a : c ) : ( ( b > c ) ? b : c ) );}
template <class T> T min(T a,T b,T c){return ( ( a < b ) ? ( ( a < c) ? a : c ) : ( ( b < c ) ? b : c ) );}
// compiling with gcc11 or above
// g++ -std=c++0x
// Lambdas [capture list](parameters) -> return_type { body }     eg.   auto f = [] (int a,int b) -> int { return a+b; };
// PIE is defined as M_PI

/////////////////////////////////////////////////////////////////////////MACRO ENDS//////////////////////////////////////////////////////////////////////////

const int MOD = 1000000000 + 7 ;
const int MAXN = 100000 + 9 ;
//////////////////////////////////////////////////////////////MAX FLOW - PUSH REALBEL/////////////////////////////////////////////////////////

// Adjacency list implementation of FIFO push relabel maximum flow
// with the gap relabeling heuristic.  This implementation is
// significantly faster than straight Ford-Fulkerson.  It solves
// random problems with 10000 vertices and 1000000 edges in a few
// seconds, though it is possible to construct test cases that
// achieve the worst-case.
//
// Running time:
//     O(|V|^3)
//
// INPUT:
//     - graph, constructed using AddEdge()
//     - source
//     - sink
//
// OUTPUT:
//     - maximum flow value
//     - To obtain the actual flow values, look at all edges with
//       capacity > 0 (zero capacity edges are residual edges).

class Edge{
	public:
	int from, to, cap, flow, index;
	//constructor
	Edge(int init_from, int init_to, int init_cap, int init_flow, int init_index){
		tie(this->from, this->to, this->cap, this->flow, this->index) = mt(init_from, init_to, init_cap, init_flow, init_index);
	}
};

class PushRelabel{
	public:
	int N;
	vector< vector<Edge> > G;
	vll excess;
	vi dist,  count;
	vector<bool> active;
	queue<int> Q;

	PushRelabel(int n){
		this->N = n;
		(this->G).resize(N);
		(this->excess).resize(N);
		(this->dist).resize(N);
		(this->active).resize(N);
		(this->count).resize(2*N);
	}

	void AddEdge(int from, int to, int cap) {
		G[from].pb(Edge(from, to, cap, 0, G[to].size()));
		if (from == to){
			G[from].back().index++;
		}
		G[to].pb(Edge(to, from, 0, 0, G[from].size() - 1));
	}

	void Enqueue(int v){
		if(!active[v] && excess[v] > 0){
			active[v] = true;
			Q.push(v);
		}
	}

	void Push(Edge &e) {
		int amt = (int)(min(excess[e.from], (ll)(e.cap - e.flow)));
		if( (dist[e.from] <= dist[e.to]) || (amt == 0) ) return;
		e.flow += amt;
		G[e.to][e.index].flow -= amt;
		excess[e.to] += amt;
		excess[e.from] -= amt;
		Enqueue(e.to);
	}

	void Gap(int k) {
		for (int v = 0; v < N; v++) {
			if (dist[v] < k){
				continue;
			}
			count[dist[v]]--;
			dist[v] = max(dist[v], N+1);
			count[dist[v]]++;
			Enqueue(v);
		}
	}

	void Relabel(int v) {
		count[dist[v]]--;
		dist[v] = 2*N;
		int sz = G[v].size();
		for (int i = 0; i < sz; i++){
			if (G[v][i].cap - G[v][i].flow > 0){
				dist[v] = min(dist[v], dist[G[v][i].to] + 1);
			}
		}
		count[dist[v]]++;
		Enqueue(v);
	}

	void Discharge(int v) {
		int sz = G[v].size();
		for (int i = 0; excess[v] > 0 && i < sz; i++){
			Push(G[v][i]);
		}
		if (excess[v] > 0) {
			if (count[dist[v]] == 1){
				Gap(dist[v]);
			}
			else{
				Relabel(v);
			}
		}
	}

	ll GetMaxFlow(int s, int t) {
		count[0] = N-1;
		count[N] = 1;
		dist[s] = N;
		active[s] = active[t] = true;
		int sz = G[s].size();
		for (int i = 0; i < sz; i++) {
			excess[s] += G[s][i].cap;
			Push(G[s][i]);
		}

		while (!Q.empty()) {
			int v = Q.front();
			Q.pop();
			active[v] = false;
			Discharge(v);
		}

		ll totflow = 0;
		sz = G[s].size();
		for (int i = 0; i < sz; i++){
			totflow += G[s][i].flow;
		}
		return totflow;
  	}
};

int n,m,bears;
bool check(double wt, vector< vector< pii > > &nxt){
	PushRelabel mxflow(n);
	for(int i=0;i<n;i++){
		int sz=nxt[i].size();
		for(int j=0;j<sz;j++){
			int cap=nxt[i][j].sd/wt;
			mxflow.AddEdge(i,nxt[i][j].ft,cap);
		}
	}
	return mxflow.GetMaxFlow(0,n-1) >= bears;
}

double eps=0.0000001;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(NUll);
	#endif
	//freopen("tests.txt","r",stdin)
	//freopen("out.txt","w",stdout)
	int t=1;
	//cin >> t;
	while(t--){
		cin >> n >> m >> bears;
		vector< vector< pii > > nxt(n);
		int x,y,c;
		for(int i=0;i<m;i++){
			cin >> x >> y >> c;
			x--;y--;
			nxt[x].pb(mp(y,c));
		}
		/*cout << mxflow.GetMaxFlow(0,n-1) << "\n";
		int sz=mxflow.G[0].size();
		for(int i=0;i<sz;i++){
			trace(mxflow.G[0][i].to ,mxflow.G[0][i].flow);
		}*/
		double lo=0,hi=1e6;
		while(hi - lo > eps){
			double mid=(lo+hi)/2;
			if(check(mid,nxt)){
				lo=mid;
			}
			else{
				hi=mid;
			}
		}
		printf("%.8lf\n",lo*bears);
	}
	return 0;
}


/***********************

  	root8950

***********************/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppii pair< pii,pii >
#define ppll pair< pll,pll >
#define vi vector<int>
#define vll vector< ll >
#define vvi vector< vi >
#define vvll vector< vll >

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define traverse(container, it) for(auto it:container)

#define ft first
#define sd second
#define mp make_pair
#define pb push_back

#define root 1
#define lft (idx << 1)
#define rgt ((idx << 1 ) + 1)
#define cllft lft,st,mid
#define clrgt rgt,mid+1,ed

#define inf INT_MAX/2
#define linf llONG_MAX/2

#define all(p) p.begin(),p.end()
#define set(p) memset(p, -1, sizeof(p))
#define clr(p) memset(p, 0, sizeof(p))
#define mem(p, v) memset(p, v, sizeof(p))
#define cpy(d, s) memcpy(d, s, sizeof(s))
#define asst(X,L,R) assert(X >= L && X <= R)

/*
#define gc getchar_unlocked
int rd_int(){ int num=0; char c=gc(); bool flag=0; while(!((c>='0' & c<='9') || c == '-')) c=gc(); if(c=='-'){ flag=1; c=gc(); } while(c>='0' && c<='9'){ num=(num<<1)+(num<<3)+c-'0'; c=gc(); } if(flag) return -num; return num; }
#define pc putchar_unlocked
void wr_int(int num){ if(num<0){pc('-');num=-num;} char snum[20];int i=0;do{snum[i++]=num%10+48;num/=10;}while(num);i--;while(i>=0){pc(snum[i--]);}pc('\n');}
*/

template <class T> T max(T a,T b,T c){return ( ( a > b ) ? ( ( a > c) ? a : c ) : ( ( b > c ) ? b : c ) );}
template <class T> T min(T a,T b,T c){return ( ( a < b ) ? ( ( a < c) ? a : c ) : ( ( b < c ) ? b : c ) );}
// compiling with gcc11 or above
// g++ -std=c++0x
// Lambdas [capture list](parameters) -> return_type { body }     eg.   auto f = [] (int a,int b) -> int { return a+b; };
// PIE is defined as M_PI

/////////////////////////////////////////////////////////////////////////MACRO ENDS//////////////////////////////////////////////////////////////////////////

const int MOD = 1000000000 + 7 ;
const int MAXN = 100000 + 9 ;
//////////////////////////////////////////////////////////////MAX FLOW - DINIC/////////////////////////////////////////////////////////////////////

// Adjacency list implementation of Dinic's blocking flow algorithm.
// This is very fast in practice, and only loses to push-relabel flow.
//
// Running time:
//     O(|V|^2 |E|)
//
// INPUT:
//     - graph, constructed using AddEdge()
//     - source and sink
//
// OUTPUT:
//     - maximum flow value
//     - To obtain actual flow values, look at edges with capacity > 0
//       (zero capacity edges are residual edges).

struct Edge {
  int from, to, cap, flow, index;
  Edge(int from, int to, int cap, int flow, int index) :
    from(from), to(to), cap(cap), flow(flow), index(index) {}
  ll rcap() { return cap - flow; }
};

struct Dinic {
  int N;
  vector<vector<Edge> > G;
  vector<vector<Edge *> > Lf;
  vector<int> layer;
  vector<int> Q;

  Dinic(int N) : N(N), G(N), Q(N) {}

  void AddEdge(int from, int to, int cap) {
    if (from == to) return;
    G[from].push_back(Edge(from, to, cap, 0, G[to].size()));
    G[to].push_back(Edge(to, from, 0, 0, G[from].size() - 1));
  }

  ll BlockingFlow(int s, int t) {
    layer.clear(); layer.resize(N, -1);
    layer[s] = 0;
    Lf.clear(); Lf.resize(N);

    int head = 0, tail = 0;
    Q[tail++] = s;
    while (head < tail) {
      int x = Q[head++];
      for (int i = 0; i < G[x].size(); i++) {
        Edge &e = G[x][i]; if (e.rcap() <= 0) continue;
        if (layer[e.to] == -1) {
          layer[e.to] = layer[e.from] + 1;
          Q[tail++] = e.to;
        }
        if (layer[e.to] > layer[e.from]) {
          Lf[e.from].push_back(&e);
        }
      }
    }
    if (layer[t] == -1) return 0;

    ll totflow = 0;
    vector<Edge *> P;
    while (!Lf[s].empty()) {
      int curr = P.empty() ? s : P.back()->to;
      if (curr == t) { // Augment
        ll amt = P.front()->rcap();
        for (int i = 0; i < P.size(); ++i) {
          amt = min(amt, P[i]->rcap());
        }
        totflow += amt;
        for (int i = P.size() - 1; i >= 0; --i) {
          P[i]->flow += amt;
          G[P[i]->to][P[i]->index].flow -= amt;
          if (P[i]->rcap() <= 0) {
            Lf[P[i]->from].pop_back();
            P.resize(i);
          }
        }
      } else if (Lf[curr].empty()) { // Retreat
        P.pop_back();
        for (int i = 0; i < N; ++i)
          for (int j = 0; j < Lf[i].size(); ++j)
            if (Lf[i][j]->to == curr)
              Lf[i].erase(Lf[i].begin() + j);
      } else { // Advance
        P.push_back(Lf[curr].back());
      }
    }
    return totflow;
  }

  ll GetMaxFlow(int s, int t) {
    ll totflow = 0;
    while (ll flow = BlockingFlow(s, t))
      totflow += flow;
    return totflow;
  }
};

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int n,m,bears;
bool check(double wt, vector< vector< pii > > &nxt){
	wt=wt/bears;
	Dinic mxflow(n);
	for(int i=0;i<n;i++){
		int sz=nxt[i].size();
		for(int j=0;j<sz;j++){
			int cap=nxt[i][j].sd/wt;
			mxflow.AddEdge(i,nxt[i][j].ft,cap);
		}
	}
	return mxflow.GetMaxFlow(0,n-1) >= bears;
}

double eps=0.0000001;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	//freopen("tests.txt","r",stdin)
	//freopen("out.txt","w",stdout)
	int t=1;
	//cin >> t;
	while(t--){
		cin >> n >> m >> bears;
		vector< vector< pii > > nxt(n);
		int x,y,c;
		for(int i=0;i<m;i++){
			cin >> x >> y >> c;
			x--;y--;
			nxt[x].pb(mp(y,c));
		}
		/*cout << mxflow.GetMaxFlow(0,n-1) << "\n";
		int sz=mxflow.G[0].size();
		for(int i=0;i<sz;i++){
			trace(mxflow.G[0][i].to ,mxflow.G[0][i].flow);
		}*/
		double lo=1,hi=1e8;
		while(hi - lo >= eps){
			double mid=(lo+hi)/2;
			if(check(mid,nxt)){
				lo=mid;
			}
			else{
				hi=mid;
			}
		}
		printf("%.9lf\n",lo);
	}
	return 0;
}


/***********************

  	root8950

***********************/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppii pair< pii,pii >
#define ppll pair< pll,pll >
#define vi vector<int>
#define vll vector< ll >
#define vvi vector< vi >
#define vvll vector< vll >

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define traverse(container, it) for(auto it:container)

#define ft first
#define sd second
#define mp make_pair
#define pb push_back

#define root 1
#define lft (idx << 1)
#define rgt ((idx << 1 ) + 1)
#define cllft lft,st,mid
#define clrgt rgt,mid+1,ed

#define inf INT_MAX/2
#define linf llONG_MAX/2

#define all(p) p.begin(),p.end()
#define set(p) memset(p, -1, sizeof(p))
#define clr(p) memset(p, 0, sizeof(p))
#define mem(p, v) memset(p, v, sizeof(p))
#define cpy(d, s) memcpy(d, s, sizeof(s))
#define asst(X,L,R) assert(X >= L && X <= R)

/*
#define gc getchar_unlocked
int rd_int(){ int num=0; char c=gc(); bool flag=0; while(!((c>='0' & c<='9') || c == '-')) c=gc(); if(c=='-'){ flag=1; c=gc(); } while(c>='0' && c<='9'){ num=(num<<1)+(num<<3)+c-'0'; c=gc(); } if(flag) return -num; return num; }
#define pc putchar_unlocked
void wr_int(int num){ if(num<0){pc('-');num=-num;} char snum[20];int i=0;do{snum[i++]=num%10+48;num/=10;}while(num);i--;while(i>=0){pc(snum[i--]);}pc('\n');}
*/

template <class T> T max(T a,T b,T c){return ( ( a > b ) ? ( ( a > c) ? a : c ) : ( ( b > c ) ? b : c ) );}
template <class T> T min(T a,T b,T c){return ( ( a < b ) ? ( ( a < c) ? a : c ) : ( ( b < c ) ? b : c ) );}
// compiling with gcc11 or above
// g++ -std=c++0x
// Lambdas [capture list](parameters) -> return_type { body }     eg.   auto f = [] (int a,int b) -> int { return a+b; };
// PIE is defined as M_PI

/////////////////////////////////////////////////////////////////////////MACRO ENDS//////////////////////////////////////////////////////////////////////////

const int MOD = 1000000000 + 7 ;
const int MAXN = 100000 + 9 ;
//////////////////////////////////////////////////////////////MAX FLOW - PUSH REALBEL/////////////////////////////////////////////////////////

// Adjacency list implementation of FIFO push relabel maximum flow
// with the gap relabeling heuristic.  This implementation is
// significantly faster than straight Ford-Fulkerson.  It solves
// random problems with 10000 vertices and 1000000 edges in a few
// seconds, though it is possible to construct test cases that
// achieve the worst-case.
//
// Running time:
//     O(|V|^3)
//
// INPUT:
//     - graph, constructed using AddEdge()
//     - source
//     - sink
//
// OUTPUT:
//     - maximum flow value
//     - To obtain the actual flow values, look at all edges with
//       capacity > 0 (zero capacity edges are residual edges).

class Edge{
	public:
	int from, to, cap, flow, index;
	//constructor
	Edge(int init_from, int init_to, int init_cap, int init_flow, int init_index){
		tie(this->from, this->to, this->cap, this->flow, this->index) = mt(init_from, init_to, init_cap, init_flow, init_index);
	}
};

class PushRelabel{
	public:
	int N;
	vector< vector<Edge> > G;
	vll excess;
	vi dist,  count;
	vector<bool> active;
	queue<int> Q;

	PushRelabel(int n){
		this->N = n;
		(this->G).resize(N);
		(this->excess).resize(N);
		(this->dist).resize(N);
		(this->active).resize(N);
		(this->count).resize(2*N);
	}

	void AddEdge(int from, int to, int cap) {
		G[from].pb(Edge(from, to, cap, 0, G[to].size()));
		if (from == to){
			G[from].back().index++;
		}
		G[to].pb(Edge(to, from, 0, 0, G[from].size() - 1));
	}

	void Enqueue(int v){
		if(!active[v] && excess[v] > 0){
			active[v] = true;
			Q.push(v);
		}
	}

	void Push(Edge &e) {
		int amt = (int)(min(excess[e.from], (ll)(e.cap - e.flow)));
		if( (dist[e.from] <= dist[e.to]) || (amt == 0) ) return;
		e.flow += amt;
		G[e.to][e.index].flow -= amt;
		excess[e.to] += amt;
		excess[e.from] -= amt;
		Enqueue(e.to);
	}

	void Gap(int k) {
		for (int v = 0; v < N; v++) {
			if (dist[v] < k){
				continue;
			}
			count[dist[v]]--;
			dist[v] = max(dist[v], N+1);
			count[dist[v]]++;
			Enqueue(v);
		}
	}

	void Relabel(int v) {
		count[dist[v]]--;
		dist[v] = 2*N;
		int sz = G[v].size();
		for (int i = 0; i < sz; i++){
			if (G[v][i].cap - G[v][i].flow > 0){
				dist[v] = min(dist[v], dist[G[v][i].to] + 1);
			}
		}
		count[dist[v]]++;
		Enqueue(v);
	}

	void Discharge(int v) {
		int sz = G[v].size();
		for (int i = 0; excess[v] > 0 && i < sz; i++){
			Push(G[v][i]);
		}
		if (excess[v] > 0) {
			if (count[dist[v]] == 1){
				Gap(dist[v]);
			}
			else{
				Relabel(v);
			}
		}
	}

	ll GetMaxFlow(int s, int t) {
		count[0] = N-1;
		count[N] = 1;
		dist[s] = N;
		active[s] = active[t] = true;
		int sz = G[s].size();
		for (int i = 0; i < sz; i++) {
			excess[s] += G[s][i].cap;
			Push(G[s][i]);
		}

		while (!Q.empty()) {
			int v = Q.front();
			Q.pop();
			active[v] = false;
			Discharge(v);
		}

		ll totflow = 0;
		sz = G[s].size();
		for (int i = 0; i < sz; i++){
			totflow += G[s][i].flow;
		}
		return totflow;
  	}
};

int n,m,bears;
bool check(double wt, vector< vector< pii > > &nxt){
	PushRelabel mxflow(n);
	for(int i=0;i<n;i++){
		int sz=nxt[i].size();
		for(int j=0;j<sz;j++){
			int cap=nxt[i][j].sd/wt;
			mxflow.AddEdge(i,nxt[i][j].ft,cap);
		}
	}
	return mxflow.GetMaxFlow(0,n-1) >= bears;
}

double eps=0.0000001;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	//freopen("tests.txt","r",stdin)
	//freopen("out.txt","w",stdout)
	int t=1;
	//cin >> t;
	while(t--){
		cin >> n >> m >> bears;
		vector< vector< pii > > nxt(n);
		int x,y,c;
		for(int i=0;i<m;i++){
			cin >> x >> y >> c;
			x--;y--;
			nxt[x].pb(mp(y,c));
		}
		/*cout << mxflow.GetMaxFlow(0,n-1) << "\n";
		int sz=mxflow.G[0].size();
		for(int i=0;i<sz;i++){
			trace(mxflow.G[0][i].to ,mxflow.G[0][i].flow);
		}*/
		double lo=0,hi=1e6;
		while(hi - lo > eps){
			double mid=(lo+hi)/2;
			if(check(mid,nxt)){
				lo=mid;
			}
			else{
				hi=mid;
			}
		}
		printf("%.8lf\n",lo*bears);
	}
	return 0;
}


/***********************

  	root8950

***********************/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppii pair< pii,pii >
#define ppll pair< pll,pll >
#define vi vector<int>
#define vll vector< ll >
#define vvi vector< vi >
#define vvll vector< vll >

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define traverse(container, it) for(auto it:container)

#define ft first
#define sd second
#define mp make_pair
#define pb push_back

#define root 1
#define lft (idx << 1)
#define rgt ((idx << 1 ) + 1)
#define cllft lft,st,mid
#define clrgt rgt,mid+1,ed

#define inf INT_MAX/2
#define linf llONG_MAX/2

#define all(p) p.begin(),p.end()
#define set(p) memset(p, -1, sizeof(p))
#define clr(p) memset(p, 0, sizeof(p))
#define mem(p, v) memset(p, v, sizeof(p))
#define cpy(d, s) memcpy(d, s, sizeof(s))
#define asst(X,L,R) assert(X >= L && X <= R)

/*
#define gc getchar_unlocked
int rd_int(){ int num=0; char c=gc(); bool flag=0; while(!((c>='0' & c<='9') || c == '-')) c=gc(); if(c=='-'){ flag=1; c=gc(); } while(c>='0' && c<='9'){ num=(num<<1)+(num<<3)+c-'0'; c=gc(); } if(flag) return -num; return num; }
#define pc putchar_unlocked
void wr_int(int num){ if(num<0){pc('-');num=-num;} char snum[20];int i=0;do{snum[i++]=num%10+48;num/=10;}while(num);i--;while(i>=0){pc(snum[i--]);}pc('\n');}
*/

template <class T> T max(T a,T b,T c){return ( ( a > b ) ? ( ( a > c) ? a : c ) : ( ( b > c ) ? b : c ) );}
template <class T> T min(T a,T b,T c){return ( ( a < b ) ? ( ( a < c) ? a : c ) : ( ( b < c ) ? b : c ) );}
// compiling with gcc11 or above
// g++ -std=c++0x
// Lambdas [capture list](parameters) -> return_type { body }     eg.   auto f = [] (int a,int b) -> int { return a+b; };
// PIE is defined as M_PI

/////////////////////////////////////////////////////////////////////////MACRO ENDS//////////////////////////////////////////////////////////////////////////

const int MOD = 1000000000 + 7 ;
const int MAXN = 100000 + 9 ;
//////////////////////////////////////////////////////////////MAX FLOW - PUSH REALBEL/////////////////////////////////////////////////////////

// Adjacency list implementation of FIFO push relabel maximum flow
// with the gap relabeling heuristic.  This implementation is
// significantly faster than straight Ford-Fulkerson.  It solves
// random problems with 10000 vertices and 1000000 edges in a few
// seconds, though it is possible to construct test cases that
// achieve the worst-case.
//
// Running time:
//     O(|V|^3)
//
// INPUT:
//     - graph, constructed using AddEdge()
//     - source
//     - sink
//
// OUTPUT:
//     - maximum flow value
//     - To obtain the actual flow values, look at all edges with
//       capacity > 0 (zero capacity edges are residual edges).

class Edge{
	public:
	int from, to, cap, flow, index;
	//constructor
	Edge(int init_from, int init_to, int init_cap, int init_flow, int init_index){
		tie(this->from, this->to, this->cap, this->flow, this->index) = mt(init_from, init_to, init_cap, init_flow, init_index);
	}
};

class PushRelabel{
	public:
	int N;
	vector< vector<Edge> > G;
	vll excess;
	vi dist,  count;
	vector<bool> active;
	queue<int> Q;

	PushRelabel(int n){
		this->N = n;
		(this->G).resize(N);
		(this->excess).resize(N);
		(this->dist).resize(N);
		(this->active).resize(N);
		(this->count).resize(2*N);
	}

	void AddEdge(int from, int to, int cap) {
		G[from].pb(Edge(from, to, cap, 0, G[to].size()));
		if (from == to){
			G[from].back().index++;
		}
		G[to].pb(Edge(to, from, 0, 0, G[from].size() - 1));
	}

	void Enqueue(int v){
		if(!active[v] && excess[v] > 0){
			active[v] = true;
			Q.push(v);
		}
	}

	void Push(Edge &e) {
		int amt = (int)(min(excess[e.from], (ll)(e.cap - e.flow)));
		if( (dist[e.from] <= dist[e.to]) || (amt == 0) ) return;
		e.flow += amt;
		G[e.to][e.index].flow -= amt;
		excess[e.to] += amt;
		excess[e.from] -= amt;
		Enqueue(e.to);
	}

	void Gap(int k) {
		for (int v = 0; v < N; v++) {
			if (dist[v] < k){
				continue;
			}
			count[dist[v]]--;
			dist[v] = max(dist[v], N+1);
			count[dist[v]]++;
			Enqueue(v);
		}
	}

	void Relabel(int v) {
		count[dist[v]]--;
		dist[v] = 2*N;
		int sz = G[v].size();
		for (int i = 0; i < sz; i++){
			if (G[v][i].cap - G[v][i].flow > 0){
				dist[v] = min(dist[v], dist[G[v][i].to] + 1);
			}
		}
		count[dist[v]]++;
		Enqueue(v);
	}

	void Discharge(int v) {
		int sz = G[v].size();
		for (int i = 0; excess[v] > 0 && i < sz; i++){
			Push(G[v][i]);
		}
		if (excess[v] > 0) {
			if (count[dist[v]] == 1){
				Gap(dist[v]);
			}
			else{
				Relabel(v);
			}
		}
	}

	ll GetMaxFlow(int s, int t) {
		count[0] = N-1;
		count[N] = 1;
		dist[s] = N;
		active[s] = active[t] = true;
		int sz = G[s].size();
		for (int i = 0; i < sz; i++) {
			excess[s] += G[s][i].cap;
			Push(G[s][i]);
		}

		while (!Q.empty()) {
			int v = Q.front();
			Q.pop();
			active[v] = false;
			Discharge(v);
		}

		ll totflow = 0;
		sz = G[s].size();
		for (int i = 0; i < sz; i++){
			totflow += G[s][i].flow;
		}
		return totflow;
  	}
};

int n,m,bears;
bool check(double wt, vector< vector< pii > > &nxt){
	wt=wt/bears;
	PushRelabel mxflow(n);
	for(int i=0;i<n;i++){
		int sz=nxt[i].size();
		for(int j=0;j<sz;j++){
			int cap=nxt[i][j].sd/wt;
			mxflow.AddEdge(i,nxt[i][j].ft,cap);
		}
	}
	return mxflow.GetMaxFlow(0,n-1) >= bears;
}

double eps=0.0000001;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	//freopen("tests.txt","r",stdin)
	//freopen("out.txt","w",stdout)
	int t=1;
	//cin >> t;
	while(t--){
		cin >> n >> m >> bears;
		vector< vector< pii > > nxt(n);
		int x,y,c;
		for(int i=0;i<m;i++){
			cin >> x >> y >> c;
			x--;y--;
			nxt[x].pb(mp(y,c));
		}
		/*cout << mxflow.GetMaxFlow(0,n-1) << "\n";
		int sz=mxflow.G[0].size();
		for(int i=0;i<sz;i++){
			trace(mxflow.G[0][i].to ,mxflow.G[0][i].flow);
		}*/
		double lo=1,hi=1e8;
		while(hi - lo >= eps){
			double mid=(lo+hi)/2;
			if(check(mid,nxt)){
				lo=mid;
			}
			else{
				hi=mid;
			}
		}
		printf("%.9lf\n",lo);
	}
	return 0;
}


/***********************

  	root8950

***********************/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppii pair< pii,pii >
#define ppll pair< pll,pll >
#define vi vector<int>
#define vll vector< ll >
#define vvi vector< vi >
#define vvll vector< vll >

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define traverse(container, it) for(auto it:container)

#define ft first
#define sd second
#define mp make_pair
#define pb push_back

#define root 1
#define lft (idx << 1)
#define rgt ((idx << 1 ) + 1)
#define cllft lft,st,mid
#define clrgt rgt,mid+1,ed

#define inf INT_MAX/2
#define linf llONG_MAX/2

#define all(p) p.begin(),p.end()
#define set(p) memset(p, -1, sizeof(p))
#define clr(p) memset(p, 0, sizeof(p))
#define mem(p, v) memset(p, v, sizeof(p))
#define cpy(d, s) memcpy(d, s, sizeof(s))
#define asst(X,L,R) assert(X >= L && X <= R)

/*
#define gc getchar_unlocked
int rd_int(){ int num=0; char c=gc(); bool flag=0; while(!((c>='0' & c<='9') || c == '-')) c=gc(); if(c=='-'){ flag=1; c=gc(); } while(c>='0' && c<='9'){ num=(num<<1)+(num<<3)+c-'0'; c=gc(); } if(flag) return -num; return num; }
#define pc putchar_unlocked
void wr_int(int num){ if(num<0){pc('-');num=-num;} char snum[20];int i=0;do{snum[i++]=num%10+48;num/=10;}while(num);i--;while(i>=0){pc(snum[i--]);}pc('\n');}
*/

template <class T> T max(T a,T b,T c){return ( ( a > b ) ? ( ( a > c) ? a : c ) : ( ( b > c ) ? b : c ) );}
template <class T> T min(T a,T b,T c){return ( ( a < b ) ? ( ( a < c) ? a : c ) : ( ( b < c ) ? b : c ) );}
// compiling with gcc11 or above
// g++ -std=c++0x
// Lambdas [capture list](parameters) -> return_type { body }     eg.   auto f = [] (int a,int b) -> int { return a+b; };
// PIE is defined as M_PI

/////////////////////////////////////////////////////////////////////////MACRO ENDS//////////////////////////////////////////////////////////////////////////

const int MOD = 1000000000 + 7 ;
const int MAXN = 100000 + 9 ;
//////////////////////////////////////////////////////////////MAX FLOW - PUSH REALBEL/////////////////////////////////////////////////////////

// Adjacency list implementation of FIFO push relabel maximum flow
// with the gap relabeling heuristic.  This implementation is
// significantly faster than straight Ford-Fulkerson.  It solves
// random problems with 10000 vertices and 1000000 edges in a few
// seconds, though it is possible to construct test cases that
// achieve the worst-case.
//
// Running time:
//     O(|V|^3)
//
// INPUT:
//     - graph, constructed using AddEdge()
//     - source
//     - sink
//
// OUTPUT:
//     - maximum flow value
//     - To obtain the actual flow values, look at all edges with
//       capacity > 0 (zero capacity edges are residual edges).

class Edge{
	public:
	int from, to, cap, flow, index;
	//constructor
	Edge(int init_from, int init_to, int init_cap, int init_flow, int init_index){
		tie(this->from, this->to, this->cap, this->flow, this->index) = mt(init_from, init_to, init_cap, init_flow, init_index);
	}
};

class PushRelabel{
	public:
	int N;
	vector< vector<Edge> > G;
	vll excess;
	vi dist,  count;
	vector<bool> active;
	queue<int> Q;

	PushRelabel(int n){
		this->N = n;
		(this->G).resize(N);
		(this->excess).resize(N);
		(this->dist).resize(N);
		(this->active).resize(N);
		(this->count).resize(2*N);
	}

	void AddEdge(int from, int to, int cap) {
		G[from].pb(Edge(from, to, cap, 0, G[to].size()));
		if (from == to){
			G[from].back().index++;
		}
		G[to].pb(Edge(to, from, 0, 0, G[from].size() - 1));
	}

	void Enqueue(int v){
		if(!active[v] && excess[v] > 0){
			active[v] = true;
			Q.push(v);
		}
	}

	void Push(Edge &e) {
		int amt = (int)(min(excess[e.from], (ll)(e.cap - e.flow)));
		if( (dist[e.from] <= dist[e.to]) || (amt == 0) ) return;
		e.flow += amt;
		G[e.to][e.index].flow -= amt;
		excess[e.to] += amt;
		excess[e.from] -= amt;
		Enqueue(e.to);
	}

	void Gap(int k) {
		for (int v = 0; v < N; v++) {
			if (dist[v] < k){
				continue;
			}
			count[dist[v]]--;
			dist[v] = max(dist[v], N+1);
			count[dist[v]]++;
			Enqueue(v);
		}
	}

	void Relabel(int v) {
		count[dist[v]]--;
		dist[v] = 2*N;
		int sz = G[v].size();
		for (int i = 0; i < sz; i++){
			if (G[v][i].cap - G[v][i].flow > 0){
				dist[v] = min(dist[v], dist[G[v][i].to] + 1);
			}
		}
		count[dist[v]]++;
		Enqueue(v);
	}

	void Discharge(int v) {
		int sz = G[v].size();
		for (int i = 0; excess[v] > 0 && i < sz; i++){
			Push(G[v][i]);
		}
		if (excess[v] > 0) {
			if (count[dist[v]] == 1){
				Gap(dist[v]);
			}
			else{
				Relabel(v);
			}
		}
	}

	ll GetMaxFlow(int s, int t) {
		count[0] = N-1;
		count[N] = 1;
		dist[s] = N;
		active[s] = active[t] = true;
		int sz = G[s].size();
		for (int i = 0; i < sz; i++) {
			excess[s] += G[s][i].cap;
			Push(G[s][i]);
		}

		while (!Q.empty()) {
			int v = Q.front();
			Q.pop();
			active[v] = false;
			Discharge(v);
		}

		ll totflow = 0;
		sz = G[s].size();
		for (int i = 0; i < sz; i++){
			totflow += G[s][i].flow;
		}
		return totflow;
  	}
};

int n,m,bears;
bool check(double wt, vector< vector< pii > > &nxt){
	wt=wt/bears;
	PushRelabel mxflow(n);
	for(int i=0;i<n;i++){
		int sz=nxt[i].size();
		for(int j=0;j<sz;j++){
			int cap=nxt[i][j].sd/wt;
			mxflow.AddEdge(i,nxt[i][j].ft,cap);
		}
	}
	return mxflow.GetMaxFlow(0,n-1) >= bears;
}

double eps=0.0000001;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	//freopen("tests.txt","r",stdin)
	//freopen("out.txt","w",stdout)
	int t=1;
	//cin >> t;
	while(t--){
		cin >> n >> m >> bears;
		vector< vector< pii > > nxt(n);
		int x,y,c;
		for(int i=0;i<m;i++){
			cin >> x >> y >> c;
			x--;y--;
			nxt[x].pb(mp(y,c));
		}
		/*cout << mxflow.GetMaxFlow(0,n-1) << "\n";
		int sz=mxflow.G[0].size();
		for(int i=0;i<sz;i++){
			trace(mxflow.G[0][i].to ,mxflow.G[0][i].flow);
		}*/
		double lo=0,hi=1e8;
		while(hi - lo >= eps){
			double mid=(lo+hi)/2;
			if(check(mid,nxt)){
				lo=mid;
			}
			else{
				hi=mid;
			}
		}
		printf("%.9lf\n",lo);
	}
	return 0;
}


/***********************

  	root8950

***********************/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mt make_tuple
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ppii pair< pii,pii >
#define ppll pair< pll,pll >
#define vi vector<int>
#define vll vector< ll >
#define vvi vector< vi >
#define vvll vector< vll >

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define traverse(container, it) for(auto it:container)

#define ft first
#define sd second
#define mp make_pair
#define pb push_back

#define root 1
#define lft (idx << 1)
#define rgt ((idx << 1 ) + 1)
#define cllft lft,st,mid
#define clrgt rgt,mid+1,ed

#define inf INT_MAX/2
#define linf llONG_MAX/2

#define all(p) p.begin(),p.end()
#define set(p) memset(p, -1, sizeof(p))
#define clr(p) memset(p, 0, sizeof(p))
#define mem(p, v) memset(p, v, sizeof(p))
#define cpy(d, s) memcpy(d, s, sizeof(s))
#define asst(X,L,R) assert(X >= L && X <= R)

/*
#define gc getchar_unlocked
int rd_int(){ int num=0; char c=gc(); bool flag=0; while(!((c>='0' & c<='9') || c == '-')) c=gc(); if(c=='-'){ flag=1; c=gc(); } while(c>='0' && c<='9'){ num=(num<<1)+(num<<3)+c-'0'; c=gc(); } if(flag) return -num; return num; }
#define pc putchar_unlocked
void wr_int(int num){ if(num<0){pc('-');num=-num;} char snum[20];int i=0;do{snum[i++]=num%10+48;num/=10;}while(num);i--;while(i>=0){pc(snum[i--]);}pc('\n');}
*/

template <class T> T max(T a,T b,T c){return ( ( a > b ) ? ( ( a > c) ? a : c ) : ( ( b > c ) ? b : c ) );}
template <class T> T min(T a,T b,T c){return ( ( a < b ) ? ( ( a < c) ? a : c ) : ( ( b < c ) ? b : c ) );}
// compiling with gcc11 or above
// g++ -std=c++0x
// Lambdas [capture list](parameters) -> return_type { body }     eg.   auto f = [] (int a,int b) -> int { return a+b; };
// PIE is defined as M_PI

/////////////////////////////////////////////////////////////////////////MACRO ENDS//////////////////////////////////////////////////////////////////////////

const int MOD = 1000000000 + 7 ;
const int MAXN = 100000 + 9 ;
//////////////////////////////////////////////////////////////MAX FLOW - PUSH REALBEL/////////////////////////////////////////////////////////

// Adjacency list implementation of FIFO push relabel maximum flow
// with the gap relabeling heuristic.  This implementation is
// significantly faster than straight Ford-Fulkerson.  It solves
// random problems with 10000 vertices and 1000000 edges in a few
// seconds, though it is possible to construct test cases that
// achieve the worst-case.
//
// Running time:
//     O(|V|^3)
//
// INPUT:
//     - graph, constructed using AddEdge()
//     - source
//     - sink
//
// OUTPUT:
//     - maximum flow value
//     - To obtain the actual flow values, look at all edges with
//       capacity > 0 (zero capacity edges are residual edges).

class Edge{
	public:
	int from, to, cap, flow, index;
	//constructor
	Edge(int init_from, int init_to, int init_cap, int init_flow, int init_index){
		tie(this->from, this->to, this->cap, this->flow, this->index) = mt(init_from, init_to, init_cap, init_flow, init_index);
	}
};

class PushRelabel{
	public:
	int N;
	vector< vector<Edge> > G;
	vll excess;
	vi dist,  count;
	vector<bool> active;
	queue<int> Q;

	PushRelabel(int n){
		this->N = n;
		(this->G).resize(N);
		(this->excess).resize(N);
		(this->dist).resize(N);
		(this->active).resize(N);
		(this->count).resize(2*N);
	}

	void AddEdge(int from, int to, int cap) {
		G[from].pb(Edge(from, to, cap, 0, G[to].size()));
		if (from == to){
			G[from].back().index++;
		}
		G[to].pb(Edge(to, from, 0, 0, G[from].size() - 1));
	}

	void Enqueue(int v){
		if(!active[v] && excess[v] > 0){
			active[v] = true;
			Q.push(v);
		}
	}

	void Push(Edge &e) {
		int amt = (int)(min(excess[e.from], (ll)(e.cap - e.flow)));
		if( (dist[e.from] <= dist[e.to]) || (amt == 0) ) return;
		e.flow += amt;
		G[e.to][e.index].flow -= amt;
		excess[e.to] += amt;
		excess[e.from] -= amt;
		Enqueue(e.to);
	}

	void Gap(int k) {
		for (int v = 0; v < N; v++) {
			if (dist[v] < k){
				continue;
			}
			count[dist[v]]--;
			dist[v] = max(dist[v], N+1);
			count[dist[v]]++;
			Enqueue(v);
		}
	}

	void Relabel(int v) {
		count[dist[v]]--;
		dist[v] = 2*N;
		int sz = G[v].size();
		for (int i = 0; i < sz; i++){
			if (G[v][i].cap - G[v][i].flow > 0){
				dist[v] = min(dist[v], dist[G[v][i].to] + 1);
			}
		}
		count[dist[v]]++;
		Enqueue(v);
	}

	void Discharge(int v) {
		int sz = G[v].size();
		for (int i = 0; excess[v] > 0 && i < sz; i++){
			Push(G[v][i]);
		}
		if (excess[v] > 0) {
			if (count[dist[v]] == 1){
				Gap(dist[v]);
			}
			else{
				Relabel(v);
			}
		}
	}

	ll GetMaxFlow(int s, int t) {
		count[0] = N-1;
		count[N] = 1;
		dist[s] = N;
		active[s] = active[t] = true;
		int sz = G[s].size();
		for (int i = 0; i < sz; i++) {
			excess[s] += G[s][i].cap;
			Push(G[s][i]);
		}

		while (!Q.empty()) {
			int v = Q.front();
			Q.pop();
			active[v] = false;
			Discharge(v);
		}

		ll totflow = 0;
		sz = G[s].size();
		for (int i = 0; i < sz; i++){
			totflow += G[s][i].flow;
		}
		return totflow;
  	}
};

int n,m,bears;
bool check(double wt, vector< vector< pii > > &nxt){
	wt=wt/bears;
	PushRelabel mxflow(n);
	for(int i=0;i<n;i++){
		int sz=nxt[i].size();
		for(int j=0;j<sz;j++){
			int cap=nxt[i][j].sd/wt;
			mxflow.AddEdge(i,nxt[i][j].ft,cap);
		}
	}
	return mxflow.GetMaxFlow(0,n-1) >= bears;
}

double eps=0.000000001;

int main(){
	#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#endif
	//freopen("tests.txt","r",stdin)
	//freopen("out.txt","w",stdout)
	int t=1;
	//cin >> t;
	while(t--){
		cin >> n >> m >> bears;
		vector< vector< pii > > nxt(n);
		int x,y,c;
		for(int i=0;i<m;i++){
			cin >> x >> y >> c;
			x--;y--;
			nxt[x].pb(mp(y,c));
		}
		/*cout << mxflow.GetMaxFlow(0,n-1) << "\n";
		int sz=mxflow.G[0].size();
		for(int i=0;i<sz;i++){
			trace(mxflow.G[0][i].to ,mxflow.G[0][i].flow);
		}*/
		double lo=0,hi=1e8;
		while(hi - lo >= eps){
			double mid=(lo+hi)/2;
			if(check(mid,nxt)){
				lo=mid;
			}
			else{
				hi=mid;
			}
		}
		printf("%.9lf\n",lo);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long find1(long long a,long long b,long long c,long long d,long long time)
{
	long long diff;
	diff=(long long)a/(c-d);
	if(a%2==1)
	diff=diff+1;
	time += (long long)c*diff;
	return time;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long time=b;
	a=a-b;
	if(a<=0)
	cout<<time<<endl;
	else if(a<=0&&c<d)
	cout<<time<<endl;
	else if(a>0&&c<d)
	cout<<-1<<endl;
	else
	cout<<find1(a,b,c,d,time)<<endl;
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long find(long long a,long long b,long long c,long long d,long long time)
{
	while(a>0)
	{
		a=a-c+d;
		time = time + c;
	}
	return time;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long time=b;
	a=a-b;
	if(a<=0&&c<d)
	cout<<time<<endl;
	else if(a>0&&c<d)
	cout<<-1<<endl;
	else
	cout<<find(a,b,c,d,time)<<endl;
	fflush(stdin);
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
/*long long find1(long long a,long long b,long long c,long long d,long long time)
{
	long long diff;
	diff=(long long)a/(c-d);
	if(a%(c-d)!=0)
	diff=diff+1;
	time += (long long)c*diff;
	return time;
}*/
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
//	long long time=b;
	//a=a-b;
	if(b>=a)
	cout<<b<<endl;
	else if(c<=d)
	cout<<-1<<endl;
	else
	cout<<(a-b+c-d+1)/(c-d)*c + b<<endl;
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
/*long long find1(long long a,long long b,long long c,long long d,long long time)
{
	long long diff;
	diff=(long long)a/(c-d);
	if(a%(c-d)!=0)
	diff=diff+1;
	time += (long long)c*diff;
	return time;
}*/
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
//	long long time=b;
	//a=a-b;
	if(b>=a)
	cout<<b<<endl;
	else if(d>=c)
	cout<<"-1"<<endl;
	else
	cout<<(a-b+c-d-1)/(c-d)*c + b<<endl;
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
/*long long find1(long long a,long long b,long long c,long long d,long long time)
{
	long long diff;
	diff=(long long)a/(c-d);
	if(a%(c-d)!=0)
	diff=diff+1;
	time += (long long)c*diff;
	return time;
}*/
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
//	long long time=b;
	//a=a-b;
	if(b<=a)
	cout<<b<<endl;
	else if(c<=d)
	cout<<-1<<endl;
	else
	cout<<(a-b+c-d+1)/(c-d)*c + b<<endl;
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long find1(long long a,long long b,long long c,long long d,long long time)
{
	long long diff;
	diff=(long long)a/(c-d);
	if(a%(c-d)!=0)
	diff=diff+1;
	time += (long long)c*diff;
	return time;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long time=b;
	a=a-b;
	if(a<=0)
	cout<<time<<endl;
	else if(a<=0&&c<d)
	cout<<time<<endl;
	else if(a>0&&c<d)
	cout<<-1<<endl;
	else
	cout<<find1(a,b,c,d,time)<<endl;
}
return 0;
}


#include<bits/stdc++.h>
using namespace std;
long long find1(long long a,long long b,long long c,long long d,long long time)
{
	while(a>0)
	{
		a=a-c+d;
		time = time + c;
	}
	return time;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	long long time=b;
	a=a-b;
	if(a<=0&&c<d)
	cout<<time<<endl;
	else if(a>0&&c<d)
	cout<<-1<<endl;
	else
	cout<<find1(a,b,c,d,time)<<endl;
}
return 0;
}


#include<iostream>
#include <iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define mod 1000000007
#define pi 3.14159265358979323846
#define fo(i,n) for(ll i=0;i<n;i++)
#define rf(i,n) for(ll i=n-1;i>=0;i--)
//Comment this while submitting as it might cause TLE
//It will change the WA from Integer Overflow to RE.
#pragma GCC optimize "trapv"
using namespace std;
ll countDigits(ll n){ ll dig = floor(log10(n)+1);  return dig;}

int main(){
    FAST;
    ll t;
    cin >>t;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll rem=a-b;
        if(rem<=0){
            cout<<a<<"\n";
            continue;
        }
        if(d>=c){
            cout<<-1<<"\n";
            continue;
        }
        ll ans=b,tot_sleep=b;
        while(tot_sleep<a){
            ans+=c;
            tot_sleep+=(c-d);
        }
        //ans+=rem+d;
        cout<<ans<<"\n";
    }
}


#include<iostream>
#include <iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define mod 1000000007
#define pi 3.14159265358979323846
#define fo(i,n) for(ll i=0;i<n;i++)
#define rf(i,n) for(ll i=n-1;i>=0;i--)
//Comment this while submitting as it might cause TLE
//It will change the WA from Integer Overflow to RE.
#pragma GCC optimize "trapv"
using namespace std;
ll countDigits(ll n){ ll dig = floor(log10(n)+1);  return dig;}

int main(){
    FAST;
    ll t;
    cin >>t;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll rem=a-b;
        if(rem<=0){
            cout<<b<<"\n";
            continue;
        }
        if(d>=c){
            cout<<-1<<"\n";
            continue;
        }
        ll ans=b,tot_sleep=b;
        while(tot_sleep<a){
            ans+=c;
            tot_sleep+=(c-d);
        }
        //ans+=rem+d;
        cout<<ans<<"\n";
    }
}


#include<iostream>
#include <iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define mod 1000000007
#define pi 3.14159265358979323846
#define fo(i,n) for(ll i=0;i<n;i++)
#define rf(i,n) for(ll i=n-1;i>=0;i--)
//Comment this while submitting as it might cause TLE
//It will change the WA from Integer Overflow to RE.
//#pragma GCC optimize "trapv"
using namespace std;
ll countDigits(ll n){ ll dig = floor(log10(n)+1);  return dig;}

int main(){
    FAST;
    ll t;
    cin >>t;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll rem=a-b;
        if(rem<=0){
            cout<<a<<"\n";
            continue;
        }
        if(d>=c){
            cout<<-1<<"\n";
            continue;
        }
        ll ans=b;
        ans += c * floor((a-b)/(c-d));
        if((a-b)%(c-d)!=0)
            ans+=c;
        cout<<ans<<"\n";
    }
}


#include<iostream>
#include <iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define mod 1000000007
#define pi 3.14159265358979323846
#define fo(i,n) for(ll i=0;i<n;i++)
#define rf(i,n) for(ll i=n-1;i>=0;i--)
//Comment this while submitting as it might cause TLE
//It will change the WA from Integer Overflow to RE.
//#pragma GCC optimize "trapv"
using namespace std;
ll countDigits(ll n){ ll dig = floor(log10(n)+1);  return dig;}

int main(){
    FAST;
    ll t;
    cin >>t;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll rem=a-b;
        if(rem<=0){
            cout<<b<<"\n";
            continue;
        }
        if(d>=c){
            cout<<-1<<"\n";
            continue;
        }
        ll ans=b;
        ans += c * floor((a-b)/(c-d));
        if((a-b)%(c-d)!=0)
            ans+=c;
        cout<<ans<<"\n";
    }
}


#include<iostream>
#include <iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define mod 1000000007
#define pi 3.14159265358979323846
#define fo(i,n) for(ll i=0;i<n;i++)
#define rf(i,n) for(ll i=n-1;i>=0;i--)
//Comment this while submitting as it might cause TLE
//It will change the WA from Integer Overflow to RE.
//#pragma GCC optimize "trapv"
using namespace std;
ll countDigits(ll n){ ll dig = floor(log10(n)+1);  return dig;}

int main(){
    FAST;
    ll t;
    cin >>t;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll rem=a-b;
        if(rem<=0){
            cout<<a<<"\n";
            continue;
        }
        if(d>=c){
            cout<<-1<<"\n";
            continue;
        }
        ll ans=b,tot_sleep=b;
        while(tot_sleep<a){
            ans+=c;
            tot_sleep+=(c-d);
        }
        //ans+=rem+d;
        cout<<ans<<"\n";
    }
}


#include<iostream>
#include <iomanip>
#include<cstdlib>
#include<string>
#include<cmath>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define mod 1000000007
#define pi 3.14159265358979323846
#define fo(i,n) for(ll i=0;i<n;i++)
#define rf(i,n) for(ll i=n-1;i>=0;i--)
//Comment this while submitting as it might cause TLE
//It will change the WA from Integer Overflow to RE.
//#pragma GCC optimize "trapv"
using namespace std;
ll countDigits(ll n){ ll dig = floor(log10(n)+1);  return dig;}

int main(){
    FAST;
    ll t;
    cin >>t;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        ll rem=a-b;
        if(rem<=0){
            cout<<b<<"\n";
            continue;
        }
        if(d>=c){
            cout<<-1<<"\n";
            continue;
        }
        ll ans=b,tot_sleep=b;
        while(tot_sleep<a){
            ans+=c;
            tot_sleep+=(c-d);
        }
        //ans+=rem+d;
        cout<<ans<<"\n";
    }
}


#include<bits/stdc++.h>

using namespace std;

int main() {
	int Q;
	cin >> Q;
	while (Q--) {
		long long A, B, C, D;
		cin >> A >> B >> C >> D;
		if (B >= A) {
			cout << B << endl;
		}
		else {
			if (C <= D) {
				cout << -1 << endl;
			}
			else {
				long long rem = A - B;
				long long rept = (rem + (C - D) - 1) / (C - D);
				cout << B + rept * C << endl;
			}
		}
	}
	return 0;
}


 #include<bits/stdc++.h>
 using namespace std;
 int main(){
    int t;
    cin>>t;
    while(t--){
        double a,b,c,d;
        cin>>a>>b>>c>>d;
        double x=((a-b)/(c-d));
        //cout<<ceil(x)<<endl;
        if(x=>&& x<=1) cout<<b<<endl;
        else if(x<0) cout<<-1<<endl;

        else cout<<b+(ceil(x)*c)<<endl;
    }

 return 0;

 }


 #include<bits/stdc++.h>
 using namespace std;
 int main(){
    int t;
    cin>>t;
    while(t--){
        double a,b,c,d;
        cin>>a>>b>>c>>d;
        double x=((a-b)/(c-d));
        //cout<<ceil(x)<<endl;
        if(x==0 || x==1) cout<<b<<endl;
        else if(x<0) cout<<-1<<endl;

        else cout<<b+(ceil(x)*c)<<endl;
    }

 return 0;

 }


#include<bits/stdc++.h>
 using namespace std;
 int main(){
    int t;
    cin>>t;
    while(t--){
        double a,b,c,d;
        cin>>a>>b>>c>>d;
        double x=((a-b)/(c-d));
        if((a-b==0)&&(c-d==0)) cout<<a<<endl;
        else if(x<0) cout<<-1<<endl;
        else if(ceil(x)==1) cout<<b<<endl;
        else cout<<b+(ceil(x)*c)<<endl;

    }

 return 0;

 }


#include<bits/stdc++.h>
 using namespace std;
 int main(){
    int t;
    cin>>t;
    while(t--){
        double a,b,c,d;
        cin>>a>>b>>c>>d;
        long double x=((a-b)/(c-d));
        if((a-b==0)&&(c-d==0)) cout<<a<<endl;
        else if(x<0) cout<<-1<<endl;
        else if(ceil(x)==1) cout<<b<<endl;
        else cout<<fixed<<setprecision(0)<<b+(ceil(x)*c)<<endl;

    }

 return 0;

 }


#inlcude<bits/stdc++.h>

using namespace std;
int main() {
	int Q;
	cin >> Q;
	while (Q--) {
		long long A, B, C, D;
		cin >> A >> B >> C >> D;
		if (B >= A) {
			cout << B << endl;
		}
		else {
			if (C <= D) {
				cout << -1 << endl;
			}
			else {
				long long rem = A - B;
				long long rept = (rem + (C - D) - 1) / (C - D);
				cout << B + rept * C << endl;
			}
		}
	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long double
#define pb                      push_back
#define MOD                     1000000007
#define endl                    "\n"

using namespace std;
int main() {
		ll t;
	cin >> t;
	while(t--)
	{
	  ll a, b, c, d;
	  cin>>a>>b>>c>>d;
	  if(d>c && b<a)
	 { cout<<-1<<endl;
	  continue;
	 }
	 else
	 {
	     ll e= a-b;
	     if(e<=0)
	     {
	         cout<<b<<endl;
	         continue;
	     }
	     else
	     {
	         ll f= c-d;
	         ll g= ceil(e/f);
	         ll h= a+ g*c;
	         cout<<h<<endl;
	         continue;
	     }
	 }
	}
}


#include <bits/stdc++.h>
#define ll long double
#define pb                      push_back
#define MOD                     1000000007
#define endl                    "\n"

using namespace std;
int main() {
		ll t;
	cin >> t;
	while(t--)
	{
	  ll a, b, c, d;
	  cin>>a>>b>>c>>d;
	  if(d>c && b<a)
	 { cout<<-1<<endl;
	  continue;
	 }
	 else
	 {
	     ll e= a-b;
	     if(e<=0)
	     { long long int j= (long long int)b;
	         cout<<j<<endl;
	         continue;
	     }
	     else
	     {
	         ll f= c-d;
	         ll g= ceil(e/f);
	         ll h= b+ g*c;
	        //long long int i = (long long int) h;
	         cout<<h<<endl;
	         continue;
	     }
	 }
	}
}


#include <bits/stdc++.h>
#define ll double
#define pb                      push_back
#define MOD                     1000000007
#define endl                    "\n"

using namespace std;
int main() {
		ll t;
	cin >> t;
	while(t--)
	{
	  ll a, b, c, d;
	  cin>>a>>b>>c>>d;
	  if(d>c && b<a)
	 { cout<<-1<<endl;
	  continue;
	 }
	 else
	 {
	     ll e= a-b;
	     if(e<=0)
	     { int j= (int)b;
	         cout<<j<<endl;
	         continue;
	     }
	     else
	     {
	         ll f= c-d;
	         ll g= ceil(e/f);
	         ll h= b+ g*c;
	        int i = (int) h;
	         cout<<i<<endl;
	         continue;
	     }
	 }
	}
}


#include <bits/stdc++.h>
#define ll long long
#define pb                      push_back
#define MOD                     1000000007
#define endl                    "\n"

using namespace std;
int main() {
		ll t;
	cin >> t;
	while(t--)
	{
	  ll a, b, c, d;
	  cin>>a>>b>>c>>d;
	  if(d>c)
	 { cout<<-1<<endl;
	  continue;
	 }
	 else
	 {
	     ll e= a-b;
	     if(e<=0)
	     {
	         cout<<b<<endl;
	         continue;
	     }
	     else
	     {
	         ll f= d-c;
	         ll g= ceil(e/f);
	         ll h= a+ g*c;
	         cout<<h<<endl;
	         continue;
	     }
	 }
	}
}


#include <bits/stdc++.h>
#define ll long double
#define pb                      push_back
#define MOD                     1000000007
#define endl                    "\n"

using namespace std;
int main() {
		ll t;
	cin >> t;
	while(t--)
	{
	  ll a, b, c, d;
	  cin>>a>>b>>c>>d;
	  if(d>c && b<a)
	 { cout<<-1<<endl;
	  continue;
	 }
	 else
	 {
	     ll e= a-b;
	     if(e<=0)
	     { long long int j= (long long int)b;
	         cout<<j<<endl;
	         continue;
	     }
	     else
	     {
	         ll f= c-d;
	         ll g= ceil(e/f);
	         ll h= b+ g*c;
	        long long int i = (long long int) h;
	         cout<<i<<endl;
	         continue;
	     }
	 }
	}
}


#include <bits/stdc++.h>
#define ll long double
#define pb                      push_back
#define MOD                     1000000007
#define endl                    "\n"

using namespace std;
int main() {
		ll t;
	cin >> t;
	while(t--)
	{
	  ll a, b, c, d;
	  cin>>a>>b>>c>>d;
	  if(d>c && b<a)
	 { cout<<-1<<endl;
	  continue;
	 }
	 else
	 {
	     ll e= a-b;
	     if(e<=0)
	     { int j= (int)b;
	         cout<<j<<endl;
	         continue;
	     }
	     else
	     {
	         ll f= c-d;
	         ll g= ceil(e/f);
	         ll h= a+ g*c;
	        int i = (int) h;
	         cout<<i<<endl;
	         continue;
	     }
	 }
	}
}


#include <bits/stdc++.h>
#define ll long long int
#define pb                      push_back
#define MOD                     1000000007
#define endl                    "\n"

using namespace std;
int main() {
		ll t;
	cin >> t;
	while(t--)
	{
	  ll a, b, c, d;
	  cin>>a>>b>>c>>d;
	  if(d>c && b<a)
	 { cout<<-1<<endl;
	  continue;
	 }
	 else
	 {
	     ll e= a-b;
	     if(e<=0)
	     { //long long int j= (long long int)b;
	         cout<<b<<endl;
	         continue;
	     }
	     else
	     {
	         ll f= c-d;
	         if(f==0)
	      {   cout<<-1<<endl;
	         continue;
	     }
	         ll g= (e/f);
	         if(e%f!=0)
	         g = g+1;
	         ll h= b+ g*c;
	        //long long int i = (long long int) h;
	         cout<<h<<endl;
	         continue;
	     }
	 }
	}
}


#include <bits/stdc++.h>
#define ll long double
#define pb                      push_back
#define MOD                     1000000007
#define endl                    "\n"

using namespace std;
int main() {
		ll t;
	cin >> t;
	while(t--)
	{
	  ll a, b, c, d;
	  cin>>a>>b>>c>>d;
	  if(d>c && b<a)
	 { cout<<-1<<endl;
	  continue;
	 }
	 else
	 {
	     ll e= a-b;
	     if(e<=0)
	     { long long int j= (long long int)b;
	         cout<<j<<endl;
	         continue;
	     }
	     else
	     {
	         ll f= c-d;
	         if(f==0)
	       {  cout<<-1<<endl;
	         continue;
	     }
	         ll g= ceil(e/f);
	         ll h= b+ g*c;
	        //long long int i = (long long int) h;
	         cout<<h<<endl;
	         continue;
	     }
	 }
	}
}


#include <bits/stdc++.h>
#define ll long long
#define pb                      push_back
#define MOD                     1000000007
#define endl                    "\n"

using namespace std;
int main() {
		ll t;
	cin >> t;
	while(t--)
	{
	  ll a, b, c, d;
	  cin>>a>>b>>c>>d;
	  if(d>c)
	 { cout<<-1<<endl;
	  continue;
	 }
	 else
	 {
	     ll e= a-b;
	     if(e<=0)
	     {
	         cout<<b<<endl;
	         continue;
	     }
	     else
	     {
	         ll f= c-d;
	         ll g= ceil(e/f);
	         ll h= a+ g*c;
	         cout<<h<<endl;
	         continue;
	     }
	 }
	}
}


#include <bits/stdc++.h>
#define ll double
#define pb                      push_back
#define MOD                     1000000007
#define endl                    "\n"

using namespace std;
int main() {
		ll t;
	cin >> t;
	while(t--)
	{
	  ll a, b, c, d;
	  cin>>a>>b>>c>>d;
	  if(d>c && b<a)
	 { cout<<-1<<endl;
	  continue;
	 }
	 else
	 {
	     ll e= a-b;
	     if(e<=0)
	     {
	         cout<<b<<endl;
	         continue;
	     }
	     else
	     {
	         ll f= c-d;
	         ll g= ceil(e/f);
	         ll h= a+ g*c;
	        int i = (int) h
	         cout<<i<<endl;
	         continue;
	     }
	 }
	}
}