#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
const long long INF = 314000000;
int M, N, X[MAXN];
vector<int> V[MAXN], has[MAXN], bel[MAXN];
long long KK[MAXN], ans1[MAXN], ans2[MAXN];
namespace pmin {
struct data {
  int u;
  long long d;
  data(int u = 0, long long d = 0) : u(u), d(d) {}
  bool operator<(const data& t) const { return d > t.d; }
};
bool vis[MAXN];
priority_queue<data> Q;
long long f[MAXN], K[MAXN];
int cnt[MAXN];
int main() {
  for (int i = 1; i <= M; ++i) K[i] = KK[i], cnt[i] = V[i].size();
  for (int i = 1; i <= N; ++i) f[i] = INF;
  for (int i = 1; i <= M; ++i)
    if (V[i].empty()) {
      f[X[i]] = min(f[X[i]], K[i]);
      Q.push(data(X[i], f[X[i]]));
    }
  while (!Q.empty()) {
    int u = Q.top().u;
    Q.pop();
    if (vis[u]) continue;
    vis[u] = 1;
    for (int i : bel[u]) {
      K[i] += f[u], --cnt[i];
      if (K[i] >= INF) K[i] = INF;
      if (!cnt[i]) f[X[i]] = min(f[X[i]], K[i]), Q.push(data(X[i], f[X[i]]));
    }
  }
  for (int i = 1; i <= N; ++i) {
    if (vis[i])
      ans1[i] = f[i];
    else
      ans1[i] = ans2[i] = -1;
  }
  return 0;
}
};  // namespace pmin
namespace pmax {
struct node {
  int v, next;
} E[MAXN];
int head[MAXN], Elen, deg[MAXN];
void add(int u, int v) {
  ++Elen, E[Elen].v = v, E[Elen].next = head[u], head[u] = Elen;
}
long long f[MAXN], K[MAXN];
bool ban[MAXN];
queue<int> Q;
int main() {
  for (int i = 1; i <= M; ++i) K[i] = KK[i];
  for (int i = 1; i <= M; ++i) {
    if (ans1[X[i]] == -1) ban[i] = 1;
    for (int j : V[i])
      if (ans1[j] == -1) ban[i] = 1;
  }
  for (int i = 1; i <= M; ++i)
    if (!ban[i]) {
      for (int j : V[i]) add(j, X[i]), ++deg[X[i]];
    }
  for (int i = 1; i <= N; ++i) f[i] = 0;
  for (int i = 1; i <= N; ++i)
    if (ans1[i] != -1 && !deg[i]) {
      Q.push(i);
      for (int j : has[i])
        if (!ban[j]) f[i] = max(f[i], K[j]);
    }
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int i : bel[u])
      if (!ban[i]) {
        K[i] += f[u];
        if (K[i] >= INF) K[i] = INF;
      }
    for (int i = head[u]; i; i = E[i].next) {
      --deg[E[i].v];
      if (!deg[E[i].v]) {
        Q.push(E[i].v);
        for (int j : has[E[i].v])
          if (!ban[j]) {
            f[E[i].v] = max(f[E[i].v], K[j]);
          }
      }
    }
  }
  for (int i = 1; i <= N; ++i)
    if (ans1[i] != -1) {
      if (deg[i])
        ans2[i] = -2;
      else
        ans2[i] = f[i];
    }
  return 0;
}
};  // namespace pmax
int main() {
  scanf("%d%d", &M, &N);
  int y, l;
  for (int i = 1; i <= M; ++i) {
    scanf("%d%d", &X[i], &l);
    has[X[i]].push_back(i);
    while (l--) {
      scanf("%d", &y);
      if (y == -1)
        ++KK[i];
      else
        V[i].push_back(y), bel[y].push_back(i);
    }
  }
  pmin::main();
  pmax::main();
  for (int i = 1; i <= N; ++i) {
    printf("%lld %lld\n", ans1[i], ans2[i]);
  }
  return 0;
}
