#include <vector>
#include <iostream>
#define INF (1LL << 60)
using namespace std;
int main()
{
int V, E, A, B; long long F, T;
scanf("%d", &V);
scanf("%d", &E);
vector<vector<long long> > G(V, vector<long long>(V, INF));
vector<vector<long long> > H(V, vector<long long>(V, INF));
for (int i = 0; i < E; i++)
{
scanf("%d", &A);
scanf("%d", &B);
scanf("%lld", &F);
scanf("%lld", &T);
G[A - 1][B - 1] = F; H[A - 1][B - 1] = T;
G[B - 1][A - 1] = F; H[B - 1][A - 1] = T;
}
vector<vector<pair<long long, long long> > > dp(V, vector<pair<long long, long long> >(1 << V, make_pair(INF, 0))); dp[0][0] = make_pair(0, 1);
for (int i = 1; i < (1 << V); i++)
{
for (int j = 0; j < V; j++) // start
{
if (i & (1 << j))
{
for (int k = 0; k < V; k++) // end
{
if (G[j][k] != INF)
{
long long cost = dp[j][i - (1 << j)].first + G[j][k];
if (cost <= H[j][k])
{
if (dp[k][i].first > cost)
{
dp[k][i] = make_pair(cost, 0);
}
if (dp[k][i].first == cost)
{
dp[k][i].second += dp[j][(i - (1 << j))].second;
}
}
}
}
}
}
}
if (dp[0][(1 << V) - 1].first != INF)
{
printf("%lld %lld\n", dp[0][(1 << V) - 1].first, dp[0][(1 << V) - 1].second);
}
else
{
printf("IMPOSSIBLE\n");
}
return 0;
}
I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKI2RlZmluZSBJTkYgKDFMTCA8PCA2MCkKCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpCnsKCWludCBWLCBFLCBBLCBCOyBsb25nIGxvbmcgRiwgVDsKCglzY2FuZigiJWQiLCAmVik7CglzY2FuZigiJWQiLCAmRSk7CgoJdmVjdG9yPHZlY3Rvcjxsb25nIGxvbmc+ID4gRyhWLCB2ZWN0b3I8bG9uZyBsb25nPihWLCBJTkYpKTsKCgl2ZWN0b3I8dmVjdG9yPGxvbmcgbG9uZz4gPiBIKFYsIHZlY3Rvcjxsb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