#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
struct Edge{
int u,v;
ll w,b;
}e[5005];
vector<pair<int,ll>> g[5005];
int n,m;
void spfa(vector<ll>& dis, const vector<int>& sources){
queue<int> q;
vector<bool> inq(n+1,false);
for(int x : sources){
if(!inq[x]){
q.push(x);
inq[x]=true;
}
}
while(!q.empty()){
int u = q.front(); q.pop();
inq[u]=false;
for(auto &pr : g[u]){
int to = pr.first;
ll w = pr.second;
if(dis[to] > dis[u] + w){
dis[to] = dis[u] + w;
if(!inq[to]){
inq[to]=true;
q.push(to);
}
}
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n>>m;
for(int i=0;i<m;i++){
cin>>e[i].u>>e[i].v>>e[i].w>>e[i].b;
}
sort(e,e+m,[](const Edge&a,const Edge&b){return a.b < b.b;});
}