#include <bits/stdc++.h>
using namespace std;
int n, m, a[100005], dia[100005], b[100005], c[100005];
int mn[100005], mx[100005];
bool flag[100005], vis[100005];
vector<int> k[100005], g[100005], rg[100005];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    pq;
void dijkstra() {
  for (int i = 1; i <= m; i++)
    if (c[i] == 0) pq.push(make_pair(dia[i], a[i]));
  while (!pq.empty()) {
    int x = pq.top().first, y = pq.top().second;
    pq.pop();
    if (mn[y] > -1) continue;
    mn[y] = x;
    for (int i = 0; i < rg[y].size(); i++) {
      int z = rg[y][i];
      c[z]--;
      b[z] = min(b[z] + mn[y], 314000000);
      if (!c[z]) pq.push(make_pair(b[z], a[z]));
    }
  }
}
int dfs(int x) {
  if (vis[x]) return mx[x] = -2;
  if (mx[x]) return mx[x];
  vis[x] = true;
  for (int i = 0; i < k[x].size(); i++)
    if (!flag[k[x][i]]) {
      int w = dia[k[x][i]];
      for (int j = 0; j < g[k[x][i]].size(); j++) {
        int v = dfs(g[k[x][i]][j]);
        if (v == -2) {
          vis[x] = false;
          return mx[x] = v;
        }
        w = min(w + v, 314000000);
      }
      mx[x] = max(mx[x], w);
    }
  vis[x] = false;
  return mx[x];
}
int main() {
  memset(mn, -1, sizeof(mn));
  cin >> m >> n;
  for (int i = 1, s; i <= m && cin >> a[i] >> s; i++) {
    k[a[i]].push_back(i);
    for (int j = 1, x; j <= s && cin >> x; j++)
      if (x == -1)
        dia[i]++;
      else {
        g[i].push_back(x);
        rg[x].push_back(i);
      }
    c[i] = g[i].size();
    b[i] = dia[i];
  }
  dijkstra();
  for (int i = 1; i <= m; i++)
    for (int j = 0; j < g[i].size(); j++)
      if (mn[g[i][j]] == -1) flag[i] = true;
  for (int i = 1; i <= n; i++)
    if (mn[i] != -1)
      dfs(i);
    else
      mx[i] = -1;
  for (int i = 1; i <= n; i++) cout << mn[i] << ' ' << mx[i] << endl;
  return 0;
}
