#include <bits/stdc++.h>
using namespace std;
int parent[100010];
int son[100010];
int aux[100010];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int j = 0; j < k; j++) {
    int m;
    scanf("%d", &m);
    for (int i = 0; i < m; i++) scanf("%d", &aux[i]);
    for (int i = 0; i < m - 1; i++) {
      parent[aux[i]] = aux[i + 1];
      son[aux[i + 1]] = aux[i];
    }
  }
  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (parent[i] == i + 1) continue;
    int j = i;
    while (parent[j] != 0) {
      int a = parent[j];
      son[parent[j]] = 0;
      parent[j] = 0;
      ans++;
      j = a;
    }
    ans++;
    if (son[i + 1] != 0) {
      j = son[i + 1];
      while (parent[j] != 0) {
        int a = parent[j];
        son[parent[j]] = 0;
        parent[j] = 0;
        ans++;
        j = a;
      }
    }
    if (parent[i + 1] != 0) {
      j = i + 1;
      while (parent[j] != 0) {
        int a = parent[j];
        son[parent[j]] = 0;
        parent[j] = 0;
        ans++;
        j = a;
      }
    }
    parent[i] = i + 1;
    son[i + 1] = i;
    cout << ans << endl;
  }
  cout << ans;
  return 0;
}
