#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<queue>
#define inf 2147483647
#define nn 610
#define mm 50010
#define lo long long
using namespace std;
bool vis[nn];
int nxt[mm],fir[nn],to[mm],w[mm],flow[mm],dis[nn],ansc=0,e=1,n,m,S,T; //之前s和其他变量重名了,所以改成了大写
int getc()
{
int ans=0,f=1;char ch=getchar();
while(!isdigit(ch)) {if(ch==‘-‘) f=-1;ch=getchar();}
while(isdigit(ch)) {ans=ans*10+ch-‘0‘;ch=getchar();}
return ans*f;
}
void add(int a,int b,int c,int d)
{
nxt[++e]=fir[a];fir[a]=e;to[e]=b;w[e]=c;flow[e]=d;
nxt[++e]=fir[b];fir[b]=e;to[e]=a;w[e]=-c;flow[e]=0; //我看到是单向边,就只建了一条边
}
inline bool spfa()
{
int o;
deque<int> q;
q.push_back(S);
fill(vis,vis+3*n+1,0); //加了新点,大小要变
fill(dis,dis+3*n+1,inf);
dis[S]=0;vis[S]=1;
while(!q.empty())
{
o=q.front();q.pop_front();
for(int i=fir[o];i>1;i=nxt[i]) //由于边是从2开始的,所以判断条件要改成i>1
if(flow[i]&&dis[o]+w[i]<dis[to[i]])
{
dis[to[i]]=dis[o]+w[i];
if(!vis[to[i]])
{
vis[to[i]]=1;
if(!q.empty()&&dis[to[i]]<dis[q.front()])
q.push_front(to[i]);
else q.push_back(to[i]);
}
}
vis[o]=0;
}
return dis[T]!=inf;
}
inline int mcmf(int now,int f)
{
if(!f||now==T) {vis[now]=1;return f;} //写成了return 0
int newflow,newans=0,minf;
vis[now]=1;
for(int i=fir[now];i;i=nxt[i])
if(!vis[to[i]]&&dis[now]+w[i]==dis[to[i]]&&flow[i])
{
minf=min(f,flow[i]);
newflow=mcmf(to[i],minf); //流量要和flow[i]取min
ansc+=newflow*w[i];
f-=newflow;
flow[i]-=newflow;
flow[i^1]+=newflow;
newans+=newflow;
if(!f) break;
}
if(!newans) dis[now]=inf;
return newans;
}
int u,v,x,f,ansf;
int main()
{
n=getc();m=getc();
S=1;T=n; //不要忘记了
for(int i=1;i<=m;i++)
{
u=getc();v=getc();x=getc();
u=u==1? u:u+2*n;v=v==n? v:v+n;
if(u==1&&v==n)
add(u,v,x,1);
else
add(u,v,x,inf);
}
for(int i=2;i<n;i++)
{
add(i+n,i,0,1);
add(i,i+n*2,0,1);
}
while(spfa())
{
vis[T]=1;
while(vis[T]){
memset(vis,0,sizeof vis);
ansf+=mcmf(S,1e9);
}
}
printf("%d %d",ansf,ansc);
return 0;
}