#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;
int main()
{
    vector<vector <int>> a;
    int n, q, t, x, m, query;
    cin >> n >> q;
    a.resize(n);
    for (int i=0; i<q; ++i){
        cin >> query;
        switch(query){
            case 0:
                cin >> t >> x;
                a[t].push_back(x);
                break;
            case 1:
                cin >> t;
                if(!a[t].empty()){
                    m = a[t].size();
                    for (int i=0; i<m; ++i){
                        if(i == m-1){
                            cout << a[t][i] << endl;
                        }
                        else {
                            cout << a[t][i] << " ";
                        }
                    }
                }
                else {
                    cout << endl;
                }
                break;
            case 2:
                cin >> t;
                if(!a[t].empty()){
                    a[t].clear();
                }
                break;
        }
    }
}
