#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, t) for(int i = (s), mi = (t); i <= mi; i++)
#define dwn(i, s, t) for(int i = (s), mi = (t); i >= mi; i--)
int read() {
int x = 0, f = 1; char c = getchar();
while(!isdigit(c)) { if(c == '-') f = -1; c = getchar(); }
while(isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); }
return x * f;
}
#define maxn 500010
#define maxm 500010
#define oo 2147483647
namespace ZKW {
struct Edge {
int from, to, flow, cost;
Edge() {}
Edge(int _1, int _2, int _3, int _4): from(_1), to(_2), flow(_3), cost(_4) {}
} es[maxm];
int n, m, s, t, ans, cost, head[maxn], nxt[maxm];
int Q[maxn], hd, tl, d[maxn];
bool inq[maxn];
bool vis[maxn];
void init() {
ans = 0;
m = 0; memset(head, -1, sizeof(head));
return ;
}
void clearFlow() {
for(int i = 0; i < m; i += 2) es[i].flow += es[i^1].flow, es[i^1].flow = 0;
return ;
}
void AddEdge(int a, int b, int c, int d) {
es[m] = Edge(a, b, c, d); nxt[m] = head[a]; head[a] = m++;
es[m] = Edge(b, a, 0, -d); nxt[m] = head[b]; head[b] = m++;
return ;
}
int Nxt(int x) { return (x + 1) % maxn; }
bool BFS() {
rep(i, 1, n) d[i] = oo;
d[t] = 0;
hd = tl = 0; Q[tl = Nxt(tl)] = t; inq[t] = 1;
while(hd != tl) {
int u = Q[hd = Nxt(hd)]; inq[u] = 0;
for(int i = head[u]; i != -1; i = nxt[i]) {
Edge &e = es[i^1];
if(e.flow && d[e.from] > d[u] + e.cost) {
d[e.from] = d[u] + e.cost;
if(!inq[e.from]) inq[e.from] = 1, Q[tl = Nxt(tl)] = e.from;
}
}
}
if(d[s] == oo) return 0;
cost = d[s];
return 1;
}
int DFS(int u, int a) {
if(u == t || !a) return ans += cost * a, a;
if(vis[u]) return 0;
vis[u] = 1;
int flow = 0, f;
for(int i = head[u]; i != -1; i = nxt[i]) {
Edge &e = es[i];
if(d[e.to] == d[u] - e.cost && (f = DFS(e.to, min(a, e.flow)))) {
flow += f; a -= f;
e.flow -= f; es[i^1]. flow += f;
if(!a) return flow;
}
}
return flow;
}
int MaxFlow(int _s, int _t) {
s = _s; t = _t;
int flow = 0, f;
while(BFS())
do {
memset(vis, 0, sizeof(int) * (n + 1));
f = DFS(s, oo);
flow += f;
} while(f);
return flow;
}
}
using ZKW::AddEdge;
int main() {
int n = read(), m = read();
ZKW::init(); ZKW::n = n;
rep(i, 1, m) {
int a = read(), b = read(), c = read(), d = read();
AddEdge(a, b, c, d);
}
printf("%d ", ZKW::MaxFlow(1, n));
printf("%d
", ZKW::ans);
return 0;
}