#include <bits/stdc++.h>
int main() {
  int x, k;
  int flag[5000] = {0};
  int index[5000] = {0};
  scanf("%d %d", &x, &k);
  if (k == 0) {
    printf("%d %d\n", x / 2, x - 1);
    return 0;
  }
  int i, j;
  for (i = 0; i < k; i++) {
    int temp, p, q;
    scanf("%d", &temp);
    if (temp == 1) {
      scanf("%d %d", &p, &q);
      flag[p] = 1;
      flag[q] = 1;
    } else if (temp == 2) {
      scanf("%d", &p);
      flag[p] = 1;
    }
  }
  flag[x] = 1;
  int chek = 0;
  for (i = 1; i <= x; i++) {
    if (flag[i] == 0) {
      chek = i;
      break;
    }
  }
  if (chek == 0) {
    printf("0 0\n");
    return 0;
  }
  int running = 1;
  int cont = 1;
  for (i = chek + 1; i <= x; i++) {
    if (flag[i] == 0 && cont == 1) {
      running++;
    } else if (flag[i] == 0 && cont == 0) {
      cont = 1;
      running = 1;
    } else if (flag[i] == 1 && cont == 1) {
      cont = 0;
      index[running]++;
      running = 0;
    } else if (flag[i] == 1 && cont == 0) {
      continue;
    }
  }
  if (cont == 1) {
    index[running]++;
  }
  int glmin = 0, glmax = 0;
  for (i = 1; i <= 4000; i++) {
    if (index[i] > 0) {
      glmin += index[i] * ((i + 1) / 2);
      glmax += index[i] * i;
    }
  }
  printf("%d %d\n", glmin, glmax);
  return 0;
}
