#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string.h>

typedef std::vector<unsigned short int> Participants;
const int NMAX = 10000;
Participants performance[NMAX];

size_t diff(const Participants& a, const Participants& b)
{
    size_t minlen = std::min(a.size(), b.size());
    for(size_t i = 0; i < minlen; ++i) {
        if (a[i] != b[i]) return std::min(a[i], b[i]);
    }
    if (a.size() == b.size()) return -1;
    if (a.size() < b.size()) return b[minlen];
    return a[minlen];
}

int main () {
    freopen("theatre.in", "r", stdin);
    freopen("theatre.out", "w", stdout);
    std::ios_base::sync_with_stdio(false);
    size_t n, m;
    std::cin >> n >> m;
    for(size_t step = 0; step < m; ++step) {
        size_t k;
        std::cin >> k;
        for(size_t t = 0; t < k; ++t) {
            size_t user;
            std::cin >> user;
            performance[user - 1].push_back(step);
        }
    }

    std::vector<size_t> res(n, 0);
    for(size_t i = 0; i < n; ++i) {
        size_t ans = res[i];

        for(size_t j = i + 1; j < n; ++j) {
            size_t cres = diff(performance[i], performance[j]);
            ans = std::max(ans, cres);
            res[j] = std::max(res[j], cres);
        }
        ++ans;

        if (i > 0) std::cout << " ";
        std::cout << ans;
    }
    std::cout << std::endl;

    return 0;
}

