// It is made by XZZ
#include<cstdio>
#include<algorithm>
#define Fname "quake"
using namespace std;
#define rep(a,b,c) for(rg int a=b;a<=c;a++)
#define drep(a,b,c) for(rg int a=b;a>=c;a--)
#define erep(a,b) for(rg int a=fir[b];a;a=nxt[a])
#define il inline
#define rg register
#define vd void
#define db long double
typedef long long ll;
il int gi(){rg int x=0;bool flg=0;rg char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')flg=1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return flg?-x:x;
}
const int maxn=401,maxm=10001;
int n,m,f;
struct edge{int a,b,w,t;db v;}e[maxm];
bool operator < (edge a,edge b){return a.v<b.v;}
int fa[maxn];
il int hd(int i){return fa[i]==i?i:hd(fa[i]);}
il bool check(ll mid){rep(i,1,m)e[i].v=mid/3e6*e[i].t+e[i].w;int x=1;sort(e+1,e+m+1);rep(i,1,n)fa[i]=i;db k=f+1e-12;rep(i,2,n){while(x<=m&&hd(e[x].a)==hd(e[x].b))++x;fa[hd(e[x].a)]=hd(e[x].b),k-=e[x].v;if(k<0)return 0;}return 1;
}
int main(){freopen(Fname".in","r",stdin);freopen(Fname".out","w",stdout);n=gi(),m=gi(),f=gi();rep(i,1,m)e[i].a=gi(),e[i].b=gi(),e[i].w=gi(),e[i].t=gi();if(!check(0ll)){puts("0.0000");return 0;}ll mid,l=0,r=2e15;while(l<r){mid=(l+r)>>1;if(check(mid+1))l=mid+1;else r=mid;}printf("%.4Lf\n",l/(db)3e6);return 0;
}
// It is made by XZZ
#include<cstdio>
#include<algorithm>
#define Fname "cards"
using namespace std;
#define rep(a,b,c) for(rg int a=b;a<=c;a++)
#define drep(a,b,c) for(rg int a=b;a>=c;a--)
#define erep(a,b) for(rg int a=fir[b];a;a=nxt[a])
#define il inline
#define rg register
#define vd void
typedef long long ll;
il ll gi(){rg ll x=0;bool flg=0;rg char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')flg=1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return flg?-x:x;
}
ll c[52],n,m;
il bool check(const ll&mid){ll tot=0;rep(i,1,n)tot+=max(0ll,mid-c[i]);return tot<=min(m,mid);
}
int main(){freopen(Fname".in","r",stdin);freopen(Fname".out","w",stdout);n=gi(),m=gi();ll mid,l=0,r=2e9;rep(i,1,n)c[i]=gi();while(l<r){mid=(l+r)>>1;if(check(mid+1))l=mid+1;else r=mid;}printf("%lld\n",l);return 0;
}
// It is made by XZZ
#include<cstdio>
#include<algorithm>
#include<cstring>
#define Fname "cycle"
using namespace std;
#define rep(a,b,c) for(rg int a=b;a<=c;a++)
#define drep(a,b,c) for(rg int a=b;a>=c;a--)
#define erep(a,b) for(rg int a=fir[b];a;a=nxt[a])
#define il inline
#define rg register
#define vd void
typedef long long ll;
il int gi(){rg int x=0;bool flg=0;rg char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')flg=1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return flg?-x:x;
}
#define db long double
il db gf(){static db a;scanf("%Lf",&a);return a;}
const int maxn=3010,maxm=10010;
int n,m,s,fir[maxn],dis[maxm],nxt[maxm],id;db w[maxm];
il vd add(int a,int b,db c){nxt[++id]=fir[a],dis[id]=b,fir[a]=id,w[id]=c;}
db dist[maxn];bool flg=0;
bool vis[maxn];
il vd spfa(const int &x){vis[x]=1;erep(i,x)if(dist[dis[i]]>dist[x]+w[i]){dist[dis[i]]=dist[x]+w[i];if(flg||vis[dis[i]]){flg=1;break;}spfa(dis[i]);}vis[x]=0;
}
il bool check(ll a){rep(i,1,id)w[i]-=a/1e9-(1e-16);rep(i,1,n)dist[i]=0,vis[i]=0;flg=0;rep(i,1,n){spfa(i);if(flg)break;}rep(i,1,id)w[i]+=a/1e9-(1e-16);return !flg;
}
int __sum;
il vd dfs(const int&x){vis[x]=1,++__sum;erep(i,x)if(!vis[dis[i]])dfs(dis[i]);}
int main(){freopen(Fname".in","r",stdin);freopen(Fname".out","w",stdout);n=gi(),m=gi();int a,b;db c;while(m--)a=gi(),b=gi(),c=gf(),add(a,b,c);ll l=-1e16,r=1e16,mid;rep(i,1,n){memset(vis,0,sizeof vis);__sum=0;dfs(i);if(__sum==n){s=i;break;}}while(l<r){mid=((l+r)>>1)+1;if(check(mid))l=mid;else r=mid-1;}printf("%.8lf\n",l/1e9);return 0;
}