#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
const long long inF = 1e16;
const long long MAX_NUM = 1000 * 1000 * 314;
long long m, n, d[N], _have[N], have[N], dex[N], cnt[N], _need[N], need[N],
    now[N], min_dis[N], max_dis[N];
vector<int> vec[N], nei[N];
priority_queue<pair<long long, int>, vector<pair<long long, int>>,
               greater<pair<long long, int>>>
    pq;
void input() {
  cin >> m >> n;
  for (int i = 0; i < m; i++) {
    cin >> dex[i];
    _have[--dex[i]]++;
    int k, a;
    cin >> k;
    while (k--) {
      cin >> a;
      if (a == -1)
        cnt[i]++;
      else {
        vec[--a].push_back(i);
        nei[dex[i]].push_back(a);
        _need[i]++;
      }
    }
  }
}
void COPY() {
  copy(_have, _have + n, have);
  copy(_need, _need + m, need);
  copy(cnt, cnt + m, now);
}
void find_min() {
  fill(min_dis, min_dis + n, inF);
  COPY();
  for (int i = 0; i < m; i++)
    if (need[i] == 0) pq.push(pair<long long, int>(cnt[i], dex[i]));
  while (pq.size()) {
    pair<long long, int> p = pq.top();
    pq.pop();
    if (min_dis[p.second] != inF) continue;
    min_dis[p.second] = min(p.first, MAX_NUM);
    for (int q : vec[p.second]) {
      now[q] += p.first;
      if (--need[q] == 0) pq.push(pair<long long, int>(now[q], dex[q]));
    }
  }
}
bool ok[N];
void find_cycle() {
  queue<int> q;
  for (int i = 0; i < n; i++)
    if ((d[i] = nei[i].size()) == 0) q.push(i);
  for (int i = 0; i < n; i++) cerr << i + 1 << " d = " << d[i] << '\n';
  while (q.size()) {
    int v = q.front();
    cerr << v + 1 << " ok\n";
    q.pop();
    ok[v] = true;
    for (int u : vec[v])
      if (--d[dex[u]] == 0) q.push(dex[u]);
  }
}
priority_queue<pair<long long, int>> PQ;
bool bad[N];
void check(int i) {
  if (bad[i]) return;
  max_dis[dex[i]] = max(max_dis[dex[i]], now[i]);
  max_dis[dex[i]] = min(max_dis[dex[i]], MAX_NUM);
  if (--have[dex[i]] == 0)
    pq.push(pair<long long, int>(max_dis[dex[i]], dex[i]));
}
void find_max() {
  fill(max_dis, max_dis + n, -inF);
  COPY();
  for (int i = 0; i < n; i++)
    if (min_dis[i] == inF)
      for (int q : vec[i]) bad[q] = true;
  for (int i = 0; i < m; i++)
    if (bad[i]) have[dex[i]]--;
  for (int i = 0; i < m; i++)
    if (need[i] == 0) check(i);
  while (pq.size()) {
    pair<long long, int> p = pq.top();
    pq.pop();
    if (min_dis[p.second] == inF) continue;
    for (int q : vec[p.second]) {
      now[q] += max_dis[p.second];
      if (--need[q] == 0) check(q);
    }
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  input();
  find_min();
  find_max();
  for (int i = 0; i < n; i++) {
    if (min_dis[i] == inF)
      cout << "-1 -1\n";
    else
      cout << min_dis[i] << ' '
           << (max_dis[i] == -inF || have[i] ? -2LL : max_dis[i]) << '\n';
  }
}
