#include <bits/stdc++.h>
using namespace std;
const int INF = 314000000;
const int N = 110000;
int vis[N], mn[N], mx[N], n, val[N];
vector<int> g[N], s[N];
int dfs(int x) {
  if (vis[x] == 1) return mn[0];
  if (vis[x] == 2) return mx[x];
  vis[x] = 1;
  for (int i = 0; i < g[x].size(); i++) {
    int ro = g[x][i];
    int sum = val[ro];
    bool o = true;
    for (int j = 0; j < s[ro].size(); j++) {
      int v = s[ro][j];
      if (mn[v] == mn[0]) o = false;
      int w = dfs(v);
      if (sum == mn[0] || w == mn[0])
        sum = mn[0];
      else
        sum = min(INF, sum + mx[v]);
    }
    if (o) mx[x] = max(mx[x], sum);
  }
  vis[x] = 2;
  return mx[x];
}
void work() {
  memset(mn, 0x3f, sizeof mn);
  while (1) {
    bool o = false;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j < g[i].size(); j++) {
        int ro = g[i][j];
        int sum = val[ro];
        for (int k = 0; k < s[ro].size(); k++) {
          int v = s[ro][k];
          if (mn[v] == mn[0] || sum == mn[0])
            sum = mn[0];
          else
            sum = min(INF, sum + mn[v]);
        }
        if (mn[i] > sum) {
          mn[i] = sum;
          o = true;
        }
      }
    }
    if (!o) break;
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) dfs(i);
    if (mn[i] == mn[0])
      puts("-1 -1");
    else
      printf("%d %d\n", mn[i], mx[i] == mn[0] ? -2 : mx[i]);
  }
}
int main() {
  int m;
  scanf("%d%d", &m, &n);
  for (int i = 1, u, ss; i <= m; i++) {
    scanf("%d%d", &u, &ss);
    g[u].push_back(i);
    for (int j = 1, v; j <= ss; j++) {
      scanf("%d", &v);
      if (v == -1)
        val[i]++;
      else
        s[i].push_back(v);
    }
  }
  work();
  return 0;
}
