#include <bits/stdc++.h>
using namespace std;
// #define DEBUG
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vll = vector<ll>;
using si = set<int>;
using sll = set<ll>;
vector<vi> adj;
vector<bool> visited;
vi topsort;
const int mod = 1e9 + 7;
void ts(int v){
visited[v] = true;
for (int i = 0; i < adj[v].size(); i++){
int u = adj[v][i];
if (!visited[u]) ts(u);
}
topsort.push_back(v);
}
int main(){
#ifdef DEBUG
freopen("out.txt", "w", stdout);
#endif
cin.tie(NULL);
ios_base::sync_with_stdio(false);
int n, l;
cin >> n >> l;
adj.resize(n + 1);
for (int i = 1; i <= l; i++){
int k; cin >> k;
for (int j = 0; j < k; j++){
int x; cin >> x;
adj[i].push_back(x);
}
}
visited.assign(n + 1, false);
ts(1);
reverse(topsort.begin(), topsort.end());
vll dp(n + 1);
dp[1] = 1;
for (int i = 0; i < topsort.size(); i++){
int v = topsort[i];
for (int j = 0; j < adj[v].size(); j++){
int u = adj[v][j];
dp[u] = (dp[u] + dp[v]) % mod;
}
}
ll total = 0;
ll once = 0;
for (int i = l + 1; i <= n; i++){
if (dp[i] > 0) once++;
total = (total + dp[i]) % mod;
}
cout << total << " " << once << endl;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgovLyAjZGVmaW5lIERFQlVHCgp1c2luZyBsbCA9IGxvbmcgbG9uZzsKdXNpbmcgaWkgPSBwYWlyPGludCwgaW50PjsKdXNpbmcgdmkgPSB2ZWN0b3I8aW50PjsKdXNpbmcgdmlpID0gdmVjdG9yPGlpPjsKdXNpbmcgdmxsID0gdmVjdG9yPGxsPjsKdXNpbmcgc2kgPSBzZXQ8aW50PjsKdXNpbmcgc2xsID0gc2V0PGxsPjsKCnZlY3Rvcjx2aT4gYWRqOwp2ZWN0b3I8Ym9vbD4gdmlzaXRlZDsKdmkgdG9wc29ydDsKY29uc3QgaW50IG1vZCA9IDFlOSArIDc7Cgp2b2lkIHRzKGludCB2KXsKICAgIHZpc2l0ZWRbdl0gPSB0cnVlOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBhZGpbdl0uc2l6ZSgpOyBpKyspewogICAgICAgIGludCB1ID0gYWRqW3ZdW2ldOwogICAgICAgIGlmICghdmlzaXRlZFt1XSkgdHModSk7CiAgICB9CiAgICB0b3Bzb3J0LnB1c2hfYmFjayh2KTsKfQoKaW50IG1haW4oKXsKCSNpZmRlZiBERUJVRwoJZnJlb3Blbigib3V0LnR4dCIsICJ3Iiwgc3Rkb3V0KTsKCSNlbmRpZgoJY2luLnRpZShOVUxMKTsKCWlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwoKICAgIGludCBuLCBsOwogICAgY2luID4+IG4gPj4gbDsKICAgIGFkai5yZXNpemUobiArIDEpOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gbDsgaSsrKXsKICAgICAgICBpbnQgazsgY2luID4+IGs7CiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBrOyBqKyspewogICAgICAgICAgICBpbnQgeDsgY2luID4+IHg7CiAgICAgICAgICAgIGFkaltpXS5wdXNoX2JhY2soeCk7CiAgICAgICAgfQogICAgfQogICAgdmlzaXRlZC5hc3NpZ24obiArIDEsIGZhbHNlKTsKICAgIHRzKDEpOwogICAgcmV2ZXJzZSh0b3Bzb3J0LmJlZ2luKCksIHRvcHNvcnQuZW5kKCkpOwogICAgdmxsIGRwKG4gKyAxKTsKICAgIGRwWzFdID0gMTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgdG9wc29ydC5zaXplKCk7IGkrKyl7CiAgICAgICAgaW50IHYgPSB0b3Bzb3J0W2ldOwogICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgYWRqW3ZdLnNpemUoKTsgaisrKXsKICAgICAgICAgICAgaW50IHUgPSBhZGpbdl1bal07CiAgICAgICAgICAgIGRwW3VdID0gKGRwW3VdICsgZHBbdl0pICUgbW9kOwogICAgICAgIH0KICAgIH0KICAgIGxsIHRvdGFsID0gMDsKICAgIGxsIG9uY2UgPSAwOwogICAgZm9yIChpbnQgaSA9IGwgKyAxOyBpIDw9IG47IGkrKyl7CiAgICAgICAgaWYgKGRwW2ldID4gMCkgb25jZSsrOwogICAgICAgIHRvdGFsID0gKHRvdGFsICsgZHBbaV0pICUgbW9kOwogICAgfQogICAgY291dCA8PCB0b3RhbCA8PCAiICIgPDwgb25jZSA8PCBlbmRsOwoJcmV0dXJuIDA7Cn0=