#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

struct ClassInfo
{
    ClassInfo(): size(0), lastChange(0){ }
    ClassInfo(size_t size, size_t lastChange): size(size), lastChange(lastChange){ }
    size_t size;
    size_t lastChange;
};

typedef std::pair<size_t, size_t> ClassUser;
typedef std::vector<ClassUser> ClassUsers;

class UserClassificator
{
public:
    UserClassificator(size_t numUsers)
        :numPerformance(0),
         userClass(numUsers, 0),
         classes(1, ClassInfo(numUsers, 0))
    { }

    void addPerformance(const std::vector<size_t>& users)
    {
        ClassUsers performance = preparePerformance(users);
        ClassUsers::iterator rangeStart = performance.begin(), end = performance.end();
        while (rangeStart != performance.end()) {
            ClassUsers::iterator rangeEnd = rangeStart + 1;
            while (rangeEnd != end && rangeEnd->first == rangeStart->first) {
                ++rangeEnd;
            }
            processNewClass(rangeStart, rangeEnd);
            rangeStart = rangeEnd;
        }
        ++numPerformance; 
    }

    const ClassInfo& classInfo(size_t user) const
    {
        return classes[userClass[user]];
    }

private:
    ClassUsers preparePerformance(const std::vector<size_t>& users) const
    {
        ClassUsers performance;
        performance.reserve(users.size());
        for(std::vector<size_t>::const_iterator it = users.begin(), ie = users.end();
                it != ie; ++it) {
            performance.push_back(ClassUser(userClass[*it], *it));
        }
        std::sort(performance.begin(), performance.end());
        return performance;
    }

    void processNewClass(ClassUsers::iterator begin, ClassUsers::iterator end)
    {
        ClassInfo& classInfo = classes[begin->first];
        size_t numInNewClass = std::distance(begin, end);
        if (numInNewClass == classInfo.size) {
            //no new information
            return;
        }
        classInfo.size -= numInNewClass;
        classInfo.lastChange = numPerformance;
        size_t newClass = classes.size();
        classes.push_back(ClassInfo(numInNewClass, numPerformance));
        for(; begin != end; ++begin) userClass[begin->second] = newClass;            
    }

    size_t numPerformance;
    std::vector<size_t> userClass;
    std::vector<ClassInfo> classes;
};

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;
    assert(n <= 100 && m <= 100);
    UserClassificator classificator(n);
    size_t sumK = 0;
    for(size_t step = 0; step < m; ++step) {
        size_t k;
        std::cin >> k;
        sumK += k;
        std::vector<size_t> users;
        users.reserve(k);
        for(size_t t = 0; t < k; ++t) {
            size_t user;
            std::cin >> user;
            users.push_back(user - 1);
        }
        classificator.addPerformance(users);
    }
    assert(sumK <= 100);
    for(size_t i = 0; i < n; ++i) {
        const ClassInfo& info = classificator.classInfo(i);
        if (i > 0) std::cout << " ";
        if (info.size > 1) std::cout << 0; else std::cout << info.lastChange + 1;
    }
    std::cout << std::endl;
    return 0;
}

