#include <bits/stdc++.h>
using namespace std;
vector<int> rule[100010], way[100010];
int minv[100010], maxv[100010];
int val[100010], n, m, vis[100010];
void read() {
  scanf("%d %d", &m, &n);
  for (int i = 1, p, s; i <= m; ++i) {
    scanf("%d %d", &p, &s);
    way[p].push_back(i);
    for (int j = 1; j <= s; ++j) {
      scanf("%d", &p);
      if (p == -1)
        ++val[i];
      else
        rule[i].push_back(p);
    }
  }
}
int Dp(int p) {
  if (vis[p] == 1) return 1 << 30;
  if (vis[p] == 2) return maxv[p];
  int &ans = maxv[p];
  vis[p] = 1;
  for (__typeof(way[p].begin()) r = way[p].begin(); r != way[p].end(); ++r) {
    int sum = val[*r];
    bool mark = true;
    for (__typeof(rule[*r].begin()) x = rule[*r].begin(); x != rule[*r].end();
         ++x) {
      if (minv[*x] == 1 << 30) mark = false;
      int a = Dp(*x);
      if (sum == 1 << 30 || a == 1 << 30)
        sum = 1 << 30;
      else
        sum = min(sum + a, 314000000);
    }
    if (mark) ans = max(ans, sum);
  }
  vis[p] = 2;
  return ans;
}
void print() {
  fill(minv + 1, minv + n + 1, 1 << 30);
  for (bool mark = true; mark;) {
    mark = false;
    for (int i = 1; i <= n; ++i)
      for (__typeof(way[i].begin()) r = way[i].begin(); r != way[i].end();
           ++r) {
        int sum = val[*r];
        for (__typeof(rule[*r].begin()) x = rule[*r].begin();
             x != rule[*r].end(); ++x) {
          if (minv[*x] == 1 << 30 || sum == 1 << 30)
            sum = 1 << 30;
          else
            sum = min(314000000, sum + minv[*x]);
        }
        if (minv[i] > sum) minv[i] = sum, mark = true;
      }
  }
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) Dp(i);
    if (minv[i] == 1 << 30)
      printf("%d %d\n", -1, -1);
    else
      printf("%d %d\n", minv[i], maxv[i] == 1 << 30 ? -2 : maxv[i]);
  }
}
int main() {
  read();
  print();
  return 0;
}
