#include <bits/stdc++.h>
using namespace std;
int ln[100050][3], n, m, li[100050 * 20], c[100050 * 2][3], v[100050],
    fr[100050], ss, d[100050], fi[100050];
bool b[100050], a[100050], dir[100050], rn[100050], rm[100050], cl[100050];
int st, low[100050], ans[100050][2], la[100050], cls;
long long cnt[100050];
inline int Read() {
  int x = 0;
  char y;
  bool z = 0;
  do y = getchar(), z |= y == '-';
  while (y < '0' || y > '9');
  do x = x * 10 + y - '0', y = getchar();
  while (y >= '0' && y <= '9');
  return z ? -x : x;
}
inline void Line(int x, int y, int z) {
  c[++ss][0] = y;
  c[ss][1] = fi[x];
  c[ss][2] = z;
  fi[x] = ss;
  dir[ss] = 1;
  c[++ss][0] = x;
  c[ss][1] = fi[y];
  c[ss][2] = z;
  fi[y] = ss;
  dir[ss] = 0;
}
void Solve0() {
  int le = 1, ri = 0;
  ss = 1;
  for (int i = 1; i <= st; i++) Line(ln[i][0], ln[i][1], ln[i][2]);
  for (int i = 1; i <= m; i++)
    if (!d[i]) li[++ri] = i;
  for (; le <= ri; le++) {
    rm[li[le]] = 1;
    if (!rn[fr[li[le]]]) {
      rn[fr[li[le]]] = 1;
      for (int i = fi[fr[li[le]]]; i; i = c[i][1])
        if (!dir[i] && (!(--d[c[i][2]]))) li[++ri] = c[i][2];
    }
  }
  memset(d, 0, sizeof(d));
  int now = 0;
  for (int i = 1; i <= st; i++)
    if (rm[ln[i][2]] && rn[ln[i][0]] && rn[ln[i][1]])
      swap(ln[++now], ln[i]), d[ln[now][2]]++;
  st = now;
}
inline void Update(int x, int y, int &ri) {
  if (!ans[x][0] || ans[x][0] > y) {
    ans[x][0] = y;
    if (!a[x]) a[li[++ri] = x] = 1;
  }
}
inline long long min(long long x, long long y) { return x < y ? x : y; }
void Solve1() {
  memset(fi, 0, sizeof(fi));
  ss = 1;
  for (int i = 1; i <= st; i++) Line(ln[i][0], ln[i][1], ln[i][2]);
  int le = 1, ri = 0;
  for (int i = 1; i <= m; i++)
    if (rm[i]) cnt[i] = v[i];
  for (int i = 1; i <= m; i++)
    if (rm[i] && !d[i]) Update(fr[i], v[i], ri);
  for (; le <= ri; le++) {
    a[li[le]] = 0;
    for (int i = fi[li[le]]; i; i = c[i][1])
      if (!dir[i]) {
        if (!b[li[le]]) d[c[i][2]]--;
        cnt[c[i][2]] = min((long long)314000000 * 100050,
                           cnt[c[i][2]] + ans[li[le]][0] - la[li[le]]);
        if (!d[c[i][2]]) Update(c[i][0], min(314000000, cnt[c[i][2]]), ri);
      }
    b[li[le]] = 1;
    la[li[le]] = ans[li[le]][0];
  }
}
int DFS(int x, int y) {
  low[x] = y;
  int k = ++st;
  li[st] = x;
  b[x] = 1;
  for (int i = fi[x]; i; i = c[i][1])
    if (dir[i]) {
      if (!low[c[i][0]])
        low[x] = min(low[x], DFS(c[i][0], y + 1));
      else if (b[c[i][0]])
        low[x] = min(low[x], low[c[i][0]]);
    }
  if (low[x] == y) {
    for (int i = k; i <= st; i++) cl[li[i]] = st > k, b[li[i]] = 0;
    st = k - 1;
  }
  return low[x];
}
void Tarjan() {
  st = 0;
  memset(b, 0, sizeof(b));
  for (int i = 1; i <= n; i++)
    if (rn[i] && !low[i]) DFS(i, 1);
}
void Solve2() {
  int le = 1, ri = 0;
  for (int i = 1; i <= n; i++)
    if (rn[i] && !cl[i])
      for (int j = fi[i]; j; j = c[j][1])
        if (c[j][0] == i) {
          cl[i] = 1;
          break;
        }
  for (int i = 1; i <= n; i++)
    if (cl[i]) li[++ri] = i;
  for (; le <= ri; le++)
    for (int i = fi[li[le]]; i; i = c[i][1])
      if (!dir[i] && !cl[c[i][0]]) cl[li[++ri] = c[i][0]] = 1;
}
void Solve3() {
  int le = 1, ri = 0;
  memset(d, 0, sizeof(d));
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= m; i++)
    if (rm[i]) cnt[i] = v[i];
  memset(v, 0, sizeof(v));
  for (int i = 1; i <= m; i++)
    if (rm[i]) la[i] = v[fr[i]], v[fr[i]] = i;
  for (int i = 3; i <= ss; i += 2)
    if (!cl[c[i ^ 1][0]]) d[c[i][0]]++;
  for (int i = 1; i <= n; i++)
    if (rn[i] && !cl[i] && !d[i]) li[++ri] = i;
  for (; le <= ri; le++) {
    for (int i = fi[li[le]]; i; i = c[i][1])
      if (dir[i]) cnt[c[i][2]] = min(314000000, cnt[c[i][2]] + ans[c[i][0]][1]);
    for (int i = v[li[le]]; i; i = la[i])
      ans[li[le]][1] = max(ans[li[le]][1], (int)cnt[i]);
    for (int i = fi[li[le]]; i; i = c[i][1])
      if (!dir[i] && !(--d[c[i][0]])) li[++ri] = fr[c[i][2]];
  }
}
int main() {
  m = Read();
  n = Read();
  for (int i = 1; i <= m; i++) {
    fr[i] = Read();
    int k = Read(), l;
    while (k--) {
      l = Read();
      if (l == -1)
        v[i]++;
      else
        ln[++st][0] = fr[i], ln[st][1] = l, ln[st][2] = i, d[i]++;
    }
  }
  Solve0();
  Solve1();
  Tarjan();
  Solve2();
  Solve3();
  for (int i = 1; i <= n; i++)
    if (!rn[i])
      puts("-1 -1");
    else
      printf("%d %d\n", ans[i][0], cl[i] ? -2 : ans[i][1]);
  return 0;
}
