#include #include #include #include using namespace std; using namespace atcoder; int main() { int n,m,x; cin >> n >> m >> x; mcf_graph pd(n); for (int _=0; _> u >> v >> a >> b; u--; v--; pd.add_edge(u,v, b,a); pd.add_edge(v,u, b,a); } auto v = pd.slope(0, n-1); long long ans = -1; bool f = true; for (const auto& [a,b]: v) { if (f) { f=false; continue; } if ((b+1)/2 <= x) ans = max(ans, (long long)a); } cout << ans << endl; }