#include<iostream>
#include<algorithm>
#include<stack>
using namespace std;
#define INF 1145141919810
long long s[20][20][2],n,m,a,b,c,d,e,f,g[20],r;
stack<int>S;
void dfs(){
if(S.size()==n && s[S.top()][1][0]!=0 && r+s[S.top()][1][0]<=s[S.top()][1][1]){
r+=s[S.top()][1][0];
if(r==e){f++;}
if(r<e){f=1;e=r;}
r-=s[S.top()][1][0];
return;
}
for(int i=1;i<=n;i++){
if(s[S.top()][i][0]!=0 && g[i]==0 && r+s[S.top()][i][0]<=s[S.top()][i][1]){
g[i]=1;
r+=s[S.top()][i][0];
S.push(i);
dfs();
}
}
int h=S.top();
g[h]=0;
S.pop();
r-=s[S.top()][h][0];
return;
}
int main(){
cin>>n>>m;
for(int i=1;i<=m;i++){
cin>>a>>b>>c>>d;
s[a][b][0]=c;s[a][b][1]=d;
s[b][a][0]=c;s[b][a][1]=d;
}
e=INF;f=0;
g[1]=1;
S.push(1);
dfs();
if(e!=INF){cout<<e<<' '<<f<<endl;}
else{cout<<"IMPOSSIBLE"<<endl;}
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGFsZ29yaXRobT4KI2luY2x1ZGU8c3RhY2s+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgSU5GIDExNDUxNDE5MTk4MTAKCmxvbmcgbG9uZyBzWzIwXVsyMF1bMl0sbixtLGEsYixjLGQsZSxmLGdbMjBdLHI7CnN0YWNrPGludD5TOwoKdm9pZCBkZnMoKXsKCWlmKFMuc2l6ZSgpPT1uICYmIHNbUy50b3AoKV1bMV1bMF0hPTAgJiYgcitzW1MudG9wKCldWzFdWzBdPD1zW1MudG9wKCldWzFdWzFdKXsKCQlyKz1zW1MudG9wKCldWzFdWzBdOwoJCWlmKHI9PWUpe2YrKzt9CgkJaWYocjxlKXtmPTE7ZT1yO30KCQlyLT1zW1MudG9wKCldWzFdWzBdOwoJCXJldHVybjsKCX0KCWZvcihpbnQgaT0xO2k8PW47aSsrKXsK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