#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5 + 20;
long long N, M, mn[maxn], mx[maxn], used[maxn];
vector<vector<long long> > vmx[maxn];
vector<pair<long long, long long> > use[maxn], vmn[maxn];
void find_mn() {
  priority_queue<pair<long long, long long>,
                 vector<pair<long long, long long> >,
                 greater<pair<long long, long long> > >
      heap;
  for (long long i = 1; i <= N; i++)
    if (mn[i] != ((long long)1e18 + 9))
      heap.push(pair<long long, long long>(mn[i], i));
  while (!heap.empty()) {
    pair<long long, long long> x = heap.top();
    heap.pop();
    if (used[x.second]) continue;
    long long node = x.second;
    long long val = x.first;
    used[node] = 1;
    mn[node] = val;
    for (long long i = 0; i < use[node].size(); i++) {
      pair<long long, long long> a = use[node][i];
      pair<long long, long long> &asd = vmn[a.first][a.second];
      asd.first--;
      asd.second += mn[node];
      if (asd.first == 0) {
        mn[a.first] = min(mn[a.first], asd.second);
        heap.push(pair<long long, long long>(mn[a.first], a.first));
      }
    }
  }
}
long long fmx(long long node) {
  if (used[node] == 1) return ((long long)1e18 + 9);
  long long &x = mx[node];
  if (x) return x;
  used[node] = 1;
  for (long long i = 0; i < vmx[node].size(); i++) {
    vector<long long> &v = vmx[node][i];
    bool flag = 0;
    for (long long j = 0; j < v.size(); j++)
      if (mn[v[j]] == ((long long)1e18 + 9)) {
        flag = 1;
        break;
      }
    if (flag) continue;
    long long sum = 0;
    for (long long j = 0; j < v.size(); j++) {
      if (v[j] == -1) {
        sum++;
        continue;
      }
      long long a = fmx(v[j]);
      if (a == ((long long)1e18 + 9)) {
        sum = ((long long)1e18 + 9);
        break;
      }
      sum += a;
    }
    x = max(x, sum);
  }
  used[node] = 2;
  return x;
}
void find_mx() {
  memset(used, 0, sizeof used);
  for (long long i = 1; i <= N; i++)
    if (!used[i]) fmx(i);
}
int main() {
  cin >> M >> N;
  for (long long i = 1; i <= N; i++) mn[i] = ((long long)1e18 + 9);
  for (long long i = 1; i <= M; i++) {
    long long type, piece;
    scanf("%lld %lld", &type, &piece);
    vector<long long> v;
    long long mon = 0, sum = 0;
    for (long long j = 1; j <= piece; j++) {
      long long a;
      scanf("%lld", &a);
      if (a != -1) {
        mon++;
        use[a].push_back(pair<long long, long long>(type, vmn[type].size()));
      } else
        sum++;
      v.push_back(a);
    }
    vmn[type].push_back(pair<long long, long long>(mon, sum));
    if (!mon) mn[type] = min(mn[type], sum);
    vmx[type].push_back(v);
  }
  find_mn();
  find_mx();
  for (long long i = 1; i <= N; i++) {
    if (mn[i] == ((long long)1e18 + 9)) {
      puts("-1 -1");
      continue;
    }
    printf("%lld ", min(314000000ll, mn[i]));
    if (mx[i] == ((long long)1e18 + 9))
      puts("-2");
    else
      printf("%lld\n", min(314000000ll, mx[i]));
  }
  return 0;
}
