#include <bits/stdc++.h>
using namespace std;
int Read() {
  char c;
  while (c = getchar(), (c != '-') && (c < '0' || c > '9'))
    ;
  bool neg = (c == '-');
  int ret = (neg ? 0 : c - 48);
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + c - 48;
  return neg ? -ret : ret;
}
const int MAXN = 100005, MAX = 314000000;
priority_queue<pair<int, int> > h;
int N, M, cnt, sr[MAXN], si[MAXN], st[MAXN], a[MAXN], b[MAXN], d[MAXN],
    ind[MAXN], c[MAXN], nxt[MAXN * 3], lnk[MAXN * 3], mi[MAXN], ma[MAXN],
    vis[MAXN];
bool inf[MAXN];
void Add(int *s, int x, int y) { lnk[++cnt] = y, nxt[cnt] = s[x], s[x] = cnt; }
void init() {
  scanf("%d%d", &M, &N);
  for (int i = 1; i <= M; i++) {
    a[i] = Read();
    int deg = Read();
    Add(si, a[i], i);
    for (int j = 1; j <= deg; j++) {
      int x = Read();
      if (x < 0)
        ++b[i];
      else
        Add(st, i, x), Add(sr, x, i);
    }
    ind[i] = deg - b[i], d[i] = b[i];
  }
}
int DP(int x) {
  if (vis[x]) return ma[x];
  vis[x] = 1;
  for (int i = si[x], y = lnk[i]; i; i = nxt[i], y = lnk[i]) {
    bool chk = 0;
    for (int j = st[y], k = lnk[j]; j; j = nxt[j], k = lnk[j])
      if (mi[k] < 0) {
        chk = 1;
        break;
      }
    if (chk) continue;
    int sum = b[y];
    for (int j = st[y], k = lnk[j]; j; j = nxt[j], k = lnk[j])
      if (vis[k] == 1)
        inf[x] = 1;
      else
        sum = min(sum + DP(k), MAX), inf[x] |= inf[k];
    ma[x] = max(ma[x], min(sum, MAX));
  }
  return vis[x] = 2, ma[x];
}
void work() {
  memset(mi, -1, sizeof(mi));
  for (int i = 1; i <= M; i++)
    if (!ind[i]) h.push(make_pair(-b[i], a[i]));
  while (!h.empty()) {
    pair<int, int> top = h.top();
    h.pop();
    if (mi[top.second] > -1) continue;
    mi[top.second] = -top.first;
    for (int i = sr[top.second], y = lnk[i]; i; i = nxt[i], y = lnk[i]) {
      d[y] = min(MAX, d[y] - top.first);
      if (--ind[y] == 0) h.push(make_pair(-d[y], a[y]));
    }
  }
  for (int i = 1; i <= N; i++)
    if (mi[i] > -1) DP(i);
  for (int i = 1; i <= N; i++)
    if (mi[i] < 0)
      puts("-1 -1");
    else
      printf("%d %d\n", mi[i], inf[i] ? -2 : ma[i]);
}
int main() {
  init();
  work();
  return 0;
}
