#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
#define CRP(t, x) const t &x
#define OPL(t, x) bool operator<(CRP(t, x)) const
#define FIL(x, v) memset(x, v, sizeof(x))
#define CLR(x) FIL(x, 0)
#define NE1(x) FIL(x, -1)
#define INF(x) FIL(x, 0x3f)
#ifndef _DEBUG
#define _DEBUG 0
#endif // !_DEBUG
#define IFD if (_DEBUG)
typedef long long ll, i64;
const int N = 1e5 + 50;
struct Edge
{
    int nxt, to, l, r;
} E[N];
int adj[N], ecnt;
inline void addEdge(int f, int t, int l, int r)
{
    E[++ecnt] = {adj[f], t, l, r};
    adj[f] = ecnt;
}
bool modify(int u, int v, int l, int r)
{
    return false;
}
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0, f, t, l, r; i < m; i++)
    {
        scanf("%d%d%d%d", &f, &t, &l, &r);
        addEdge(f, t, l, r);
        addEdge(t, f, l, r);
    }
    queue<int> Q;
    static bool inq[N];
    for (Q.push(1), inq[1] = true; !Q.empty(); inq[Q.front()] = false, Q.pop())
        for (int u, e = adj[u = Q.front()]; e; e = E[e].nxt)
            if (modify(u, E[e].to, E[e].l, E[e].r) && !inq[E[e].to])
                Q.push(E[e].to), inq[E[e].to] = true;
    return 0;
}