#include <bits/stdc++.h>
using namespace std;
const long long BIG = 314000000, INF = 2000000000LL * 2000LL;
const int black = 1, green = 2;
vector<pair<int, vector<int> > > e;
int n, m, t, kol, i, j, k, a;
vector<vector<int> > g;
long long f1[111111], f2[111111];
bool fr[111111];
int used[111111];
bool dfsF(int v) {
  if (fr[v]) return fr[v];
  if (used[v] == green)
    return false;
  else if (used[v] == black)
    return fr[v];
  used[v] = green;
  int j, id;
  fr[v] = false;
  for (size_t i = 0; i < g[v].size(); i++) {
    id = g[v][i];
    bool ff = true;
    for (j = 0; j < (int)e[id].second.size(); j++) {
      ff &= dfsF(e[id].second[j]);
    }
    fr[v] |= ff;
  }
  used[v] = black;
  return fr[v];
}
void dfs1(int v) {
  if (used[v] == green) {
    f1[v] = INF;
    return;
  } else if (used[v] == black)
    return;
  used[v] = green;
  int j, to, id;
  long long maxi = 0, f;
  bool ff;
  for (size_t i = 0; i < g[v].size(); i++) {
    id = g[v][i];
    f = e[id].first;
    ff = true;
    for (j = 0; j < (int)e[id].second.size(); j++) {
      to = e[id].second[j];
      dfs1(to);
      if (f1[to] >= INF || f >= INF) {
        f = INF;
      } else {
        f = min(BIG, f + f1[to]);
      }
      if (fr[to] == false) ff = false;
    }
    if (ff) maxi = max(maxi, f);
  }
  f1[v] = maxi;
  used[v] = black;
}
void dfs2(int v) {
  if (used[v] == green) {
    f2[v] = INF;
    return;
  } else if (used[v] == black)
    return;
  used[v] = green;
  int j, to, id;
  long long mini = INF, f;
  bool ff;
  for (size_t i = 0; i < g[v].size(); i++) {
    id = g[v][i];
    f = e[id].first;
    ff = true;
    for (j = 0; j < (int)e[id].second.size(); j++) {
      to = e[id].second[j];
      dfs2(to);
      if (f2[to] >= INF || f >= INF) {
        f = INF;
      } else {
        f = min(BIG, f + f2[to]);
      }
      if (fr[to] == false) ff = false;
    }
    if (ff) mini = min(mini, f);
  }
  f2[v] = mini;
  used[v] = black;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> m >> n;
  e.resize(m);
  g.resize(n + 1);
  for (i = 0; i < m; i++) {
    cin >> a >> kol;
    while (kol--) {
      cin >> t;
      if (t < 0)
        e[i].first++;
      else
        e[i].second.push_back(t);
    }
    sort(e[i].second.begin(), e[i].second.end());
    g[a].push_back(i);
  }
  memset(used, 0, sizeof(used[0]) * (n + 1));
  for (i = 1; i <= n; i++) used[i] = 0, dfsF(i);
  memset(used, 0, sizeof(used[0]) * (n + 1));
  for (i = 1; i <= n; i++) used[i] = 0, dfs1(i);
  memset(used, 0, sizeof(used[0]) * (n + 1));
  for (i = 1; i <= n; i++) used[i] = 0, dfs2(i);
  for (i = 1; i <= n; i++) {
    if (!fr[i])
      cout << "-1 -1\n";
    else {
      if (f2[i] >= INF)
        cout << -2 << ' ';
      else
        cout << min(f2[i], BIG) << ' ';
      if (f1[i] >= INF)
        cout << -2 << endl;
      else
        cout << min(f1[i], BIG) << endl;
    }
  }
  return 0;
}
