#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

typedef std::vector<size_t> Participants;
std::vector< Participants > performance;

size_t diff(const Participants& a, const Participants& b)
{
    std::pair<Participants::const_iterator,
              Participants::const_iterator> pit;
    size_t minlen = std::min(a.size(), b.size());
    pit = mismatch(a.begin(), a.begin() + minlen, b.begin());
    if (pit.first == a.end() && pit.second == b.end()) return -1;
    if (pit.first == a.end()) return *pit.second;
    if (pit.second == b.end()) return *pit.first;
    return std::min(*pit.first, *pit.second);
}

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;
    performance.resize(n);
    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);
        }
    }

    for(size_t i = 0; i < n; ++i) {
        size_t ans = 0;
        for(size_t j = 0; j < n; ++j) if (i != j) {
            ans = std::max(ans, diff(performance[i], performance[j]));
        }
        ++ans;

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

    return 0;
}

