// NOTE: it is recommended to use this even if you don't understand the following code.

#include <fstream>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    // uncomment the two following lines if you want to read/write from files
    // ifstream cin("input.txt");
    // ofstream cout("output.txt");
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, M;
    cin >> N >> M;

    vector<int> C(M);
    for (int i = 0; i < M; i++) cin >> C[i];

    vector<int> K(N);
    vector<vector<int>> P(N), S(N);
    for (int i = 0; i < N; i++) {
        cin >> K[i];
        P[i].resize(K[i]);
        S[i].resize(K[i]);
        for (int j = 0; j < K[i]; j++) {
            cin >> P[i][j] >> S[i][j];
        }
    }

    vector<int> T(M);


    // INSERT YOUR CODE HERE


    for (int i = 0; i < M; ++i)
        cout << T[i] << " ";
    cout << endl;

    return 0;
}
