#include #include using namespace std; using boost::multiprecision::cpp_int; using P = pair; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); // L = lcm(1,...,300) cpp_int L=1; for(int i=1;i<=300;i++){ L=lcm(L,cpp_int(i)); } int n,m; cin>>n>>m; vector>> G(n); for(int i=0;i>u>>v>>a>>b; u--;v--; cpp_int w=cpp_int(a)*(L/b); G[u].push_back({v,w}); G[v].push_back({u,w}); } cpp_int INF=L*cpp_int(1000000000LL); vector D(n,INF); priority_queue,greater

> pq; D[0]=0; pq.push({0,0}); while(!pq.empty()){ auto [d,v]=pq.top(); pq.pop(); if(d!=D[v]) continue; for(auto [to,w]:G[v]){ cpp_int nd=d+w; if(nd