#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int n, m, ID, l, QQQ[100005], rule[100005], diamond[100005], tent_min[100005],
    M, x, idx, tent_max[100005], used[100005];
vector<int> monster[100005], QQQ_rule[100005], leader[100005];
set<pair<int, int> > S;
bool bad[100005];
int find_max(int v) {
  used[v]++;
  if (used[v] > 1) {
    tent_max[v] = -2;
    return -2;
  }
  if (tent_max[v]) {
    used[v]--;
    return tent_max[v];
  }
  for (int i = 0; i < leader[v].size(); i++) {
    int to = leader[v][i], sum = diamond[to];
    if (bad[to]) continue;
    for (int j = 0; j < QQQ_rule[to].size(); j++) {
      int tmp = find_max(QQQ_rule[to][j]);
      if (tmp == -2) {
        tent_max[v] = -2;
        return -2;
      }
      sum += tmp;
    }
    tent_max[v] = (tent_max[v] > sum ? tent_max[v] : sum);
  }
  used[v]--;
  return tent_max[v];
}
int main() {
  scanf("%d%d", &m, &n);
  for (long long i = 1; i <= m; i++) {
    scanf("%d%d", &ID, &l);
    QQQ[i] = ID;
    leader[ID].push_back(i);
    for (long long j = 1; j <= l; j++) {
      scanf("%d", &x);
      if (x != -1) {
        monster[x].push_back(i);
        rule[i]++;
        QQQ_rule[i].push_back(x);
      } else
        diamond[i]++;
    }
  }
  for (long long i = 1; i <= n; i++) tent_min[i] = 2000000000LL;
  for (long long i = 1; i <= m; i++)
    if (!rule[i])
      tent_min[QQQ[i]] =
          (tent_min[QQQ[i]] < diamond[i] ? tent_min[QQQ[i]] : diamond[i]);
  for (long long i = 1; i <= n; i++)
    if (tent_min[i] != 2000000000LL) S.insert(make_pair(tent_min[i], i));
  while (!S.empty()) {
    int v = S.begin()->second;
    S.erase(S.begin());
    for (int i = 0; i < monster[v].size(); i++) {
      int to = monster[v][i];
      if (rule[to]) {
        rule[to]--;
        if (!rule[to]) {
          int sum = diamond[to];
          for (int j = 0; j < QQQ_rule[to].size(); j++)
            sum += (tent_min[QQQ_rule[to][j]]);
          if (sum < tent_min[QQQ[to]]) {
            S.erase(make_pair(tent_min[QQQ[to]], QQQ[to]));
            tent_min[QQQ[to]] = sum;
            S.insert(make_pair(tent_min[QQQ[to]], QQQ[to]));
          }
        }
      }
    }
  }
  for (long long i = 1; i <= m; i++) {
    for (int j = 0; j < QQQ_rule[i].size(); j++)
      if (tent_min[QQQ_rule[i][j]] == 2000000000LL) {
        bad[i] = true;
        break;
      }
  }
  for (long long i = 1; i <= n; i++)
    if (!tent_max[i]) find_max(i);
  for (long long i = 1; i <= n; i++) {
    if (tent_min[i] == 2000000000LL)
      puts("-1 -1");
    else {
      if (tent_min[i] > 314000000) tent_min[i] = 314000000;
      if (tent_max[i] > 314000000) tent_max[i] = 314000000;
      printf("%d %d\n", tent_min[i], tent_max[i]);
    }
  }
}
