/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
#include<string.h>
#include<vector>
using namespace std;
typedef long long ll;
const ll a = 11289;
const ll b = 40961;
const ll p = 233333333;
const ll q = 998244353;
struct edgee
{
	int to;
};
struct diann
{
	ll hashvalue;
	char namee[11];
};
edgee edge[2][200200];
diann dian[2][100100];
map<string, int>name[2];
int n, edgetot[2];
char aa[20], bb[20];
int nametot[2];
int first[2][100200], nextt[2][200200];
void addedge(int from, int to, int kind)
{
	edge[kind][edgetot[kind]].to = to;
	nextt[kind][edgetot[kind]] = first[kind][from];
	first[kind][from] = edgetot[kind]++;
	edge[kind][edgetot[kind]].to = from;
	nextt[kind][edgetot[kind]] = first[kind][to];
	first[kind][to] = edgetot[kind]++;
}
int read(char *aa, int kind)
{
	if (name[kind][aa] == 0)
	{
		strcpy(dian[kind][nametot[kind]].namee, aa);
		name[kind][aa] = nametot[kind]++;
	}
	return name[kind][aa];
}
bool visit[2][100100], isinstack[2][100100];
bool visitroot[2][2];
ll hashvaluee[2][100100], temphash[100100];
int du[2][100100], height[2][100100];
int root[2][2],maxheight;
int son[2][100020];
vector<int>parent[2][100010];
void gethash(int kind)
{
	queue<int>que; maxheight = -1;
	for (int i = 1; i <nametot[kind]; i++)
	{
		visit[kind][i] = 0; isinstack[kind][i] = 0;
		if (du[kind][i] == 1)
		{
			height[kind][i] = 1;
			hashvaluee[kind][i] = 1;
			que.push(i);
		}
	}
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		visit[kind][now] = 1;
		int all = -1;
		for (int i = first[kind][now]; i != -1; i = nextt[kind][i])
		{
			int to = edge[kind][i].to;
			if (visit[kind][to] == 1&&height[kind][to]==height[kind][now]-1)
				temphash[++all] = hashvaluee[kind][to];
			else
			{
				if (isinstack[kind][to] == 0)
				{
					que.push(to);
					isinstack[kind][to] = 1;
					height[kind][to] = height[kind][now] + 1;
				}
			}
		}
		if (all != -1)
		{
			all++;
			sort(temphash, temphash + all);
			hashvaluee[kind][now] = (a*p) % q;
			for (int i = 0; i < all; i++)
			{
				hashvaluee[kind][now] = (hashvaluee[kind][now] * p^temphash[i]) % q;
			}
			hashvaluee[kind][now] = (hashvaluee[kind][now] * b) % q;
		}
		if (height[kind][now] > maxheight)
		{
			root[kind][0] = now; root[kind][1] = -1;
			maxheight = height[kind][now];
		}
		else
		{
			if (height[kind][now] == maxheight)
			{
				root[kind][1] = now;
				if (hashvaluee[kind][root[kind][1]] < hashvaluee[kind][root[kind][0]])
					swap(root[kind][0], root[kind][1]);
			}
		}
		}
		}
		bool com1(int a, int b)
		{
		return hashvaluee[0][a] < hashvaluee[0][b];
		}
		bool com2(int a, int b)
		{
		return hashvaluee[1][a] < hashvaluee[1][b];
		}
		void print(int l, int r,int fal,int far)
		{
		if (l == -1 || r == -1)
		return;
		printf("%s %s\n", dian[0][l].namee, dian[1][r].namee);
		int alll = -1,allr=-1;
		for (int i = first[0][l]; i != -1; i = nextt[0][i])
		{
		if (edge[0][i].to!=fal&&edge[0][i].to!=root[0][0]&&edge[0][i].to!=root[0][1])
		son[0][++alll]=edge[0][i].to;
		}
		sort(son[0], son[0] + alll+1, com1);
		for (int i = 0; i <=alll; i++)
		parent[0][l].push_back(son[0][i]);
		for (int i = first[1][r]; i != -1; i = nextt[1][i])
		{
		if (edge[1][i].to != far&&edge[1][i].to!=root[1][0]&&edge[1][i].to!=root[1][1]);
		son[1][++allr] = edge[1][i].to;
		}
		sort(son[1], son[1] + allr+1, com2);
		for (int i = 0; i <=allr; i++)
		parent[1][r].push_back(son[1][i]);
		for (int i = 0; i <=alll; i++)
		{
		int ll = parent[0][l][i]; int rr = parent[1][r][i];
		print(ll, rr,l,r);
		}
		}
		int main()
		{
		while (scanf("%d", &n))
		{
		nametot[0] = 1; nametot[1] = 1;
		name[0].clear(); name[1].clear();
		root[0][0] = root[0][1] = root[1][0] = root[1][1] = -1;
		visitroot[0][0] = visitroot[0][1] = visitroot[1][0] =visitroot[1][1] = 0;
		for (int i = 0; i <= n; i++)
		first[0][i] = -1, first[1][i] = -1,
		parent[0][i].clear(), parent[1][i].clear(),
		du[0][i]=du[1][i]=0;
		for (int i = 1; i < n; i++)
		{
		scanf("%s%s", aa, bb);
		int a1 = read(aa, 0);
		int b1 = read(bb, 0);
		addedge(a1, b1, 0);
		du[0][a1]++, du[0][b1]++;
		}
		for (int i = 1; i < n; i++)
		{
		scanf("%s%s", aa, bb);
		int a2 = read(aa, 1);
		int b2 = read(bb, 1);
		addedge(a2, b2, 1);
		du[1][a2]++, du[1][b2]++;
		}
		gethash(0);
		gethash(1);
		for (int i = 0; i < 2; i++)
		{
		if (root[0][i] == -1)break;
		print(root[0][i], root[1][i],-1,-1);
		}
		}
		}*/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
	int value;
	bool issame;
	int samevalue;
};
node tree[600000];
int a1[100010], b1[100010];
int choose[20][100010];
int a, b, C, M, last;
int n, m, A, B;
int rand(int last)
{
	a = (36969 + (last >> 3))*(a&M) + (a >> 16);
	b = (18000 + (last >> 3))*(b&M) + (b >> 16);
	return (C&((a << 16) + b)) % 1000000000;
}
int getrank(int l, int r, int h, int value)
{
	while (l < r)
	{
		int mid = (l + r) / 2+1;
		if (choose[h][mid] <= mid)
			l = mid;
		else
			r = mid - 1;
	}
	return l;
}
void pushup(int k)
{
	tree[k].value = tree[k << 1].value + tree[k << 1 | 1].value;
}
void pushdown(int k, int h, int l, int r)
{
	if (tree[k].issame)
	{
		tree[k << 1].issame = 1;
		tree[k << 1 | 1].issame = 1;
		tree[k].issame = 0;
		tree[k << 1].samevalue = tree[k].samevalue;
		tree[k << 1 | 1].samevalue = tree[k].samevalue;
		int mid = (l + r) / 2;
		int l1 = getrank(l, mid, h + 1, tree[k].samevalue);
		int l2 = getrank(mid + 1, r, h + 1, tree[k].samevalue);
		if (l1 == l)
			tree[k << 1].value = tree[k << 1].samevalue >= choose[h + 1][l] ? 1 : 0;
		else
			tree[k << 1].value = l1 - l + 1;
		if (l2 == mid + 1)
			tree[k << 1 | 1].value = tree[k << 1 | 1].samevalue >= choose[h + 1][mid + 1] ? 1 : 0;
		else
			tree[k << 1 | 1].value = l2 - mid - 1 + 1;
	}
}
void build(int l, int r, int k, int h)
{
		if (l == r)
		{
			tree[k].value = a1[l] >= b1[l] ? 1 : 0;
			return;
		}
		int mid = (l + r) / 2;
		build(l, mid, k << 1, h + 1);
		build(mid + 1, r, k << 1 | 1, h + 1);
		int l1 = l;
		int l2 = mid + 1;
		int kk = l;
		while (l1 <= mid&&l2 <= r)
		{
			if (choose[h + 1][l1] <= choose[h + 1][l2])
				choose[h][kk++] = choose[h + 1][l1++];
			else
				choose[h][kk++] = choose[h + 1][l2++];
		}
			while (l1 <= mid)
				choose[h][kk++] = choose[h + 1][l1++];
			while (l2 <= r)
				choose[h][kk++] = choose[h + 1][l2++];
			pushup(k);
}
void same(int l, int r, int ll, int rr, int k, int value, int h)
{
	if (ll>=l&&rr<=r)
	{
		int rank = getrank(ll, rr, h, value);
		if (rank == ll)
			tree[k].value = value >= choose[h][ll] ? 1 : 0;
		else
			tree[k].value = rank - ll + 1;
		tree[k].issame = 1;
		tree[k].samevalue = value;
		return;
	}
	else
	{
		pushdown(k, h, ll, rr);
		int mid = (ll + rr) / 2;
		if (mid >= l)same(l, r, ll, mid, k << 1, value, h + 1);
		if (mid+1<= r)same(l, r, mid + 1, rr, k << 1 | 1, value, h + 1);
		pushup(k);
	}
}
int getsum(int l, int r, int ll, int rr, int k, int h)
{
	if (ll >= l&&rr <= r)
	{
		return tree[k].value;
	}
	else
	{
		pushdown(k, h, ll, rr);
		int mid = (ll + rr) / 2;
		int l1 = 0, l2 = 0;
		if (mid >= l)l1 = getsum(l, r, ll, mid, k << 1, h + 1);
		if (mid + 1 <= rr)l2 = getsum(l, r, mid + 1, rr, k << 1 | 1, h + 1);
		return l1 + l2;
	}
}
int main()
{
	while (scanf("%d%d%d%d", &n, &m, &A, &B) != EOF)
	{
		a = A, b = B, C = ~(1 << 31), M = (1 << 16) - 1,last=0;
		for (int i = 1; i <= n; i++)
			scanf("%d", &a1[i]);
		for (int i = 1; i <= n; i++)
			scanf("%d", &b1[i]);
		build(1, n, 1, 0);
		while (m--)
		{
			int l, r, x;
			l = rand(last)%n+1; r = rand(last)%n+1; x = rand(last)%n+1;
			if (l > r)swap(l, r);
			if ((l + r + x) % 2 == 0)
			{
				int valuee = getsum(l, r, 1, n, 1, 0);
				last = valuee;
				printf("%d\n", valuee);
			}
			else
			{
				same(l, r, 1, n, 1, x, 0);
			}
		}
	}
}*/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<string.h>
using namespace std;
bitset<100001>dp[2][3], mode[26];
char a[100010], b[5020];
int n, m, t;
int main()
{
//	//dp[0][0][0] = 1;
	//dp[1][0][0] = 1;
	//dp[0][0]=dp[0][0] << 1;
	//dp[1][0] = dp[0][0] | dp[1][0];
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d%d", &n, &m);
		for (int i = 0; i < 26; i++)
			mode[i].reset();
		for (int i = 0; i < 2; i++)
			for (int j = 0; j < 3; j++)
				dp[i][j].reset();
		scanf("%s%s", a, b);
		int lena =n;
		int lenb =m;
		for (int i = 0; i < lena; i++)
		{
			int kind = a[i] - 'a';
			mode[kind][i] = 1;
		}
		dp[1][1] = mode[b[0] - 'a'];
		if (lenb>=2)
		dp[1][2] = mode[b[1] - 'a'];
		b[lenb] = 'a';
		int cnt = 0;
		for (int i = 1; i < lenb; i++)
		{
				dp[cnt][0] = (dp[cnt ^ 1][2] << 1)&mode[b[i - 1] - 'a'];
			dp[cnt][1] = (((dp[cnt ^ 1][1] |dp[cnt ^ 1][0])<<1)&mode[b[i] - 'a']);
	dp[cnt][2] = (((dp[cnt ^ 1][0]|dp[cnt ^ 1][1]) << 1)&mode[b[i + 1] - 'a']);

			cnt ^= 1;
		}
		cnt ^= 1;
		for (int i = 0; i<=n-1; i++)
			if (dp[cnt][0][i + lenb - 1] | dp[cnt][1][i + lenb - 1] && i <= n - 1 - lenb + 1)
				printf("1");
			else
				printf("0");
		printf("\n");
	}
}*/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int t;
int a[1010];
int main()
{
	while (scanf("%d", &t) != EOF)
	{
		for (int i = 0; i < t; i++)
			scanf("%d", &a[i]);
		double sum1 = 0, sum2 = 0;
		sum1 = a[0] + a[t - 1];
		sum1 /= 2;
		for (int i = 1; i < t - 1; i++)
			sum2 += a[i];
		sum2 /= 3;
		printf("%.6llf\n", sum1 + sum2);
	}
	return 0;
}*/
//hdu5762
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
using  namespace std;
typedef long long ll;
struct nodee
{
	int son[26];
	int fa,pos,maxx;
	//char value;
};
nodee tree[300200];
int t,tot;
char s[100100];
char cc[10];
int maxx,noww;
void insert(char c)
{
	int tempp = noww;
	noww = tot;
	if (c== cc[0])
	{
		tree[noww].pos = maxx;
	}
	//tree[noww].value = c;
	int kind = c - 'a';
	if (tree[noww].pos == 0)
		tree[noww].pos = tree[tempp].pos;
	tree[noww].maxx = maxx;
	while (tempp&&tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tempp=tree[tempp].fa;
	if (tempp == 0 && tree[tempp].son[kind]==0)
		tree[tempp].son[kind] = noww,
	    tree[noww].fa = tempp;
	else
	{
			int nextt = tree[tempp].son[kind];
			if (tree[nextt].maxx - 1 == tree[tempp].maxx)
				tree[noww].fa = nextt;
			else
			{
				int neww = ++tot;
				tree[neww] = tree[nextt];
				tree[neww].maxx = tree[tempp].maxx + 1;
				if (tree[nextt].maxx == tree[nextt].pos)
					tree[neww].pos = tree[tempp].maxx + 1;
				else
					tree[neww].pos = tree[tempp].pos;
				while (tempp&&tree[tempp].son[kind] == nextt)
					tree[tempp].son[kind] = neww;
				if (tempp == 0 && tree[tempp].son[kind] == nextt)
					tree[tempp].son[kind] = neww;
				tree[noww].fa = neww; tree[nextt].fa = neww;
			}
	}
	tot++;
	maxx++;
}
int main()
{
	scanf("%d", &t);
	int k = 1;
	while (t--)
	{
		for (int i = 0; i <=tot; i++)for (int j = 0; j < 26; j++)tree[i].son[j] = 0, tree[i].fa = 0, tree[i].pos = 0,tree[i].maxx=0;
		tot = 1; maxx = 1; noww = 0;
		scanf("%s", cc);
		scanf("%s", s);
		//cc[0] = (rand() % 26) + 'a';
		//for (int i = 0; i < 100000; i++)
			//s[i] = (rand() % 26) + 'a';
		int len = strlen(s);
		//len = 100000;
		for (int i = 0; i < len; i++)
		{
			insert(s[i]);
		}
		ll sum = 0;
		for (int i = tot - 1; i >= 1; i--)
		{
			int fa = tree[i].fa;
			sum += min(tree[i].maxx - tree[fa].maxx, tree[i].pos);
		}
		printf("Case #%d: %lld\n",k++,sum);
	}
}/**/

/*#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
const int MAXN = 100010;
int t1[MAXN], t2[MAXN], c[MAXN];//��SA������Ҫ���м����������Ҫ��ֵ
//��������ַ�������s�����У���s[0]��s[n-1],����Ϊn,�����ֵС��m,
//��s[n-1]�������s[i]������0��r[n-1]=0
//���������Ժ�������sa������
//sa[1~n]->[0,N] rank[0~n-1]->[1,N]  height[1~n]
bool cmp(int *r, int a, int b, int l)
{
	return r[a] == r[b] && r[a + l] == r[b + l];
}
void da(int str[], int sa[], int Rank[], int height[], int n, int m)
{
	n++;
	int i, j, p, *x = t1, *y = t2;
	//��һ�ֻ����������s�����ֵ�ܴ󣬿ɸ�Ϊ��������
	for (i = 0; i < m; i++)c[i] = 0;
	for (i = 0; i < n; i++)c[x[i] = str[i]]++;
	for (i = 1; i < m; i++)c[i] += c[i - 1];
	for (i = n - 1; i >= 0; i--)sa[--c[x[i]]] = i;
	for (j = 1; j <= n; j <<= 1)
	{
		p = 0;
		//ֱ������sa��������ڶ��ؼ���
		for (i = n - j; i < n; i++)y[p++] = i;//�����j�����ڶ��ؼ���Ϊ�յ���С
		for (i = 0; i < n; i++)if (sa[i] >= j)y[p++] = sa[i] - j;
		//��������y����ľ��ǰ��յڶ��ؼ�������Ľ��
		//���������һ�ؼ���
		for (i = 0; i < m; i++)c[i] = 0;
		for (i = 0; i < n; i++)c[x[y[i]]]++;
		for (i = 1; i < m; i++)c[i] += c[i - 1];
		for (i = n - 1; i >= 0; i--)sa[--c[x[y[i]]]] = y[i];
		//����sa��x��������µ�x����
		swap(x, y);
		p = 1; x[sa[0]] = 0;
		for (i = 1; i < n; i++)
			x[sa[i]] = cmp(y, sa[i - 1], sa[i], j) ? p - 1 : p++;
		if (p >= n)break;
		m = p;//�´λ�����������ֵ
	}
	int k = 0;
	n--;
	for (i = 0; i <= n; i++)Rank[sa[i]] = i;
	for (i = 0; i < n; i++)
	{
		if (k)k--;
		j = sa[Rank[i] - 1];
		while (str[i + k] == str[j + k])k++;
		height[Rank[i]] = k;
	}
}
int Rank[MAXN], height[MAXN];

char str[MAXN];
char X[3];
int r[MAXN];
int sa[MAXN];
int nxt[MAXN];

int main(){
	int T;
	scanf("%d", &T);
	for (int cs = 1; cs <= T; cs++) {
		//X[0]= (rand() % 26) + 'a';
		//for (int i = 0; i < 100000; i++)
			//str[i] = (rand() % 26) + 'a';
		scanf("%s%s", X, str);
		int n = strlen(str);
		//n = 100000;
		int temp = n;
		for (int i = n - 1; i >= 0; i--) {
			if (str[i] == X[0]) temp = i;
			nxt[i] = temp;

		}
		for (int i = 0; i < n; i++) r[i] = str[i];
		r[n] = 0;
		da(r, sa, Rank, height, n, 128);
		ll ans = 0;
		for (int i = 1; i <= n; i++) {
			//printf("%d %d %d\n",nxt[sa[i]], sa[i] , height[i]);
			ans += n - max(nxt[sa[i]], sa[i] + height[i]);
		}
		printf("Case #%d: %I64d\n", cs, ans);
	}
	return 0;
}/**/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long ll;
struct nodee
{
	int son[26];
	int maxx,fa;
};
nodee tree[2000200];
char s[1000100];
int tot, maxx, tempp,noww;
void insert(char c)
{
	tree[tot].maxx = maxx;
	tempp = noww;
	noww = tot;
	int kind = c - 'a';
	while (tempp&&tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tempp=tree[tempp].fa;
	if (tempp == 0 && tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tree[noww].fa = tempp;
	else
	{
		int nextt = tree[tempp].son[kind];
		if (tree[nextt].maxx - 1 == tree[tempp].maxx)
			tree[noww].fa = nextt;
		else
		{
			int neww = ++tot;
			tree[neww] = tree[nextt];
			tree[neww].maxx = tree[tempp].maxx + 1;
			tree[noww].fa = neww; tree[nextt].fa = neww;
			while (tree[tempp].son[kind] == nextt)
			{
				tree[tempp].son[kind] = neww;
				if (tempp == 0)break;
				tempp = tree[tempp].fa;
			}
		}
	}
	tot++, maxx++;
}
int main()
{
	tot = 1; noww = 0; maxx = 1;
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 0; i < len; i++)
	{
		insert(s[i]);
	}
	ll ans = 0;
	for (int i = tot - 1; i >= 1; i--)
	{
		int fa = tree[i].fa;
		ans += tree[i].maxx - tree[fa].maxx;
	}
	printf("%lld\n", ans);
	return 0;
}/**/
//hihocoder 1449
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<queue>
using namespace std;
typedef long long ll;
struct nodee
{
	int maxl, maxr,fa;
	ll amount;
	int son[26];
	char vv;
};
struct lenth
{
	ll to, value;
};
lenth realvalue[1000200];
nodee tree[2000200];
int maxx, tot, noww, tempp;
char s[1000200];
int to[2000200];
void insert(char cc)
{
	tempp = noww;
	noww = tot;
	tree[noww].maxr = maxx;
	tree[noww].amount = 1;
	tree[noww].vv = cc;
	int kind = cc - 'a';
	while (tempp&&tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tempp = tree[tempp].fa;
	if (tempp == 0 && tree[tempp].son[kind] == 0)
	{
		tree[tempp].son[kind] = noww;
		tree[noww].fa = tempp;
	}
	else
	{
		int nextt = tree[tempp].son[kind];
		if (tree[nextt].maxr - tree[tempp].maxr == 1)
		{
			tree[noww].fa = nextt;
		}
		else
		{
			int neww = ++tot;
			tree[neww] = tree[nextt];
			tree[neww].amount = 0;
			tree[neww].maxr = tree[tempp].maxr + 1;
			tree[nextt].fa = neww; tree[noww].fa = neww;
			while (tree[tempp].son[kind] == nextt)
			{
				tree[tempp].son[kind] = neww;
				if (tempp == 0)break;
				tempp = tree[tempp].fa;
			}
		}
	}
	tot++;
	maxx++;
}
queue<int>que;
bool visit[2000200];
void getsum()
{
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		int fa = tree[now].fa;
		tree[fa].amount+=tree[now].amount;
		if (visit[fa] == 0)
		{
			visit[fa] = 1;
			if (fa)
			que.push(fa);
		}
	}
}
bool com(nodee a, nodee b)
{
	return a.amount < b.amount;
}
int main()
{
	noww = 0; maxx = 1; tot = 1;
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 0; i < len; i++)
	{
		insert(s[i]);
	}
	for (int i = tot - 1; i >= 1; i--)
	{
		int fa = tree[i].fa;
		tree[i].maxl = tree[fa].maxr + 1;
		to[fa]++;
	}
	for (int i = tot - 1; i >= 1; i--)
	{
		if (to[i] == 0)
		{
			que.push(i);
		}
	}
	getsum();

	for (int i = 1; i < tot; i++)
	{
		int noww = tree[i].maxr;
		realvalue[noww].value = max(realvalue[noww].value, tree[i].amount);
	}
	for (int i = len-1; i >= 1; i--)
	{
		realvalue[i].value= max(realvalue[i].value, realvalue[i + 1].value);
	}
	for (int i = 1; i <= len; i++)
		printf("%lld\n", realvalue[i].value);
	return 0;
}/**/

/*sort(tree+1, tree + tot, com);
int amount = 0;
for (int i =tot-1; i>=1; i--)
{
if (amount == len)
break;
int l = tree[i].maxl;
int r = tree[i].maxr;
while (l <=r)
{
if (realvalue[l].value != 0)
{
l = realvalue[l].to + 1;
continue;
}
realvalue[l].to = r;
realvalue[l].value = tree[i].amount;
l++;
amount++;
}
}*/
/*#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 100;
const int M = 1e6 + 5;
int tot, slink[2 * N], trans[2 * N][26], minlen[2 * N], maxlen[2 * N], edpts[2 * N], n;
char str[2 * N];
int blue[2 * N], ind[2 * N], ans[2 * N + 10];
int newstate(int _maxlen, int _minlen, int* _trans, int _slink) {
	maxlen[++tot] = _maxlen;
	minlen[tot] = _minlen;
	slink[tot] = _slink;
	if (_trans)
		for (int i = 0; i<26; i++)
			trans[tot][i] = _trans[i];
	return tot;
}
int add(char ch, int u) {
	int c = ch - 'a', v = u;
	int z = newstate(maxlen[u] + 1, -1, NULL, 0);
	blue[z] = 1;//��ɫ
	while (v&&!trans[v][c]) {
		trans[v][c] = z;
		v = slink[v];
	}
	if (!v) {
		minlen[z] = 1;
		slink[z] = 1;
		ind[0]++;
		return z;
	}
	int x = trans[v][c];
	if (maxlen[v] + 1 == maxlen[x]) {
		slink[z] = x;
		minlen[z] = maxlen[x] + 1;
		ind[x]++;
		return z;
	}
	int y = newstate(maxlen[v] + 1, -1, trans[x], slink[x]);
	slink[z] = slink[x] = y;
	ind[y] += 2;
	minlen[x] = minlen[z] = maxlen[y] + 1;
	while (v&&trans[v][c] == x) {
		trans[v][c] = y;
		v = slink[v];
	}
	minlen[y] = maxlen[slink[y]] + 1;
	return z;
}
void count() {
	queue<int> q;
	for (int i = 1; i <= tot; i++)if (!ind[i]) {
		q.push(i);
	}
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		if (blue[u]) edpts[u]++;
		edpts[slink[u]] += edpts[u];
		if (!--ind[slink[u]]) q.push(slink[u]);
	}
}

int main() {
	int i;
	scanf("%s", str);
	int len = strlen(str), pre = 1;
	tot = 1;
	for (i = 0; i<len; i++) {
		pre = add(str[i], pre);
	}
	count();
	for (i = 0; i <= tot; i++){
		ans[maxlen[i]] = max(ans[maxlen[i]], edpts[i]);
	}
	for (i = tot; i>0; i--){
		ans[i] = max(ans[i], ans[i + 1]);
	}
	for (i = 1; i <= len; i++)printf("%d\n", ans[i]);
	return 0;
}/**/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
struct edgee
{
	int from, to;
	ll cap,tempcap;
	edgee(int a, int b, ll c) :from(a), to(b), cap(c)
	{}
	edgee()
	{}
};
edgee edge[1010];
int first[1010], nextt[1010];
int edgetot = 0;
int h[1010], num[1010],fa[1010],edgenum[1010];
int tfirst[1010];
bool isin[1010];
void addedge(int from, int to, ll cap)
{
	edge[edgetot] = edgee(from, to, cap);
	nextt[edgetot] = first[from];
	first[from] = edgetot++;
	edge[edgetot] = edgee(to, from, 0);
	nextt[edgetot] = first[to];
	first[to] = edgetot++;
}
int n, m, x;
bool endd;
void bfs(int t,int s)
{
	for (int i = 1; i <= n; i++)
		h[i] = 1000000000;
	h[t] = 0;
	num[0] = 1;
	queue<int>que;
	que.push(t);
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		for (int i = first[now]; i != -1; i = nextt[i])
		{
			int to = edge[i].to;
			if (h[to] != 1000000000)
				continue;
			h[to] =  h[now] + 1;
			num[h[to]]++;
			que.push(to);
		}
	}
}
void augument(int t,ll &mincap)
{
	for (int i = fa[t]; i; i = fa[i])
	{
		edge[edgenum[i]].tempcap -= mincap;
		edge[edgenum[i] ^ 1].tempcap += mincap;
	}
}
ll isap(int s,int t)
{
	int temp = s;
	ll capp = 100000000000000000;
	ll ans = 0;
	while (h[s] <n)
	{
		int tempp = temp;
		if (temp == t)
		{
			augument(temp, capp);
			ans += capp;
			temp =s;
			capp = 100000000000000000;
			continue;
		}
		for (int &i = first[temp]; i != -1; i = nextt[i])
		{
			int to = edge[i].to;
			if (h[to] == h[temp] - 1 && edge[i].tempcap > 0)
			{
				fa[to] = temp;
				edgenum[temp] = i;
				temp = to;
				capp = min(capp, edge[i].tempcap);
				break;
			}
		}
		if (tempp != temp)
			continue;
		num[h[temp]]--;
		if (num[h[temp]] == 0)
			break;
		int minh = 100000000;
		for (int j = tfirst[temp]; j != -1; j = nextt[j])
		{
			int to = edge[j].to;
			if (edge[j].tempcap > 0)
				minh = min(minh, h[to]);
		}
		first[temp] = tfirst[temp];
		if (minh != 100000000)
			h[temp] = minh+1;
		else
			h[temp] = 100000000;
		if (h[temp] != 100000000)
		num[h[temp]]++;
		if (temp != s)
			temp = fa[temp];
	}
	return ans;
}
ll solve(double k)
{
	for (int i = 0; i < edgetot; i++)
		edge[i].tempcap = (ll)(edge[i].cap / k);
	for (int i = 1; i <= n; i++)
		first[i] = tfirst[i],fa[i]=0,edgenum[i]=0;
	ll ans = 0;
	bfs(n, 1);
	ans += isap(1, n);
	return ans;
}
int main()
{
	scanf("%d%d%d", &n, &m, &x);
	for (int i = 0; i <= n; i++)
		first[i] = -1;
	for (int i = 0; i < m; i++)
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		addedge(a, b, c);
	}
	for (int i = 1; i <= n; i++)
		tfirst[i] = first[i];
	double l = 0;
	    double r = 1000000;
		double l1 = 0;
		double r1 = r;
		int t = 0;
	while ((r - l )> (1e-11))
	{
		t++;
		double mid = (l + r) / 2;
		if (solve(mid)>=x)
		{
			l = mid;
			//if (fabs(l - l1) <=1e-9)
				//break;
		}
		else
		{
			r = mid;
			//if (fabs(r - r1) <=1e-9)
				//break;
		}
		if (t >= 50)
			break;
	}
	printf("%.8lf\n", l*x);
	return 0;
	}/**/


/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
#include<string.h>
#include<vector>
using namespace std;
typedef long long ll;
const ll a = 11289;
const ll b = 40961;
const ll p = 233333333;
const ll q = 998244353;
struct edgee
{
	int to;
};
struct diann
{
	ll hashvalue;
	char namee[11];
};
edgee edge[2][200200];
diann dian[2][100100];
map<string, int>name[2];
int n, edgetot[2];
char aa[20], bb[20];
int nametot[2];
int first[2][100200], nextt[2][200200];
void addedge(int from, int to, int kind)
{
	edge[kind][edgetot[kind]].to = to;
	nextt[kind][edgetot[kind]] = first[kind][from];
	first[kind][from] = edgetot[kind]++;
	edge[kind][edgetot[kind]].to = from;
	nextt[kind][edgetot[kind]] = first[kind][to];
	first[kind][to] = edgetot[kind]++;
}
int read(char *aa, int kind)
{
	if (name[kind][aa] == 0)
	{
		strcpy(dian[kind][nametot[kind]].namee, aa);
		name[kind][aa] = nametot[kind]++;
	}
	return name[kind][aa];
}
bool visit[2][100100], isinstack[2][100100];
bool visitroot[2][2];
ll hashvaluee[2][100100], temphash[100100];
int du[2][100100], height[2][100100];
int root[2][2],maxheight;
int son[2][100020];
vector<int>parent[2][100010];
void gethash(int kind)
{
	queue<int>que; maxheight = -1;
	for (int i = 1; i <nametot[kind]; i++)
	{
		visit[kind][i] = 0; isinstack[kind][i] = 0;
		if (du[kind][i] == 1)
		{
			height[kind][i] = 1;
			hashvaluee[kind][i] = 1;
			que.push(i);
		}
	}
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		visit[kind][now] = 1;
		int all = -1;
		for (int i = first[kind][now]; i != -1; i = nextt[kind][i])
		{
			int to = edge[kind][i].to;
			if (visit[kind][to] == 1&&height[kind][to]==height[kind][now]-1)
				temphash[++all] = hashvaluee[kind][to];
			else
			{
				if (isinstack[kind][to] == 0)
				{
					que.push(to);
					isinstack[kind][to] = 1;
					height[kind][to] = height[kind][now] + 1;
				}
			}
		}
		if (all != -1)
		{
			all++;
			sort(temphash, temphash + all);
			hashvaluee[kind][now] = (a*p) % q;
			for (int i = 0; i < all; i++)
			{
				hashvaluee[kind][now] = (hashvaluee[kind][now] * p^temphash[i]) % q;
			}
			hashvaluee[kind][now] = (hashvaluee[kind][now] * b) % q;
		}
		if (height[kind][now] > maxheight)
		{
			root[kind][0] = now; root[kind][1] = -1;
			maxheight = height[kind][now];
		}
		else
		{
			if (height[kind][now] == maxheight)
			{
				root[kind][1] = now;
				if (hashvaluee[kind][root[kind][1]] < hashvaluee[kind][root[kind][0]])
					swap(root[kind][0], root[kind][1]);
			}
		}
		}
		}
		bool com1(int a, int b)
		{
		return hashvaluee[0][a] < hashvaluee[0][b];
		}
		bool com2(int a, int b)
		{
		return hashvaluee[1][a] < hashvaluee[1][b];
		}
		void print(int l, int r,int fal,int far)
		{
		if (l == -1 || r == -1)
		return;
		printf("%s %s\n", dian[0][l].namee, dian[1][r].namee);
		int alll = -1,allr=-1;
		for (int i = first[0][l]; i != -1; i = nextt[0][i])
		{
		if (edge[0][i].to!=fal&&edge[0][i].to!=root[0][0]&&edge[0][i].to!=root[0][1])
		son[0][++alll]=edge[0][i].to;
		}
		sort(son[0], son[0] + alll+1, com1);
		for (int i = 0; i <=alll; i++)
		parent[0][l].push_back(son[0][i]);
		for (int i = first[1][r]; i != -1; i = nextt[1][i])
		{
		if (edge[1][i].to != far&&edge[1][i].to!=root[1][0]&&edge[1][i].to!=root[1][1]);
		son[1][++allr] = edge[1][i].to;
		}
		sort(son[1], son[1] + allr+1, com2);
		for (int i = 0; i <=allr; i++)
		parent[1][r].push_back(son[1][i]);
		for (int i = 0; i <=alll; i++)
		{
		int ll = parent[0][l][i]; int rr = parent[1][r][i];
		print(ll, rr,l,r);
		}
		}
		int main()
		{
		while (scanf("%d", &n))
		{
		nametot[0] = 1; nametot[1] = 1;
		name[0].clear(); name[1].clear();
		root[0][0] = root[0][1] = root[1][0] = root[1][1] = -1;
		visitroot[0][0] = visitroot[0][1] = visitroot[1][0] =visitroot[1][1] = 0;
		for (int i = 0; i <= n; i++)
		first[0][i] = -1, first[1][i] = -1,
		parent[0][i].clear(), parent[1][i].clear(),
		du[0][i]=du[1][i]=0;
		for (int i = 1; i < n; i++)
		{
		scanf("%s%s", aa, bb);
		int a1 = read(aa, 0);
		int b1 = read(bb, 0);
		addedge(a1, b1, 0);
		du[0][a1]++, du[0][b1]++;
		}
		for (int i = 1; i < n; i++)
		{
		scanf("%s%s", aa, bb);
		int a2 = read(aa, 1);
		int b2 = read(bb, 1);
		addedge(a2, b2, 1);
		du[1][a2]++, du[1][b2]++;
		}
		gethash(0);
		gethash(1);
		for (int i = 0; i < 2; i++)
		{
		if (root[0][i] == -1)break;
		print(root[0][i], root[1][i],-1,-1);
		}
		}
		}*/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
	int value;
	bool issame;
	int samevalue;
};
node tree[600000];
int a1[100010], b1[100010];
int choose[20][100010];
int a, b, C, M, last;
int n, m, A, B;
int rand(int last)
{
	a = (36969 + (last >> 3))*(a&M) + (a >> 16);
	b = (18000 + (last >> 3))*(b&M) + (b >> 16);
	return (C&((a << 16) + b)) % 1000000000;
}
int getrank(int l, int r, int h, int value)
{
	while (l < r)
	{
		int mid = (l + r) / 2+1;
		if (choose[h][mid] <= mid)
			l = mid;
		else
			r = mid - 1;
	}
	return l;
}
void pushup(int k)
{
	tree[k].value = tree[k << 1].value + tree[k << 1 | 1].value;
}
void pushdown(int k, int h, int l, int r)
{
	if (tree[k].issame)
	{
		tree[k << 1].issame = 1;
		tree[k << 1 | 1].issame = 1;
		tree[k].issame = 0;
		tree[k << 1].samevalue = tree[k].samevalue;
		tree[k << 1 | 1].samevalue = tree[k].samevalue;
		int mid = (l + r) / 2;
		int l1 = getrank(l, mid, h + 1, tree[k].samevalue);
		int l2 = getrank(mid + 1, r, h + 1, tree[k].samevalue);
		if (l1 == l)
			tree[k << 1].value = tree[k << 1].samevalue >= choose[h + 1][l] ? 1 : 0;
		else
			tree[k << 1].value = l1 - l + 1;
		if (l2 == mid + 1)
			tree[k << 1 | 1].value = tree[k << 1 | 1].samevalue >= choose[h + 1][mid + 1] ? 1 : 0;
		else
			tree[k << 1 | 1].value = l2 - mid - 1 + 1;
	}
}
void build(int l, int r, int k, int h)
{
		if (l == r)
		{
			tree[k].value = a1[l] >= b1[l] ? 1 : 0;
			return;
		}
		int mid = (l + r) / 2;
		build(l, mid, k << 1, h + 1);
		build(mid + 1, r, k << 1 | 1, h + 1);
		int l1 = l;
		int l2 = mid + 1;
		int kk = l;
		while (l1 <= mid&&l2 <= r)
		{
			if (choose[h + 1][l1] <= choose[h + 1][l2])
				choose[h][kk++] = choose[h + 1][l1++];
			else
				choose[h][kk++] = choose[h + 1][l2++];
		}
			while (l1 <= mid)
				choose[h][kk++] = choose[h + 1][l1++];
			while (l2 <= r)
				choose[h][kk++] = choose[h + 1][l2++];
			pushup(k);
}
void same(int l, int r, int ll, int rr, int k, int value, int h)
{
	if (ll>=l&&rr<=r)
	{
		int rank = getrank(ll, rr, h, value);
		if (rank == ll)
			tree[k].value = value >= choose[h][ll] ? 1 : 0;
		else
			tree[k].value = rank - ll + 1;
		tree[k].issame = 1;
		tree[k].samevalue = value;
		return;
	}
	else
	{
		pushdown(k, h, ll, rr);
		int mid = (ll + rr) / 2;
		if (mid >= l)same(l, r, ll, mid, k << 1, value, h + 1);
		if (mid+1<= r)same(l, r, mid + 1, rr, k << 1 | 1, value, h + 1);
		pushup(k);
	}
}
int getsum(int l, int r, int ll, int rr, int k, int h)
{
	if (ll >= l&&rr <= r)
	{
		return tree[k].value;
	}
	else
	{
		pushdown(k, h, ll, rr);
		int mid = (ll + rr) / 2;
		int l1 = 0, l2 = 0;
		if (mid >= l)l1 = getsum(l, r, ll, mid, k << 1, h + 1);
		if (mid + 1 <= rr)l2 = getsum(l, r, mid + 1, rr, k << 1 | 1, h + 1);
		return l1 + l2;
	}
}
int main()
{
	while (scanf("%d%d%d%d", &n, &m, &A, &B) != EOF)
	{
		a = A, b = B, C = ~(1 << 31), M = (1 << 16) - 1,last=0;
		for (int i = 1; i <= n; i++)
			scanf("%d", &a1[i]);
		for (int i = 1; i <= n; i++)
			scanf("%d", &b1[i]);
		build(1, n, 1, 0);
		while (m--)
		{
			int l, r, x;
			l = rand(last)%n+1; r = rand(last)%n+1; x = rand(last)%n+1;
			if (l > r)swap(l, r);
			if ((l + r + x) % 2 == 0)
			{
				int valuee = getsum(l, r, 1, n, 1, 0);
				last = valuee;
				printf("%d\n", valuee);
			}
			else
			{
				same(l, r, 1, n, 1, x, 0);
			}
		}
	}
}*/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<string.h>
using namespace std;
bitset<100001>dp[2][3], mode[26];
char a[100010], b[5020];
int n, m, t;
int main()
{
//	//dp[0][0][0] = 1;
	//dp[1][0][0] = 1;
	//dp[0][0]=dp[0][0] << 1;
	//dp[1][0] = dp[0][0] | dp[1][0];
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d%d", &n, &m);
		for (int i = 0; i < 26; i++)
			mode[i].reset();
		for (int i = 0; i < 2; i++)
			for (int j = 0; j < 3; j++)
				dp[i][j].reset();
		scanf("%s%s", a, b);
		int lena =n;
		int lenb =m;
		for (int i = 0; i < lena; i++)
		{
			int kind = a[i] - 'a';
			mode[kind][i] = 1;
		}
		dp[1][1] = mode[b[0] - 'a'];
		if (lenb>=2)
		dp[1][2] = mode[b[1] - 'a'];
		b[lenb] = 'a';
		int cnt = 0;
		for (int i = 1; i < lenb; i++)
		{
				dp[cnt][0] = (dp[cnt ^ 1][2] << 1)&mode[b[i - 1] - 'a'];
			dp[cnt][1] = (((dp[cnt ^ 1][1] |dp[cnt ^ 1][0])<<1)&mode[b[i] - 'a']);
	dp[cnt][2] = (((dp[cnt ^ 1][0]|dp[cnt ^ 1][1]) << 1)&mode[b[i + 1] - 'a']);

			cnt ^= 1;
		}
		cnt ^= 1;
		for (int i = 0; i<=n-1; i++)
			if (dp[cnt][0][i + lenb - 1] | dp[cnt][1][i + lenb - 1] && i <= n - 1 - lenb + 1)
				printf("1");
			else
				printf("0");
		printf("\n");
	}
}*/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int t;
int a[1010];
int main()
{
	while (scanf("%d", &t) != EOF)
	{
		for (int i = 0; i < t; i++)
			scanf("%d", &a[i]);
		double sum1 = 0, sum2 = 0;
		sum1 = a[0] + a[t - 1];
		sum1 /= 2;
		for (int i = 1; i < t - 1; i++)
			sum2 += a[i];
		sum2 /= 3;
		printf("%.6llf\n", sum1 + sum2);
	}
	return 0;
}*/
//hdu5762
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
using  namespace std;
typedef long long ll;
struct nodee
{
	int son[26];
	int fa,pos,maxx;
	//char value;
};
nodee tree[300200];
int t,tot;
char s[100100];
char cc[10];
int maxx,noww;
void insert(char c)
{
	int tempp = noww;
	noww = tot;
	if (c== cc[0])
	{
		tree[noww].pos = maxx;
	}
	//tree[noww].value = c;
	int kind = c - 'a';
	if (tree[noww].pos == 0)
		tree[noww].pos = tree[tempp].pos;
	tree[noww].maxx = maxx;
	while (tempp&&tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tempp=tree[tempp].fa;
	if (tempp == 0 && tree[tempp].son[kind]==0)
		tree[tempp].son[kind] = noww,
	    tree[noww].fa = tempp;
	else
	{
			int nextt = tree[tempp].son[kind];
			if (tree[nextt].maxx - 1 == tree[tempp].maxx)
				tree[noww].fa = nextt;
			else
			{
				int neww = ++tot;
				tree[neww] = tree[nextt];
				tree[neww].maxx = tree[tempp].maxx + 1;
				if (tree[nextt].maxx == tree[nextt].pos)
					tree[neww].pos = tree[tempp].maxx + 1;
				else
					tree[neww].pos = tree[tempp].pos;
				while (tempp&&tree[tempp].son[kind] == nextt)
					tree[tempp].son[kind] = neww;
				if (tempp == 0 && tree[tempp].son[kind] == nextt)
					tree[tempp].son[kind] = neww;
				tree[noww].fa = neww; tree[nextt].fa = neww;
			}
	}
	tot++;
	maxx++;
}
int main()
{
	scanf("%d", &t);
	int k = 1;
	while (t--)
	{
		for (int i = 0; i <=tot; i++)for (int j = 0; j < 26; j++)tree[i].son[j] = 0, tree[i].fa = 0, tree[i].pos = 0,tree[i].maxx=0;
		tot = 1; maxx = 1; noww = 0;
		scanf("%s", cc);
		scanf("%s", s);
		//cc[0] = (rand() % 26) + 'a';
		//for (int i = 0; i < 100000; i++)
			//s[i] = (rand() % 26) + 'a';
		int len = strlen(s);
		//len = 100000;
		for (int i = 0; i < len; i++)
		{
			insert(s[i]);
		}
		ll sum = 0;
		for (int i = tot - 1; i >= 1; i--)
		{
			int fa = tree[i].fa;
			sum += min(tree[i].maxx - tree[fa].maxx, tree[i].pos);
		}
		printf("Case #%d: %lld\n",k++,sum);
	}
}/**/

/*#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
const int MAXN = 100010;
int t1[MAXN], t2[MAXN], c[MAXN];//��SA������Ҫ���м����������Ҫ��ֵ
//��������ַ�������s�����У���s[0]��s[n-1],����Ϊn,�����ֵС��m,
//��s[n-1]�������s[i]������0��r[n-1]=0
//���������Ժ�������sa������
//sa[1~n]->[0,N] rank[0~n-1]->[1,N]  height[1~n]
bool cmp(int *r, int a, int b, int l)
{
	return r[a] == r[b] && r[a + l] == r[b + l];
}
void da(int str[], int sa[], int Rank[], int height[], int n, int m)
{
	n++;
	int i, j, p, *x = t1, *y = t2;
	//��һ�ֻ����������s�����ֵ�ܴ󣬿ɸ�Ϊ��������
	for (i = 0; i < m; i++)c[i] = 0;
	for (i = 0; i < n; i++)c[x[i] = str[i]]++;
	for (i = 1; i < m; i++)c[i] += c[i - 1];
	for (i = n - 1; i >= 0; i--)sa[--c[x[i]]] = i;
	for (j = 1; j <= n; j <<= 1)
	{
		p = 0;
		//ֱ������sa��������ڶ��ؼ���
		for (i = n - j; i < n; i++)y[p++] = i;//�����j�����ڶ��ؼ���Ϊ�յ���С
		for (i = 0; i < n; i++)if (sa[i] >= j)y[p++] = sa[i] - j;
		//��������y����ľ��ǰ��յڶ��ؼ�������Ľ��
		//���������һ�ؼ���
		for (i = 0; i < m; i++)c[i] = 0;
		for (i = 0; i < n; i++)c[x[y[i]]]++;
		for (i = 1; i < m; i++)c[i] += c[i - 1];
		for (i = n - 1; i >= 0; i--)sa[--c[x[y[i]]]] = y[i];
		//����sa��x��������µ�x����
		swap(x, y);
		p = 1; x[sa[0]] = 0;
		for (i = 1; i < n; i++)
			x[sa[i]] = cmp(y, sa[i - 1], sa[i], j) ? p - 1 : p++;
		if (p >= n)break;
		m = p;//�´λ�����������ֵ
	}
	int k = 0;
	n--;
	for (i = 0; i <= n; i++)Rank[sa[i]] = i;
	for (i = 0; i < n; i++)
	{
		if (k)k--;
		j = sa[Rank[i] - 1];
		while (str[i + k] == str[j + k])k++;
		height[Rank[i]] = k;
	}
}
int Rank[MAXN], height[MAXN];

char str[MAXN];
char X[3];
int r[MAXN];
int sa[MAXN];
int nxt[MAXN];

int main(){
	int T;
	scanf("%d", &T);
	for (int cs = 1; cs <= T; cs++) {
		//X[0]= (rand() % 26) + 'a';
		//for (int i = 0; i < 100000; i++)
			//str[i] = (rand() % 26) + 'a';
		scanf("%s%s", X, str);
		int n = strlen(str);
		//n = 100000;
		int temp = n;
		for (int i = n - 1; i >= 0; i--) {
			if (str[i] == X[0]) temp = i;
			nxt[i] = temp;

		}
		for (int i = 0; i < n; i++) r[i] = str[i];
		r[n] = 0;
		da(r, sa, Rank, height, n, 128);
		ll ans = 0;
		for (int i = 1; i <= n; i++) {
			//printf("%d %d %d\n",nxt[sa[i]], sa[i] , height[i]);
			ans += n - max(nxt[sa[i]], sa[i] + height[i]);
		}
		printf("Case #%d: %I64d\n", cs, ans);
	}
	return 0;
}/**/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long ll;
struct nodee
{
	int son[26];
	int maxx,fa;
};
nodee tree[2000200];
char s[1000100];
int tot, maxx, tempp,noww;
void insert(char c)
{
	tree[tot].maxx = maxx;
	tempp = noww;
	noww = tot;
	int kind = c - 'a';
	while (tempp&&tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tempp=tree[tempp].fa;
	if (tempp == 0 && tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tree[noww].fa = tempp;
	else
	{
		int nextt = tree[tempp].son[kind];
		if (tree[nextt].maxx - 1 == tree[tempp].maxx)
			tree[noww].fa = nextt;
		else
		{
			int neww = ++tot;
			tree[neww] = tree[nextt];
			tree[neww].maxx = tree[tempp].maxx + 1;
			tree[noww].fa = neww; tree[nextt].fa = neww;
			while (tree[tempp].son[kind] == nextt)
			{
				tree[tempp].son[kind] = neww;
				if (tempp == 0)break;
				tempp = tree[tempp].fa;
			}
		}
	}
	tot++, maxx++;
}
int main()
{
	tot = 1; noww = 0; maxx = 1;
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 0; i < len; i++)
	{
		insert(s[i]);
	}
	ll ans = 0;
	for (int i = tot - 1; i >= 1; i--)
	{
		int fa = tree[i].fa;
		ans += tree[i].maxx - tree[fa].maxx;
	}
	printf("%lld\n", ans);
	return 0;
}/**/
//hihocoder 1449
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<queue>
using namespace std;
typedef long long ll;
struct nodee
{
	int maxl, maxr,fa;
	ll amount;
	int son[26];
	char vv;
};
struct lenth
{
	ll to, value;
};
lenth realvalue[1000200];
nodee tree[2000200];
int maxx, tot, noww, tempp;
char s[1000200];
int to[2000200];
void insert(char cc)
{
	tempp = noww;
	noww = tot;
	tree[noww].maxr = maxx;
	tree[noww].amount = 1;
	tree[noww].vv = cc;
	int kind = cc - 'a';
	while (tempp&&tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tempp = tree[tempp].fa;
	if (tempp == 0 && tree[tempp].son[kind] == 0)
	{
		tree[tempp].son[kind] = noww;
		tree[noww].fa = tempp;
	}
	else
	{
		int nextt = tree[tempp].son[kind];
		if (tree[nextt].maxr - tree[tempp].maxr == 1)
		{
			tree[noww].fa = nextt;
		}
		else
		{
			int neww = ++tot;
			tree[neww] = tree[nextt];
			tree[neww].amount = 0;
			tree[neww].maxr = tree[tempp].maxr + 1;
			tree[nextt].fa = neww; tree[noww].fa = neww;
			while (tree[tempp].son[kind] == nextt)
			{
				tree[tempp].son[kind] = neww;
				if (tempp == 0)break;
				tempp = tree[tempp].fa;
			}
		}
	}
	tot++;
	maxx++;
}
queue<int>que;
bool visit[2000200];
void getsum()
{
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		int fa = tree[now].fa;
		tree[fa].amount+=tree[now].amount;
		if (visit[fa] == 0)
		{
			visit[fa] = 1;
			if (fa)
			que.push(fa);
		}
	}
}
bool com(nodee a, nodee b)
{
	return a.amount < b.amount;
}
int main()
{
	noww = 0; maxx = 1; tot = 1;
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 0; i < len; i++)
	{
		insert(s[i]);
	}
	for (int i = tot - 1; i >= 1; i--)
	{
		int fa = tree[i].fa;
		tree[i].maxl = tree[fa].maxr + 1;
		to[fa]++;
	}
	for (int i = tot - 1; i >= 1; i--)
	{
		if (to[i] == 0)
		{
			que.push(i);
		}
	}
	getsum();

	for (int i = 1; i < tot; i++)
	{
		int noww = tree[i].maxr;
		realvalue[noww].value = max(realvalue[noww].value, tree[i].amount);
	}
	for (int i = len-1; i >= 1; i--)
	{
		realvalue[i].value= max(realvalue[i].value, realvalue[i + 1].value);
	}
	for (int i = 1; i <= len; i++)
		printf("%lld\n", realvalue[i].value);
	return 0;
}/**/

/*sort(tree+1, tree + tot, com);
int amount = 0;
for (int i =tot-1; i>=1; i--)
{
if (amount == len)
break;
int l = tree[i].maxl;
int r = tree[i].maxr;
while (l <=r)
{
if (realvalue[l].value != 0)
{
l = realvalue[l].to + 1;
continue;
}
realvalue[l].to = r;
realvalue[l].value = tree[i].amount;
l++;
amount++;
}
}*/
/*#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 100;
const int M = 1e6 + 5;
int tot, slink[2 * N], trans[2 * N][26], minlen[2 * N], maxlen[2 * N], edpts[2 * N], n;
char str[2 * N];
int blue[2 * N], ind[2 * N], ans[2 * N + 10];
int newstate(int _maxlen, int _minlen, int* _trans, int _slink) {
	maxlen[++tot] = _maxlen;
	minlen[tot] = _minlen;
	slink[tot] = _slink;
	if (_trans)
		for (int i = 0; i<26; i++)
			trans[tot][i] = _trans[i];
	return tot;
}
int add(char ch, int u) {
	int c = ch - 'a', v = u;
	int z = newstate(maxlen[u] + 1, -1, NULL, 0);
	blue[z] = 1;//��ɫ
	while (v&&!trans[v][c]) {
		trans[v][c] = z;
		v = slink[v];
	}
	if (!v) {
		minlen[z] = 1;
		slink[z] = 1;
		ind[0]++;
		return z;
	}
	int x = trans[v][c];
	if (maxlen[v] + 1 == maxlen[x]) {
		slink[z] = x;
		minlen[z] = maxlen[x] + 1;
		ind[x]++;
		return z;
	}
	int y = newstate(maxlen[v] + 1, -1, trans[x], slink[x]);
	slink[z] = slink[x] = y;
	ind[y] += 2;
	minlen[x] = minlen[z] = maxlen[y] + 1;
	while (v&&trans[v][c] == x) {
		trans[v][c] = y;
		v = slink[v];
	}
	minlen[y] = maxlen[slink[y]] + 1;
	return z;
}
void count() {
	queue<int> q;
	for (int i = 1; i <= tot; i++)if (!ind[i]) {
		q.push(i);
	}
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		if (blue[u]) edpts[u]++;
		edpts[slink[u]] += edpts[u];
		if (!--ind[slink[u]]) q.push(slink[u]);
	}
}

int main() {
	int i;
	scanf("%s", str);
	int len = strlen(str), pre = 1;
	tot = 1;
	for (i = 0; i<len; i++) {
		pre = add(str[i], pre);
	}
	count();
	for (i = 0; i <= tot; i++){
		ans[maxlen[i]] = max(ans[maxlen[i]], edpts[i]);
	}
	for (i = tot; i>0; i--){
		ans[i] = max(ans[i], ans[i + 1]);
	}
	for (i = 1; i <= len; i++)printf("%d\n", ans[i]);
	return 0;
}/**/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
struct edgee
{
	int from, to;
	ll cap,tempcap;
	edgee(int a, int b, ll c) :from(a), to(b), cap(c)
	{}
	edgee()
	{}
};
edgee edge[1010];
int first[1010], nextt[1010];
int edgetot = 0;
int h[1010], num[1010],fa[1010],edgenum[1010];
int tfirst[1010];
bool isin[1010];
void addedge(int from, int to, ll cap)
{
	edge[edgetot] = edgee(from, to, cap);
	nextt[edgetot] = first[from];
	first[from] = edgetot++;
	edge[edgetot] = edgee(to, from, 0);
	nextt[edgetot] = first[to];
	first[to] = edgetot++;
}
int n, m, x;
bool endd;
void bfs(int t,int s)
{
	for (int i = 1; i <= n; i++)
		h[i] = 1000000000;
	h[t] = 0;
	num[0] = 1;
	queue<int>que;
	que.push(t);
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		for (int i = first[now]; i != -1; i = nextt[i])
		{
			int to = edge[i].to;
			if (h[to] != 1000000000)
				continue;
			h[to] =  h[now] + 1;
			num[h[to]]++;
			que.push(to);
		}
	}
}
void augument(int t,ll &mincap)
{
	for (int i = fa[t]; i; i = fa[i])
	{
		edge[edgenum[i]].tempcap -= mincap;
		edge[edgenum[i] ^ 1].tempcap += mincap;
	}
}
ll isap(int s,int t)
{
	int temp = s;
	ll capp = 100000000000000000;
	ll ans = 0;
	while (h[s] <n)
	{
		int tempp = temp;
		if (temp == t)
		{
			augument(temp, capp);
			ans += capp;
			temp =s;
			capp = 100000000000000000;
			continue;
		}
		for (int &i = first[temp]; i != -1; i = nextt[i])
		{
			int to = edge[i].to;
			if (h[to] == h[temp] - 1 && edge[i].tempcap > 0)
			{
				fa[to] = temp;
				edgenum[temp] = i;
				temp = to;
				capp = min(capp, edge[i].tempcap);
				break;
			}
		}
		if (tempp != temp)
			continue;
		num[h[temp]]--;
		if (num[h[temp]] == 0)
			break;
		int minh = 100000000;
		for (int j = tfirst[temp]; j != -1; j = nextt[j])
		{
			int to = edge[j].to;
			if (edge[j].tempcap > 0)
				minh = min(minh, h[to]);
		}
		first[temp] = tfirst[temp];
		if (minh != 100000000)
			h[temp] = minh+1;
		else
			h[temp] = 100000000;
		if (h[temp] != 100000000)
		num[h[temp]]++;
		if (temp != s)
			temp = fa[temp];
	}
	return ans;
}
ll solve(double k)
{
	for (int i = 0; i < edgetot; i++)
		edge[i].tempcap = (ll)(edge[i].cap / k);
	for (int i = 1; i <= n; i++)
		first[i] = tfirst[i],fa[i]=0,edgenum[i]=0;
	ll ans = 0;
	bfs(n, 1);
	ans += isap(1, n);
	return ans;
}
int main()
{
	scanf("%d%d%d", &n, &m, &x);
	for (int i = 0; i <= n; i++)
		first[i] = -1;
	for (int i = 0; i < m; i++)
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		addedge(a, b, c);
	}
	for (int i = 1; i <= n; i++)
		tfirst[i] = first[i];
	double l = 0;
	    double r = 1000000;
		double l1 = 0;
		double r1 = r;
		int t = 0;
	while ((r - l )> (1e-11))
	{
		t++;
		double mid = (l + r) / 2;
		if (solve(mid)>=x)
		{
			l = mid;
			//if (fabs(l - l1) <=1e-9)
				//break;
		}
		else
		{
			r = mid;
			//if (fabs(r - r1) <=1e-9)
				//break;
		}
		if (t >= 42)
			break;
	}
	printf("%.8lf\n", l*x);
	return 0;
	}/**/


/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
#include<string.h>
#include<vector>
using namespace std;
typedef long long ll;
const ll a = 11289;
const ll b = 40961;
const ll p = 233333333;
const ll q = 998244353;
struct edgee
{
	int to;
};
struct diann
{
	ll hashvalue;
	char namee[11];
};
edgee edge[2][200200];
diann dian[2][100100];
map<string, int>name[2];
int n, edgetot[2];
char aa[20], bb[20];
int nametot[2];
int first[2][100200], nextt[2][200200];
void addedge(int from, int to, int kind)
{
	edge[kind][edgetot[kind]].to = to;
	nextt[kind][edgetot[kind]] = first[kind][from];
	first[kind][from] = edgetot[kind]++;
	edge[kind][edgetot[kind]].to = from;
	nextt[kind][edgetot[kind]] = first[kind][to];
	first[kind][to] = edgetot[kind]++;
}
int read(char *aa, int kind)
{
	if (name[kind][aa] == 0)
	{
		strcpy(dian[kind][nametot[kind]].namee, aa);
		name[kind][aa] = nametot[kind]++;
	}
	return name[kind][aa];
}
bool visit[2][100100], isinstack[2][100100];
bool visitroot[2][2];
ll hashvaluee[2][100100], temphash[100100];
int du[2][100100], height[2][100100];
int root[2][2],maxheight;
int son[2][100020];
vector<int>parent[2][100010];
void gethash(int kind)
{
	queue<int>que; maxheight = -1;
	for (int i = 1; i <nametot[kind]; i++)
	{
		visit[kind][i] = 0; isinstack[kind][i] = 0;
		if (du[kind][i] == 1)
		{
			height[kind][i] = 1;
			hashvaluee[kind][i] = 1;
			que.push(i);
		}
	}
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		visit[kind][now] = 1;
		int all = -1;
		for (int i = first[kind][now]; i != -1; i = nextt[kind][i])
		{
			int to = edge[kind][i].to;
			if (visit[kind][to] == 1&&height[kind][to]==height[kind][now]-1)
				temphash[++all] = hashvaluee[kind][to];
			else
			{
				if (isinstack[kind][to] == 0)
				{
					que.push(to);
					isinstack[kind][to] = 1;
					height[kind][to] = height[kind][now] + 1;
				}
			}
		}
		if (all != -1)
		{
			all++;
			sort(temphash, temphash + all);
			hashvaluee[kind][now] = (a*p) % q;
			for (int i = 0; i < all; i++)
			{
				hashvaluee[kind][now] = (hashvaluee[kind][now] * p^temphash[i]) % q;
			}
			hashvaluee[kind][now] = (hashvaluee[kind][now] * b) % q;
		}
		if (height[kind][now] > maxheight)
		{
			root[kind][0] = now; root[kind][1] = -1;
			maxheight = height[kind][now];
		}
		else
		{
			if (height[kind][now] == maxheight)
			{
				root[kind][1] = now;
				if (hashvaluee[kind][root[kind][1]] < hashvaluee[kind][root[kind][0]])
					swap(root[kind][0], root[kind][1]);
			}
		}
		}
		}
		bool com1(int a, int b)
		{
		return hashvaluee[0][a] < hashvaluee[0][b];
		}
		bool com2(int a, int b)
		{
		return hashvaluee[1][a] < hashvaluee[1][b];
		}
		void print(int l, int r,int fal,int far)
		{
		if (l == -1 || r == -1)
		return;
		printf("%s %s\n", dian[0][l].namee, dian[1][r].namee);
		int alll = -1,allr=-1;
		for (int i = first[0][l]; i != -1; i = nextt[0][i])
		{
		if (edge[0][i].to!=fal&&edge[0][i].to!=root[0][0]&&edge[0][i].to!=root[0][1])
		son[0][++alll]=edge[0][i].to;
		}
		sort(son[0], son[0] + alll+1, com1);
		for (int i = 0; i <=alll; i++)
		parent[0][l].push_back(son[0][i]);
		for (int i = first[1][r]; i != -1; i = nextt[1][i])
		{
		if (edge[1][i].to != far&&edge[1][i].to!=root[1][0]&&edge[1][i].to!=root[1][1]);
		son[1][++allr] = edge[1][i].to;
		}
		sort(son[1], son[1] + allr+1, com2);
		for (int i = 0; i <=allr; i++)
		parent[1][r].push_back(son[1][i]);
		for (int i = 0; i <=alll; i++)
		{
		int ll = parent[0][l][i]; int rr = parent[1][r][i];
		print(ll, rr,l,r);
		}
		}
		int main()
		{
		while (scanf("%d", &n))
		{
		nametot[0] = 1; nametot[1] = 1;
		name[0].clear(); name[1].clear();
		root[0][0] = root[0][1] = root[1][0] = root[1][1] = -1;
		visitroot[0][0] = visitroot[0][1] = visitroot[1][0] =visitroot[1][1] = 0;
		for (int i = 0; i <= n; i++)
		first[0][i] = -1, first[1][i] = -1,
		parent[0][i].clear(), parent[1][i].clear(),
		du[0][i]=du[1][i]=0;
		for (int i = 1; i < n; i++)
		{
		scanf("%s%s", aa, bb);
		int a1 = read(aa, 0);
		int b1 = read(bb, 0);
		addedge(a1, b1, 0);
		du[0][a1]++, du[0][b1]++;
		}
		for (int i = 1; i < n; i++)
		{
		scanf("%s%s", aa, bb);
		int a2 = read(aa, 1);
		int b2 = read(bb, 1);
		addedge(a2, b2, 1);
		du[1][a2]++, du[1][b2]++;
		}
		gethash(0);
		gethash(1);
		for (int i = 0; i < 2; i++)
		{
		if (root[0][i] == -1)break;
		print(root[0][i], root[1][i],-1,-1);
		}
		}
		}*/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
	int value;
	bool issame;
	int samevalue;
};
node tree[600000];
int a1[100010], b1[100010];
int choose[20][100010];
int a, b, C, M, last;
int n, m, A, B;
int rand(int last)
{
	a = (36969 + (last >> 3))*(a&M) + (a >> 16);
	b = (18000 + (last >> 3))*(b&M) + (b >> 16);
	return (C&((a << 16) + b)) % 1000000000;
}
int getrank(int l, int r, int h, int value)
{
	while (l < r)
	{
		int mid = (l + r) / 2+1;
		if (choose[h][mid] <= mid)
			l = mid;
		else
			r = mid - 1;
	}
	return l;
}
void pushup(int k)
{
	tree[k].value = tree[k << 1].value + tree[k << 1 | 1].value;
}
void pushdown(int k, int h, int l, int r)
{
	if (tree[k].issame)
	{
		tree[k << 1].issame = 1;
		tree[k << 1 | 1].issame = 1;
		tree[k].issame = 0;
		tree[k << 1].samevalue = tree[k].samevalue;
		tree[k << 1 | 1].samevalue = tree[k].samevalue;
		int mid = (l + r) / 2;
		int l1 = getrank(l, mid, h + 1, tree[k].samevalue);
		int l2 = getrank(mid + 1, r, h + 1, tree[k].samevalue);
		if (l1 == l)
			tree[k << 1].value = tree[k << 1].samevalue >= choose[h + 1][l] ? 1 : 0;
		else
			tree[k << 1].value = l1 - l + 1;
		if (l2 == mid + 1)
			tree[k << 1 | 1].value = tree[k << 1 | 1].samevalue >= choose[h + 1][mid + 1] ? 1 : 0;
		else
			tree[k << 1 | 1].value = l2 - mid - 1 + 1;
	}
}
void build(int l, int r, int k, int h)
{
		if (l == r)
		{
			tree[k].value = a1[l] >= b1[l] ? 1 : 0;
			return;
		}
		int mid = (l + r) / 2;
		build(l, mid, k << 1, h + 1);
		build(mid + 1, r, k << 1 | 1, h + 1);
		int l1 = l;
		int l2 = mid + 1;
		int kk = l;
		while (l1 <= mid&&l2 <= r)
		{
			if (choose[h + 1][l1] <= choose[h + 1][l2])
				choose[h][kk++] = choose[h + 1][l1++];
			else
				choose[h][kk++] = choose[h + 1][l2++];
		}
			while (l1 <= mid)
				choose[h][kk++] = choose[h + 1][l1++];
			while (l2 <= r)
				choose[h][kk++] = choose[h + 1][l2++];
			pushup(k);
}
void same(int l, int r, int ll, int rr, int k, int value, int h)
{
	if (ll>=l&&rr<=r)
	{
		int rank = getrank(ll, rr, h, value);
		if (rank == ll)
			tree[k].value = value >= choose[h][ll] ? 1 : 0;
		else
			tree[k].value = rank - ll + 1;
		tree[k].issame = 1;
		tree[k].samevalue = value;
		return;
	}
	else
	{
		pushdown(k, h, ll, rr);
		int mid = (ll + rr) / 2;
		if (mid >= l)same(l, r, ll, mid, k << 1, value, h + 1);
		if (mid+1<= r)same(l, r, mid + 1, rr, k << 1 | 1, value, h + 1);
		pushup(k);
	}
}
int getsum(int l, int r, int ll, int rr, int k, int h)
{
	if (ll >= l&&rr <= r)
	{
		return tree[k].value;
	}
	else
	{
		pushdown(k, h, ll, rr);
		int mid = (ll + rr) / 2;
		int l1 = 0, l2 = 0;
		if (mid >= l)l1 = getsum(l, r, ll, mid, k << 1, h + 1);
		if (mid + 1 <= rr)l2 = getsum(l, r, mid + 1, rr, k << 1 | 1, h + 1);
		return l1 + l2;
	}
}
int main()
{
	while (scanf("%d%d%d%d", &n, &m, &A, &B) != EOF)
	{
		a = A, b = B, C = ~(1 << 31), M = (1 << 16) - 1,last=0;
		for (int i = 1; i <= n; i++)
			scanf("%d", &a1[i]);
		for (int i = 1; i <= n; i++)
			scanf("%d", &b1[i]);
		build(1, n, 1, 0);
		while (m--)
		{
			int l, r, x;
			l = rand(last)%n+1; r = rand(last)%n+1; x = rand(last)%n+1;
			if (l > r)swap(l, r);
			if ((l + r + x) % 2 == 0)
			{
				int valuee = getsum(l, r, 1, n, 1, 0);
				last = valuee;
				printf("%d\n", valuee);
			}
			else
			{
				same(l, r, 1, n, 1, x, 0);
			}
		}
	}
}*/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<string.h>
using namespace std;
bitset<100001>dp[2][3], mode[26];
char a[100010], b[5020];
int n, m, t;
int main()
{
//	//dp[0][0][0] = 1;
	//dp[1][0][0] = 1;
	//dp[0][0]=dp[0][0] << 1;
	//dp[1][0] = dp[0][0] | dp[1][0];
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d%d", &n, &m);
		for (int i = 0; i < 26; i++)
			mode[i].reset();
		for (int i = 0; i < 2; i++)
			for (int j = 0; j < 3; j++)
				dp[i][j].reset();
		scanf("%s%s", a, b);
		int lena =n;
		int lenb =m;
		for (int i = 0; i < lena; i++)
		{
			int kind = a[i] - 'a';
			mode[kind][i] = 1;
		}
		dp[1][1] = mode[b[0] - 'a'];
		if (lenb>=2)
		dp[1][2] = mode[b[1] - 'a'];
		b[lenb] = 'a';
		int cnt = 0;
		for (int i = 1; i < lenb; i++)
		{
				dp[cnt][0] = (dp[cnt ^ 1][2] << 1)&mode[b[i - 1] - 'a'];
			dp[cnt][1] = (((dp[cnt ^ 1][1] |dp[cnt ^ 1][0])<<1)&mode[b[i] - 'a']);
	dp[cnt][2] = (((dp[cnt ^ 1][0]|dp[cnt ^ 1][1]) << 1)&mode[b[i + 1] - 'a']);

			cnt ^= 1;
		}
		cnt ^= 1;
		for (int i = 0; i<=n-1; i++)
			if (dp[cnt][0][i + lenb - 1] | dp[cnt][1][i + lenb - 1] && i <= n - 1 - lenb + 1)
				printf("1");
			else
				printf("0");
		printf("\n");
	}
}*/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int t;
int a[1010];
int main()
{
	while (scanf("%d", &t) != EOF)
	{
		for (int i = 0; i < t; i++)
			scanf("%d", &a[i]);
		double sum1 = 0, sum2 = 0;
		sum1 = a[0] + a[t - 1];
		sum1 /= 2;
		for (int i = 1; i < t - 1; i++)
			sum2 += a[i];
		sum2 /= 3;
		printf("%.6llf\n", sum1 + sum2);
	}
	return 0;
}*/
//hdu5762
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
using  namespace std;
typedef long long ll;
struct nodee
{
	int son[26];
	int fa,pos,maxx;
	//char value;
};
nodee tree[300200];
int t,tot;
char s[100100];
char cc[10];
int maxx,noww;
void insert(char c)
{
	int tempp = noww;
	noww = tot;
	if (c== cc[0])
	{
		tree[noww].pos = maxx;
	}
	//tree[noww].value = c;
	int kind = c - 'a';
	if (tree[noww].pos == 0)
		tree[noww].pos = tree[tempp].pos;
	tree[noww].maxx = maxx;
	while (tempp&&tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tempp=tree[tempp].fa;
	if (tempp == 0 && tree[tempp].son[kind]==0)
		tree[tempp].son[kind] = noww,
	    tree[noww].fa = tempp;
	else
	{
			int nextt = tree[tempp].son[kind];
			if (tree[nextt].maxx - 1 == tree[tempp].maxx)
				tree[noww].fa = nextt;
			else
			{
				int neww = ++tot;
				tree[neww] = tree[nextt];
				tree[neww].maxx = tree[tempp].maxx + 1;
				if (tree[nextt].maxx == tree[nextt].pos)
					tree[neww].pos = tree[tempp].maxx + 1;
				else
					tree[neww].pos = tree[tempp].pos;
				while (tempp&&tree[tempp].son[kind] == nextt)
					tree[tempp].son[kind] = neww;
				if (tempp == 0 && tree[tempp].son[kind] == nextt)
					tree[tempp].son[kind] = neww;
				tree[noww].fa = neww; tree[nextt].fa = neww;
			}
	}
	tot++;
	maxx++;
}
int main()
{
	scanf("%d", &t);
	int k = 1;
	while (t--)
	{
		for (int i = 0; i <=tot; i++)for (int j = 0; j < 26; j++)tree[i].son[j] = 0, tree[i].fa = 0, tree[i].pos = 0,tree[i].maxx=0;
		tot = 1; maxx = 1; noww = 0;
		scanf("%s", cc);
		scanf("%s", s);
		//cc[0] = (rand() % 26) + 'a';
		//for (int i = 0; i < 100000; i++)
			//s[i] = (rand() % 26) + 'a';
		int len = strlen(s);
		//len = 100000;
		for (int i = 0; i < len; i++)
		{
			insert(s[i]);
		}
		ll sum = 0;
		for (int i = tot - 1; i >= 1; i--)
		{
			int fa = tree[i].fa;
			sum += min(tree[i].maxx - tree[fa].maxx, tree[i].pos);
		}
		printf("Case #%d: %lld\n",k++,sum);
	}
}/**/

/*#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
const int MAXN = 100010;
int t1[MAXN], t2[MAXN], c[MAXN];//��SA������Ҫ���м����������Ҫ��ֵ
//��������ַ�������s�����У���s[0]��s[n-1],����Ϊn,�����ֵС��m,
//��s[n-1]�������s[i]������0��r[n-1]=0
//���������Ժ�������sa������
//sa[1~n]->[0,N] rank[0~n-1]->[1,N]  height[1~n]
bool cmp(int *r, int a, int b, int l)
{
	return r[a] == r[b] && r[a + l] == r[b + l];
}
void da(int str[], int sa[], int Rank[], int height[], int n, int m)
{
	n++;
	int i, j, p, *x = t1, *y = t2;
	//��һ�ֻ����������s�����ֵ�ܴ󣬿ɸ�Ϊ��������
	for (i = 0; i < m; i++)c[i] = 0;
	for (i = 0; i < n; i++)c[x[i] = str[i]]++;
	for (i = 1; i < m; i++)c[i] += c[i - 1];
	for (i = n - 1; i >= 0; i--)sa[--c[x[i]]] = i;
	for (j = 1; j <= n; j <<= 1)
	{
		p = 0;
		//ֱ������sa��������ڶ��ؼ���
		for (i = n - j; i < n; i++)y[p++] = i;//�����j�����ڶ��ؼ���Ϊ�յ���С
		for (i = 0; i < n; i++)if (sa[i] >= j)y[p++] = sa[i] - j;
		//��������y����ľ��ǰ��յڶ��ؼ�������Ľ��
		//���������һ�ؼ���
		for (i = 0; i < m; i++)c[i] = 0;
		for (i = 0; i < n; i++)c[x[y[i]]]++;
		for (i = 1; i < m; i++)c[i] += c[i - 1];
		for (i = n - 1; i >= 0; i--)sa[--c[x[y[i]]]] = y[i];
		//����sa��x��������µ�x����
		swap(x, y);
		p = 1; x[sa[0]] = 0;
		for (i = 1; i < n; i++)
			x[sa[i]] = cmp(y, sa[i - 1], sa[i], j) ? p - 1 : p++;
		if (p >= n)break;
		m = p;//�´λ�����������ֵ
	}
	int k = 0;
	n--;
	for (i = 0; i <= n; i++)Rank[sa[i]] = i;
	for (i = 0; i < n; i++)
	{
		if (k)k--;
		j = sa[Rank[i] - 1];
		while (str[i + k] == str[j + k])k++;
		height[Rank[i]] = k;
	}
}
int Rank[MAXN], height[MAXN];

char str[MAXN];
char X[3];
int r[MAXN];
int sa[MAXN];
int nxt[MAXN];

int main(){
	int T;
	scanf("%d", &T);
	for (int cs = 1; cs <= T; cs++) {
		//X[0]= (rand() % 26) + 'a';
		//for (int i = 0; i < 100000; i++)
			//str[i] = (rand() % 26) + 'a';
		scanf("%s%s", X, str);
		int n = strlen(str);
		//n = 100000;
		int temp = n;
		for (int i = n - 1; i >= 0; i--) {
			if (str[i] == X[0]) temp = i;
			nxt[i] = temp;

		}
		for (int i = 0; i < n; i++) r[i] = str[i];
		r[n] = 0;
		da(r, sa, Rank, height, n, 128);
		ll ans = 0;
		for (int i = 1; i <= n; i++) {
			//printf("%d %d %d\n",nxt[sa[i]], sa[i] , height[i]);
			ans += n - max(nxt[sa[i]], sa[i] + height[i]);
		}
		printf("Case #%d: %I64d\n", cs, ans);
	}
	return 0;
}/**/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long ll;
struct nodee
{
	int son[26];
	int maxx,fa;
};
nodee tree[2000200];
char s[1000100];
int tot, maxx, tempp,noww;
void insert(char c)
{
	tree[tot].maxx = maxx;
	tempp = noww;
	noww = tot;
	int kind = c - 'a';
	while (tempp&&tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tempp=tree[tempp].fa;
	if (tempp == 0 && tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tree[noww].fa = tempp;
	else
	{
		int nextt = tree[tempp].son[kind];
		if (tree[nextt].maxx - 1 == tree[tempp].maxx)
			tree[noww].fa = nextt;
		else
		{
			int neww = ++tot;
			tree[neww] = tree[nextt];
			tree[neww].maxx = tree[tempp].maxx + 1;
			tree[noww].fa = neww; tree[nextt].fa = neww;
			while (tree[tempp].son[kind] == nextt)
			{
				tree[tempp].son[kind] = neww;
				if (tempp == 0)break;
				tempp = tree[tempp].fa;
			}
		}
	}
	tot++, maxx++;
}
int main()
{
	tot = 1; noww = 0; maxx = 1;
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 0; i < len; i++)
	{
		insert(s[i]);
	}
	ll ans = 0;
	for (int i = tot - 1; i >= 1; i--)
	{
		int fa = tree[i].fa;
		ans += tree[i].maxx - tree[fa].maxx;
	}
	printf("%lld\n", ans);
	return 0;
}/**/
//hihocoder 1449
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<queue>
using namespace std;
typedef long long ll;
struct nodee
{
	int maxl, maxr,fa;
	ll amount;
	int son[26];
	char vv;
};
struct lenth
{
	ll to, value;
};
lenth realvalue[1000200];
nodee tree[2000200];
int maxx, tot, noww, tempp;
char s[1000200];
int to[2000200];
void insert(char cc)
{
	tempp = noww;
	noww = tot;
	tree[noww].maxr = maxx;
	tree[noww].amount = 1;
	tree[noww].vv = cc;
	int kind = cc - 'a';
	while (tempp&&tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tempp = tree[tempp].fa;
	if (tempp == 0 && tree[tempp].son[kind] == 0)
	{
		tree[tempp].son[kind] = noww;
		tree[noww].fa = tempp;
	}
	else
	{
		int nextt = tree[tempp].son[kind];
		if (tree[nextt].maxr - tree[tempp].maxr == 1)
		{
			tree[noww].fa = nextt;
		}
		else
		{
			int neww = ++tot;
			tree[neww] = tree[nextt];
			tree[neww].amount = 0;
			tree[neww].maxr = tree[tempp].maxr + 1;
			tree[nextt].fa = neww; tree[noww].fa = neww;
			while (tree[tempp].son[kind] == nextt)
			{
				tree[tempp].son[kind] = neww;
				if (tempp == 0)break;
				tempp = tree[tempp].fa;
			}
		}
	}
	tot++;
	maxx++;
}
queue<int>que;
bool visit[2000200];
void getsum()
{
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		int fa = tree[now].fa;
		tree[fa].amount+=tree[now].amount;
		if (visit[fa] == 0)
		{
			visit[fa] = 1;
			if (fa)
			que.push(fa);
		}
	}
}
bool com(nodee a, nodee b)
{
	return a.amount < b.amount;
}
int main()
{
	noww = 0; maxx = 1; tot = 1;
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 0; i < len; i++)
	{
		insert(s[i]);
	}
	for (int i = tot - 1; i >= 1; i--)
	{
		int fa = tree[i].fa;
		tree[i].maxl = tree[fa].maxr + 1;
		to[fa]++;
	}
	for (int i = tot - 1; i >= 1; i--)
	{
		if (to[i] == 0)
		{
			que.push(i);
		}
	}
	getsum();

	for (int i = 1; i < tot; i++)
	{
		int noww = tree[i].maxr;
		realvalue[noww].value = max(realvalue[noww].value, tree[i].amount);
	}
	for (int i = len-1; i >= 1; i--)
	{
		realvalue[i].value= max(realvalue[i].value, realvalue[i + 1].value);
	}
	for (int i = 1; i <= len; i++)
		printf("%lld\n", realvalue[i].value);
	return 0;
}/**/

/*sort(tree+1, tree + tot, com);
int amount = 0;
for (int i =tot-1; i>=1; i--)
{
if (amount == len)
break;
int l = tree[i].maxl;
int r = tree[i].maxr;
while (l <=r)
{
if (realvalue[l].value != 0)
{
l = realvalue[l].to + 1;
continue;
}
realvalue[l].to = r;
realvalue[l].value = tree[i].amount;
l++;
amount++;
}
}*/
/*#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 100;
const int M = 1e6 + 5;
int tot, slink[2 * N], trans[2 * N][26], minlen[2 * N], maxlen[2 * N], edpts[2 * N], n;
char str[2 * N];
int blue[2 * N], ind[2 * N], ans[2 * N + 10];
int newstate(int _maxlen, int _minlen, int* _trans, int _slink) {
	maxlen[++tot] = _maxlen;
	minlen[tot] = _minlen;
	slink[tot] = _slink;
	if (_trans)
		for (int i = 0; i<26; i++)
			trans[tot][i] = _trans[i];
	return tot;
}
int add(char ch, int u) {
	int c = ch - 'a', v = u;
	int z = newstate(maxlen[u] + 1, -1, NULL, 0);
	blue[z] = 1;//��ɫ
	while (v&&!trans[v][c]) {
		trans[v][c] = z;
		v = slink[v];
	}
	if (!v) {
		minlen[z] = 1;
		slink[z] = 1;
		ind[0]++;
		return z;
	}
	int x = trans[v][c];
	if (maxlen[v] + 1 == maxlen[x]) {
		slink[z] = x;
		minlen[z] = maxlen[x] + 1;
		ind[x]++;
		return z;
	}
	int y = newstate(maxlen[v] + 1, -1, trans[x], slink[x]);
	slink[z] = slink[x] = y;
	ind[y] += 2;
	minlen[x] = minlen[z] = maxlen[y] + 1;
	while (v&&trans[v][c] == x) {
		trans[v][c] = y;
		v = slink[v];
	}
	minlen[y] = maxlen[slink[y]] + 1;
	return z;
}
void count() {
	queue<int> q;
	for (int i = 1; i <= tot; i++)if (!ind[i]) {
		q.push(i);
	}
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		if (blue[u]) edpts[u]++;
		edpts[slink[u]] += edpts[u];
		if (!--ind[slink[u]]) q.push(slink[u]);
	}
}

int main() {
	int i;
	scanf("%s", str);
	int len = strlen(str), pre = 1;
	tot = 1;
	for (i = 0; i<len; i++) {
		pre = add(str[i], pre);
	}
	count();
	for (i = 0; i <= tot; i++){
		ans[maxlen[i]] = max(ans[maxlen[i]], edpts[i]);
	}
	for (i = tot; i>0; i--){
		ans[i] = max(ans[i], ans[i + 1]);
	}
	for (i = 1; i <= len; i++)printf("%d\n", ans[i]);
	return 0;
}/**/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
struct edgee
{
	int from, to;
	ll cap,tempcap;
	edgee(int a, int b, ll c) :from(a), to(b), cap(c)
	{}
	edgee()
	{}
};
edgee edge[1010];
int first[1010], nextt[1010];
int edgetot = 0;
int h[1010], num[1010],fa[1010],edgenum[1010];
int tfirst[1010];
bool isin[1010];
void addedge(int from, int to, ll cap)
{
	edge[edgetot] = edgee(from, to, cap);
	nextt[edgetot] = first[from];
	first[from] = edgetot++;
	edge[edgetot] = edgee(to, from, 0);
	nextt[edgetot] = first[to];
	first[to] = edgetot++;
}
int n, m, x;
bool endd;
void bfs(int t,int s)
{
	for (int i = 1; i <= n; i++)
		h[i] = 1000000000;
	h[t] = 0;
	num[0] = 1;
	queue<int>que;
	que.push(t);
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		for (int i = first[now]; i != -1; i = nextt[i])
		{
			int to = edge[i].to;
			if (h[to] != 1000000000)
				continue;
			h[to] =  h[now] + 1;
			num[h[to]]++;
			que.push(to);
		}
	}
}
void augument(int t,ll &mincap)
{
	for (int i = fa[t]; i; i = fa[i])
	{
		edge[edgenum[i]].tempcap -= mincap;
		edge[edgenum[i] ^ 1].tempcap += mincap;
	}
}
ll isap(int s,int t)
{
	int temp = s;
	ll capp = 100000000000000000;
	ll ans = 0;
	while (h[s] <n)
	{
		int tempp = temp;
		if (temp == t)
		{
			augument(temp, capp);
			ans += capp;
			temp =s;
			capp = 100000000000000000;
			continue;
		}
		for (int &i = first[temp]; i != -1; i = nextt[i])
		{
			int to = edge[i].to;
			if (h[to] == h[temp] - 1 && edge[i].tempcap > 0)
			{
				fa[to] = temp;
				edgenum[temp] = i;
				temp = to;
				capp = min(capp, edge[i].tempcap);
				break;
			}
		}
		if (tempp != temp)
			continue;
		num[h[temp]]--;
		if (num[h[temp]] == 0)
			break;
		int minh = 100000000;
		for (int j = tfirst[temp]; j != -1; j = nextt[j])
		{
			int to = edge[j].to;
			if (edge[j].tempcap > 0)
				minh = min(minh, h[to]);
		}
		first[temp] = tfirst[temp];
		if (minh != 100000000)
			h[temp] = minh+1;
		else
			h[temp] = 100000000;
		if (h[temp] != 100000000)
		num[h[temp]]++;
		if (temp != s)
			temp = fa[temp];
	}
	return ans;
}
ll solve(double k)
{
	for (int i = 0; i < edgetot; i++)
		edge[i].tempcap = (ll)(edge[i].cap / k);
	for (int i = 1; i <= n; i++)
		first[i] = tfirst[i],fa[i]=0,edgenum[i]=0;
	ll ans = 0;
	bfs(n, 1);
	ans += isap(1, n);
	return ans;
}
int main()
{
	scanf("%d%d%d", &n, &m, &x);
	for (int i = 0; i <= n; i++)
		first[i] = -1;
	for (int i = 0; i < m; i++)
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		addedge(a, b, c);
	}
	for (int i = 1; i <= n; i++)
		tfirst[i] = first[i];
	double l = 0;
	    double r = 1000000;
	while ((r - l )> (1e-8))
	{
		double mid = (l + r) / 2;
		if (solve(mid)>=x)
		{
			l = mid;
		}
		else
			r = mid;
	}
	printf("%.6lf\n", l*x);
	return 0;
	}/**/


/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
#include<string.h>
#include<vector>
using namespace std;
typedef long long ll;
const ll a = 11289;
const ll b = 40961;
const ll p = 233333333;
const ll q = 998244353;
struct edgee
{
	int to;
};
struct diann
{
	ll hashvalue;
	char namee[11];
};
edgee edge[2][200200];
diann dian[2][100100];
map<string, int>name[2];
int n, edgetot[2];
char aa[20], bb[20];
int nametot[2];
int first[2][100200], nextt[2][200200];
void addedge(int from, int to, int kind)
{
	edge[kind][edgetot[kind]].to = to;
	nextt[kind][edgetot[kind]] = first[kind][from];
	first[kind][from] = edgetot[kind]++;
	edge[kind][edgetot[kind]].to = from;
	nextt[kind][edgetot[kind]] = first[kind][to];
	first[kind][to] = edgetot[kind]++;
}
int read(char *aa, int kind)
{
	if (name[kind][aa] == 0)
	{
		strcpy(dian[kind][nametot[kind]].namee, aa);
		name[kind][aa] = nametot[kind]++;
	}
	return name[kind][aa];
}
bool visit[2][100100], isinstack[2][100100];
bool visitroot[2][2];
ll hashvaluee[2][100100], temphash[100100];
int du[2][100100], height[2][100100];
int root[2][2],maxheight;
int son[2][100020];
vector<int>parent[2][100010];
void gethash(int kind)
{
	queue<int>que; maxheight = -1;
	for (int i = 1; i <nametot[kind]; i++)
	{
		visit[kind][i] = 0; isinstack[kind][i] = 0;
		if (du[kind][i] == 1)
		{
			height[kind][i] = 1;
			hashvaluee[kind][i] = 1;
			que.push(i);
		}
	}
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		visit[kind][now] = 1;
		int all = -1;
		for (int i = first[kind][now]; i != -1; i = nextt[kind][i])
		{
			int to = edge[kind][i].to;
			if (visit[kind][to] == 1&&height[kind][to]==height[kind][now]-1)
				temphash[++all] = hashvaluee[kind][to];
			else
			{
				if (isinstack[kind][to] == 0)
				{
					que.push(to);
					isinstack[kind][to] = 1;
					height[kind][to] = height[kind][now] + 1;
				}
			}
		}
		if (all != -1)
		{
			all++;
			sort(temphash, temphash + all);
			hashvaluee[kind][now] = (a*p) % q;
			for (int i = 0; i < all; i++)
			{
				hashvaluee[kind][now] = (hashvaluee[kind][now] * p^temphash[i]) % q;
			}
			hashvaluee[kind][now] = (hashvaluee[kind][now] * b) % q;
		}
		if (height[kind][now] > maxheight)
		{
			root[kind][0] = now; root[kind][1] = -1;
			maxheight = height[kind][now];
		}
		else
		{
			if (height[kind][now] == maxheight)
			{
				root[kind][1] = now;
				if (hashvaluee[kind][root[kind][1]] < hashvaluee[kind][root[kind][0]])
					swap(root[kind][0], root[kind][1]);
			}
		}
		}
		}
		bool com1(int a, int b)
		{
		return hashvaluee[0][a] < hashvaluee[0][b];
		}
		bool com2(int a, int b)
		{
		return hashvaluee[1][a] < hashvaluee[1][b];
		}
		void print(int l, int r,int fal,int far)
		{
		if (l == -1 || r == -1)
		return;
		printf("%s %s\n", dian[0][l].namee, dian[1][r].namee);
		int alll = -1,allr=-1;
		for (int i = first[0][l]; i != -1; i = nextt[0][i])
		{
		if (edge[0][i].to!=fal&&edge[0][i].to!=root[0][0]&&edge[0][i].to!=root[0][1])
		son[0][++alll]=edge[0][i].to;
		}
		sort(son[0], son[0] + alll+1, com1);
		for (int i = 0; i <=alll; i++)
		parent[0][l].push_back(son[0][i]);
		for (int i = first[1][r]; i != -1; i = nextt[1][i])
		{
		if (edge[1][i].to != far&&edge[1][i].to!=root[1][0]&&edge[1][i].to!=root[1][1]);
		son[1][++allr] = edge[1][i].to;
		}
		sort(son[1], son[1] + allr+1, com2);
		for (int i = 0; i <=allr; i++)
		parent[1][r].push_back(son[1][i]);
		for (int i = 0; i <=alll; i++)
		{
		int ll = parent[0][l][i]; int rr = parent[1][r][i];
		print(ll, rr,l,r);
		}
		}
		int main()
		{
		while (scanf("%d", &n))
		{
		nametot[0] = 1; nametot[1] = 1;
		name[0].clear(); name[1].clear();
		root[0][0] = root[0][1] = root[1][0] = root[1][1] = -1;
		visitroot[0][0] = visitroot[0][1] = visitroot[1][0] =visitroot[1][1] = 0;
		for (int i = 0; i <= n; i++)
		first[0][i] = -1, first[1][i] = -1,
		parent[0][i].clear(), parent[1][i].clear(),
		du[0][i]=du[1][i]=0;
		for (int i = 1; i < n; i++)
		{
		scanf("%s%s", aa, bb);
		int a1 = read(aa, 0);
		int b1 = read(bb, 0);
		addedge(a1, b1, 0);
		du[0][a1]++, du[0][b1]++;
		}
		for (int i = 1; i < n; i++)
		{
		scanf("%s%s", aa, bb);
		int a2 = read(aa, 1);
		int b2 = read(bb, 1);
		addedge(a2, b2, 1);
		du[1][a2]++, du[1][b2]++;
		}
		gethash(0);
		gethash(1);
		for (int i = 0; i < 2; i++)
		{
		if (root[0][i] == -1)break;
		print(root[0][i], root[1][i],-1,-1);
		}
		}
		}*/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
	int value;
	bool issame;
	int samevalue;
};
node tree[600000];
int a1[100010], b1[100010];
int choose[20][100010];
int a, b, C, M, last;
int n, m, A, B;
int rand(int last)
{
	a = (36969 + (last >> 3))*(a&M) + (a >> 16);
	b = (18000 + (last >> 3))*(b&M) + (b >> 16);
	return (C&((a << 16) + b)) % 1000000000;
}
int getrank(int l, int r, int h, int value)
{
	while (l < r)
	{
		int mid = (l + r) / 2+1;
		if (choose[h][mid] <= mid)
			l = mid;
		else
			r = mid - 1;
	}
	return l;
}
void pushup(int k)
{
	tree[k].value = tree[k << 1].value + tree[k << 1 | 1].value;
}
void pushdown(int k, int h, int l, int r)
{
	if (tree[k].issame)
	{
		tree[k << 1].issame = 1;
		tree[k << 1 | 1].issame = 1;
		tree[k].issame = 0;
		tree[k << 1].samevalue = tree[k].samevalue;
		tree[k << 1 | 1].samevalue = tree[k].samevalue;
		int mid = (l + r) / 2;
		int l1 = getrank(l, mid, h + 1, tree[k].samevalue);
		int l2 = getrank(mid + 1, r, h + 1, tree[k].samevalue);
		if (l1 == l)
			tree[k << 1].value = tree[k << 1].samevalue >= choose[h + 1][l] ? 1 : 0;
		else
			tree[k << 1].value = l1 - l + 1;
		if (l2 == mid + 1)
			tree[k << 1 | 1].value = tree[k << 1 | 1].samevalue >= choose[h + 1][mid + 1] ? 1 : 0;
		else
			tree[k << 1 | 1].value = l2 - mid - 1 + 1;
	}
}
void build(int l, int r, int k, int h)
{
		if (l == r)
		{
			tree[k].value = a1[l] >= b1[l] ? 1 : 0;
			return;
		}
		int mid = (l + r) / 2;
		build(l, mid, k << 1, h + 1);
		build(mid + 1, r, k << 1 | 1, h + 1);
		int l1 = l;
		int l2 = mid + 1;
		int kk = l;
		while (l1 <= mid&&l2 <= r)
		{
			if (choose[h + 1][l1] <= choose[h + 1][l2])
				choose[h][kk++] = choose[h + 1][l1++];
			else
				choose[h][kk++] = choose[h + 1][l2++];
		}
			while (l1 <= mid)
				choose[h][kk++] = choose[h + 1][l1++];
			while (l2 <= r)
				choose[h][kk++] = choose[h + 1][l2++];
			pushup(k);
}
void same(int l, int r, int ll, int rr, int k, int value, int h)
{
	if (ll>=l&&rr<=r)
	{
		int rank = getrank(ll, rr, h, value);
		if (rank == ll)
			tree[k].value = value >= choose[h][ll] ? 1 : 0;
		else
			tree[k].value = rank - ll + 1;
		tree[k].issame = 1;
		tree[k].samevalue = value;
		return;
	}
	else
	{
		pushdown(k, h, ll, rr);
		int mid = (ll + rr) / 2;
		if (mid >= l)same(l, r, ll, mid, k << 1, value, h + 1);
		if (mid+1<= r)same(l, r, mid + 1, rr, k << 1 | 1, value, h + 1);
		pushup(k);
	}
}
int getsum(int l, int r, int ll, int rr, int k, int h)
{
	if (ll >= l&&rr <= r)
	{
		return tree[k].value;
	}
	else
	{
		pushdown(k, h, ll, rr);
		int mid = (ll + rr) / 2;
		int l1 = 0, l2 = 0;
		if (mid >= l)l1 = getsum(l, r, ll, mid, k << 1, h + 1);
		if (mid + 1 <= rr)l2 = getsum(l, r, mid + 1, rr, k << 1 | 1, h + 1);
		return l1 + l2;
	}
}
int main()
{
	while (scanf("%d%d%d%d", &n, &m, &A, &B) != EOF)
	{
		a = A, b = B, C = ~(1 << 31), M = (1 << 16) - 1,last=0;
		for (int i = 1; i <= n; i++)
			scanf("%d", &a1[i]);
		for (int i = 1; i <= n; i++)
			scanf("%d", &b1[i]);
		build(1, n, 1, 0);
		while (m--)
		{
			int l, r, x;
			l = rand(last)%n+1; r = rand(last)%n+1; x = rand(last)%n+1;
			if (l > r)swap(l, r);
			if ((l + r + x) % 2 == 0)
			{
				int valuee = getsum(l, r, 1, n, 1, 0);
				last = valuee;
				printf("%d\n", valuee);
			}
			else
			{
				same(l, r, 1, n, 1, x, 0);
			}
		}
	}
}*/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<string.h>
using namespace std;
bitset<100001>dp[2][3], mode[26];
char a[100010], b[5020];
int n, m, t;
int main()
{
//	//dp[0][0][0] = 1;
	//dp[1][0][0] = 1;
	//dp[0][0]=dp[0][0] << 1;
	//dp[1][0] = dp[0][0] | dp[1][0];
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d%d", &n, &m);
		for (int i = 0; i < 26; i++)
			mode[i].reset();
		for (int i = 0; i < 2; i++)
			for (int j = 0; j < 3; j++)
				dp[i][j].reset();
		scanf("%s%s", a, b);
		int lena =n;
		int lenb =m;
		for (int i = 0; i < lena; i++)
		{
			int kind = a[i] - 'a';
			mode[kind][i] = 1;
		}
		dp[1][1] = mode[b[0] - 'a'];
		if (lenb>=2)
		dp[1][2] = mode[b[1] - 'a'];
		b[lenb] = 'a';
		int cnt = 0;
		for (int i = 1; i < lenb; i++)
		{
				dp[cnt][0] = (dp[cnt ^ 1][2] << 1)&mode[b[i - 1] - 'a'];
			dp[cnt][1] = (((dp[cnt ^ 1][1] |dp[cnt ^ 1][0])<<1)&mode[b[i] - 'a']);
	dp[cnt][2] = (((dp[cnt ^ 1][0]|dp[cnt ^ 1][1]) << 1)&mode[b[i + 1] - 'a']);

			cnt ^= 1;
		}
		cnt ^= 1;
		for (int i = 0; i<=n-1; i++)
			if (dp[cnt][0][i + lenb - 1] | dp[cnt][1][i + lenb - 1] && i <= n - 1 - lenb + 1)
				printf("1");
			else
				printf("0");
		printf("\n");
	}
}*/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int t;
int a[1010];
int main()
{
	while (scanf("%d", &t) != EOF)
	{
		for (int i = 0; i < t; i++)
			scanf("%d", &a[i]);
		double sum1 = 0, sum2 = 0;
		sum1 = a[0] + a[t - 1];
		sum1 /= 2;
		for (int i = 1; i < t - 1; i++)
			sum2 += a[i];
		sum2 /= 3;
		printf("%.6llf\n", sum1 + sum2);
	}
	return 0;
}*/
//hdu5762
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
using  namespace std;
typedef long long ll;
struct nodee
{
	int son[26];
	int fa,pos,maxx;
	//char value;
};
nodee tree[300200];
int t,tot;
char s[100100];
char cc[10];
int maxx,noww;
void insert(char c)
{
	int tempp = noww;
	noww = tot;
	if (c== cc[0])
	{
		tree[noww].pos = maxx;
	}
	//tree[noww].value = c;
	int kind = c - 'a';
	if (tree[noww].pos == 0)
		tree[noww].pos = tree[tempp].pos;
	tree[noww].maxx = maxx;
	while (tempp&&tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tempp=tree[tempp].fa;
	if (tempp == 0 && tree[tempp].son[kind]==0)
		tree[tempp].son[kind] = noww,
	    tree[noww].fa = tempp;
	else
	{
			int nextt = tree[tempp].son[kind];
			if (tree[nextt].maxx - 1 == tree[tempp].maxx)
				tree[noww].fa = nextt;
			else
			{
				int neww = ++tot;
				tree[neww] = tree[nextt];
				tree[neww].maxx = tree[tempp].maxx + 1;
				if (tree[nextt].maxx == tree[nextt].pos)
					tree[neww].pos = tree[tempp].maxx + 1;
				else
					tree[neww].pos = tree[tempp].pos;
				while (tempp&&tree[tempp].son[kind] == nextt)
					tree[tempp].son[kind] = neww;
				if (tempp == 0 && tree[tempp].son[kind] == nextt)
					tree[tempp].son[kind] = neww;
				tree[noww].fa = neww; tree[nextt].fa = neww;
			}
	}
	tot++;
	maxx++;
}
int main()
{
	scanf("%d", &t);
	int k = 1;
	while (t--)
	{
		for (int i = 0; i <=tot; i++)for (int j = 0; j < 26; j++)tree[i].son[j] = 0, tree[i].fa = 0, tree[i].pos = 0,tree[i].maxx=0;
		tot = 1; maxx = 1; noww = 0;
		scanf("%s", cc);
		scanf("%s", s);
		//cc[0] = (rand() % 26) + 'a';
		//for (int i = 0; i < 100000; i++)
			//s[i] = (rand() % 26) + 'a';
		int len = strlen(s);
		//len = 100000;
		for (int i = 0; i < len; i++)
		{
			insert(s[i]);
		}
		ll sum = 0;
		for (int i = tot - 1; i >= 1; i--)
		{
			int fa = tree[i].fa;
			sum += min(tree[i].maxx - tree[fa].maxx, tree[i].pos);
		}
		printf("Case #%d: %lld\n",k++,sum);
	}
}/**/

/*#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll;
const int MAXN = 100010;
int t1[MAXN], t2[MAXN], c[MAXN];//��SA������Ҫ���м����������Ҫ��ֵ
//��������ַ�������s�����У���s[0]��s[n-1],����Ϊn,�����ֵС��m,
//��s[n-1]�������s[i]������0��r[n-1]=0
//���������Ժ�������sa������
//sa[1~n]->[0,N] rank[0~n-1]->[1,N]  height[1~n]
bool cmp(int *r, int a, int b, int l)
{
	return r[a] == r[b] && r[a + l] == r[b + l];
}
void da(int str[], int sa[], int Rank[], int height[], int n, int m)
{
	n++;
	int i, j, p, *x = t1, *y = t2;
	//��һ�ֻ����������s�����ֵ�ܴ󣬿ɸ�Ϊ��������
	for (i = 0; i < m; i++)c[i] = 0;
	for (i = 0; i < n; i++)c[x[i] = str[i]]++;
	for (i = 1; i < m; i++)c[i] += c[i - 1];
	for (i = n - 1; i >= 0; i--)sa[--c[x[i]]] = i;
	for (j = 1; j <= n; j <<= 1)
	{
		p = 0;
		//ֱ������sa��������ڶ��ؼ���
		for (i = n - j; i < n; i++)y[p++] = i;//�����j�����ڶ��ؼ���Ϊ�յ���С
		for (i = 0; i < n; i++)if (sa[i] >= j)y[p++] = sa[i] - j;
		//��������y����ľ��ǰ��յڶ��ؼ�������Ľ��
		//���������һ�ؼ���
		for (i = 0; i < m; i++)c[i] = 0;
		for (i = 0; i < n; i++)c[x[y[i]]]++;
		for (i = 1; i < m; i++)c[i] += c[i - 1];
		for (i = n - 1; i >= 0; i--)sa[--c[x[y[i]]]] = y[i];
		//����sa��x��������µ�x����
		swap(x, y);
		p = 1; x[sa[0]] = 0;
		for (i = 1; i < n; i++)
			x[sa[i]] = cmp(y, sa[i - 1], sa[i], j) ? p - 1 : p++;
		if (p >= n)break;
		m = p;//�´λ�����������ֵ
	}
	int k = 0;
	n--;
	for (i = 0; i <= n; i++)Rank[sa[i]] = i;
	for (i = 0; i < n; i++)
	{
		if (k)k--;
		j = sa[Rank[i] - 1];
		while (str[i + k] == str[j + k])k++;
		height[Rank[i]] = k;
	}
}
int Rank[MAXN], height[MAXN];

char str[MAXN];
char X[3];
int r[MAXN];
int sa[MAXN];
int nxt[MAXN];

int main(){
	int T;
	scanf("%d", &T);
	for (int cs = 1; cs <= T; cs++) {
		//X[0]= (rand() % 26) + 'a';
		//for (int i = 0; i < 100000; i++)
			//str[i] = (rand() % 26) + 'a';
		scanf("%s%s", X, str);
		int n = strlen(str);
		//n = 100000;
		int temp = n;
		for (int i = n - 1; i >= 0; i--) {
			if (str[i] == X[0]) temp = i;
			nxt[i] = temp;

		}
		for (int i = 0; i < n; i++) r[i] = str[i];
		r[n] = 0;
		da(r, sa, Rank, height, n, 128);
		ll ans = 0;
		for (int i = 1; i <= n; i++) {
			//printf("%d %d %d\n",nxt[sa[i]], sa[i] , height[i]);
			ans += n - max(nxt[sa[i]], sa[i] + height[i]);
		}
		printf("Case #%d: %I64d\n", cs, ans);
	}
	return 0;
}/**/
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;
typedef long long ll;
struct nodee
{
	int son[26];
	int maxx,fa;
};
nodee tree[2000200];
char s[1000100];
int tot, maxx, tempp,noww;
void insert(char c)
{
	tree[tot].maxx = maxx;
	tempp = noww;
	noww = tot;
	int kind = c - 'a';
	while (tempp&&tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tempp=tree[tempp].fa;
	if (tempp == 0 && tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tree[noww].fa = tempp;
	else
	{
		int nextt = tree[tempp].son[kind];
		if (tree[nextt].maxx - 1 == tree[tempp].maxx)
			tree[noww].fa = nextt;
		else
		{
			int neww = ++tot;
			tree[neww] = tree[nextt];
			tree[neww].maxx = tree[tempp].maxx + 1;
			tree[noww].fa = neww; tree[nextt].fa = neww;
			while (tree[tempp].son[kind] == nextt)
			{
				tree[tempp].son[kind] = neww;
				if (tempp == 0)break;
				tempp = tree[tempp].fa;
			}
		}
	}
	tot++, maxx++;
}
int main()
{
	tot = 1; noww = 0; maxx = 1;
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 0; i < len; i++)
	{
		insert(s[i]);
	}
	ll ans = 0;
	for (int i = tot - 1; i >= 1; i--)
	{
		int fa = tree[i].fa;
		ans += tree[i].maxx - tree[fa].maxx;
	}
	printf("%lld\n", ans);
	return 0;
}/**/
//hihocoder 1449
/*#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<queue>
using namespace std;
typedef long long ll;
struct nodee
{
	int maxl, maxr,fa;
	ll amount;
	int son[26];
	char vv;
};
struct lenth
{
	ll to, value;
};
lenth realvalue[1000200];
nodee tree[2000200];
int maxx, tot, noww, tempp;
char s[1000200];
int to[2000200];
void insert(char cc)
{
	tempp = noww;
	noww = tot;
	tree[noww].maxr = maxx;
	tree[noww].amount = 1;
	tree[noww].vv = cc;
	int kind = cc - 'a';
	while (tempp&&tree[tempp].son[kind] == 0)
		tree[tempp].son[kind] = noww,
		tempp = tree[tempp].fa;
	if (tempp == 0 && tree[tempp].son[kind] == 0)
	{
		tree[tempp].son[kind] = noww;
		tree[noww].fa = tempp;
	}
	else
	{
		int nextt = tree[tempp].son[kind];
		if (tree[nextt].maxr - tree[tempp].maxr == 1)
		{
			tree[noww].fa = nextt;
		}
		else
		{
			int neww = ++tot;
			tree[neww] = tree[nextt];
			tree[neww].amount = 0;
			tree[neww].maxr = tree[tempp].maxr + 1;
			tree[nextt].fa = neww; tree[noww].fa = neww;
			while (tree[tempp].son[kind] == nextt)
			{
				tree[tempp].son[kind] = neww;
				if (tempp == 0)break;
				tempp = tree[tempp].fa;
			}
		}
	}
	tot++;
	maxx++;
}
queue<int>que;
bool visit[2000200];
void getsum()
{
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		int fa = tree[now].fa;
		tree[fa].amount+=tree[now].amount;
		if (visit[fa] == 0)
		{
			visit[fa] = 1;
			if (fa)
			que.push(fa);
		}
	}
}
bool com(nodee a, nodee b)
{
	return a.amount < b.amount;
}
int main()
{
	noww = 0; maxx = 1; tot = 1;
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 0; i < len; i++)
	{
		insert(s[i]);
	}
	for (int i = tot - 1; i >= 1; i--)
	{
		int fa = tree[i].fa;
		tree[i].maxl = tree[fa].maxr + 1;
		to[fa]++;
	}
	for (int i = tot - 1; i >= 1; i--)
	{
		if (to[i] == 0)
		{
			que.push(i);
		}
	}
	getsum();

	for (int i = 1; i < tot; i++)
	{
		int noww = tree[i].maxr;
		realvalue[noww].value = max(realvalue[noww].value, tree[i].amount);
	}
	for (int i = len-1; i >= 1; i--)
	{
		realvalue[i].value= max(realvalue[i].value, realvalue[i + 1].value);
	}
	for (int i = 1; i <= len; i++)
		printf("%lld\n", realvalue[i].value);
	return 0;
}/**/

/*sort(tree+1, tree + tot, com);
int amount = 0;
for (int i =tot-1; i>=1; i--)
{
if (amount == len)
break;
int l = tree[i].maxl;
int r = tree[i].maxr;
while (l <=r)
{
if (realvalue[l].value != 0)
{
l = realvalue[l].to + 1;
continue;
}
realvalue[l].to = r;
realvalue[l].value = tree[i].amount;
l++;
amount++;
}
}*/
/*#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int N = 1e6 + 100;
const int M = 1e6 + 5;
int tot, slink[2 * N], trans[2 * N][26], minlen[2 * N], maxlen[2 * N], edpts[2 * N], n;
char str[2 * N];
int blue[2 * N], ind[2 * N], ans[2 * N + 10];
int newstate(int _maxlen, int _minlen, int* _trans, int _slink) {
	maxlen[++tot] = _maxlen;
	minlen[tot] = _minlen;
	slink[tot] = _slink;
	if (_trans)
		for (int i = 0; i<26; i++)
			trans[tot][i] = _trans[i];
	return tot;
}
int add(char ch, int u) {
	int c = ch - 'a', v = u;
	int z = newstate(maxlen[u] + 1, -1, NULL, 0);
	blue[z] = 1;//��ɫ
	while (v&&!trans[v][c]) {
		trans[v][c] = z;
		v = slink[v];
	}
	if (!v) {
		minlen[z] = 1;
		slink[z] = 1;
		ind[0]++;
		return z;
	}
	int x = trans[v][c];
	if (maxlen[v] + 1 == maxlen[x]) {
		slink[z] = x;
		minlen[z] = maxlen[x] + 1;
		ind[x]++;
		return z;
	}
	int y = newstate(maxlen[v] + 1, -1, trans[x], slink[x]);
	slink[z] = slink[x] = y;
	ind[y] += 2;
	minlen[x] = minlen[z] = maxlen[y] + 1;
	while (v&&trans[v][c] == x) {
		trans[v][c] = y;
		v = slink[v];
	}
	minlen[y] = maxlen[slink[y]] + 1;
	return z;
}
void count() {
	queue<int> q;
	for (int i = 1; i <= tot; i++)if (!ind[i]) {
		q.push(i);
	}
	while (!q.empty()) {
		int u = q.front();
		q.pop();
		if (blue[u]) edpts[u]++;
		edpts[slink[u]] += edpts[u];
		if (!--ind[slink[u]]) q.push(slink[u]);
	}
}

int main() {
	int i;
	scanf("%s", str);
	int len = strlen(str), pre = 1;
	tot = 1;
	for (i = 0; i<len; i++) {
		pre = add(str[i], pre);
	}
	count();
	for (i = 0; i <= tot; i++){
		ans[maxlen[i]] = max(ans[maxlen[i]], edpts[i]);
	}
	for (i = tot; i>0; i--){
		ans[i] = max(ans[i], ans[i + 1]);
	}
	for (i = 1; i <= len; i++)printf("%d\n", ans[i]);
	return 0;
}/**/
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
struct edgee
{
	int from, to;
	ll cap,tempcap;
	edgee(int a, int b, ll c) :from(a), to(b), cap(c)
	{}
	edgee()
	{}
};
edgee edge[1010];
int first[1010], nextt[1010];
int edgetot = 0;
int h[1010], num[1010],fa[1010],edgenum[1010];
int tfirst[1010];
bool isin[1010];
void addedge(int from, int to, ll cap)
{
	edge[edgetot] = edgee(from, to, cap);
	nextt[edgetot] = first[from];
	first[from] = edgetot++;
	edge[edgetot] = edgee(to, from, 0);
	nextt[edgetot] = first[to];
	first[to] = edgetot++;
}
int n, m, x;
bool endd;
void bfs(int t,int s)
{
	for (int i = 1; i <= n; i++)
		h[i] = 1000000000;
	h[t] = 0;
	num[0] = 1;
	queue<int>que;
	que.push(t);
	while (!que.empty())
	{
		int now = que.front();
		que.pop();
		for (int i = first[now]; i != -1; i = nextt[i])
		{
			int to = edge[i].to;
			if (h[to] != 1000000000)
				continue;
			h[to] =  h[now] + 1;
			num[h[to]]++;
			que.push(to);
		}
	}
}
void augument(int t,ll &mincap)
{
	for (int i = fa[t]; i; i = fa[i])
	{
		edge[edgenum[i]].tempcap -= mincap;
		edge[edgenum[i] ^ 1].tempcap += mincap;
	}
}
ll isap(int s,int t)
{
	int temp = s;
	ll capp = 100000000000000000;
	ll ans = 0;
	while (h[s] <n)
	{
		int tempp = temp;
		if (temp == t)
		{
			augument(temp, capp);
			ans += capp;
			temp =s;
			capp = 100000000000000000;
			continue;
		}
		for (int &i = first[temp]; i != -1; i = nextt[i])
		{
			int to = edge[i].to;
			if (h[to] == h[temp] - 1 && edge[i].tempcap > 0)
			{
				fa[to] = temp;
				edgenum[temp] = i;
				temp = to;
				capp = min(capp, edge[i].tempcap);
				break;
			}
		}
		if (tempp != temp)
			continue;
		num[h[temp]]--;
		if (num[h[temp]] == 0)
			break;
		int minh = 100000000;
		for (int j = tfirst[temp]; j != -1; j = nextt[j])
		{
			int to = edge[j].to;
			if (edge[j].tempcap > 0)
				minh = min(minh, h[to]);
		}
		first[temp] = tfirst[temp];
		if (minh != 100000000)
			h[temp] = minh+1;
		else
			h[temp] = 100000000;
		if (h[temp] != 100000000)
		num[h[temp]]++;
		if (temp != s)
			temp = fa[temp];
	}
	return ans;
}
ll solve(double k)
{
	for (int i = 0; i < edgetot; i++)
		edge[i].tempcap = (ll)(edge[i].cap / k);
	for (int i = 1; i <= n; i++)
		first[i] = tfirst[i],fa[i]=0,edgenum[i]=0;
	ll ans = 0;
	bfs(n, 1);
	ans += isap(1, n);
	return ans;
}
int main()
{
	scanf("%d%d%d", &n, &m, &x);
	for (int i = 0; i <= n; i++)
		first[i] = -1;
	for (int i = 0; i < m; i++)
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		addedge(a, b, c);
	}
	for (int i = 1; i <= n; i++)
		tfirst[i] = first[i];
	double l = 0;
	    double r = 1000000;
		double l1 = 0;
		double r1 = r;
	while ((r - l )> (1e-10))
	{
		double mid = (l + r) / 2;
		if (solve(mid)>=x)
		{
			l = mid;
			if (fabs(l - l1) <=1e-9)
				break;
		}
		else
		{
			r = mid;
			if (fabs(r - r1) <=1e-9)
				break;
		}
	}
	printf("%.8lf\n", l*x);
	return 0;
	}/**/