#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n, q, t, c, i, x;
    cin >> n;
    vector<int> vec[n];
    cin >> c;
    while (c--)
    {
        cin >> t >> q;
        if (t == 0)
        {
            cin >> x;
            vec[q].push_back(x);
        }
        if (t == 1)
        {
            for (i = 0; i < vec[q].size(); i++)
            {
                if (i)
                    cout << " ";
                cout << vec[q][i];
            }
            cout << endl;
        }
        if (t == 2)
        {
            vec[q].clear();
        }
    }
}
