#include <iostream>
#include <vector>
using namespace std;

void dump(const vector<int>& A)
{
    for (int i = 0; i < A.size(); i++) {
        if (i)
            cout << " ";
        cout << A[i];
    }
    cout << endl;
}
int main()
{
    int n, q;
    cin >> n >> q;
    vector<vector<int>> A(n);
    for (int i = 0; i < q; i++) {
        int query;
        cin >> query;
        if (query == 0) {
            int t, x;
            cin >> t >> x;
            A[t].push_back(x);
        }
        if (query == 1) {
            int t;
            cin >> t;
            dump(A[t]);
        }
        if (query == 2) {
            int t;
            cin >> t;
            A[t].clear();
        }
    }
    return 0;
}
