#include <iostream>
#include <vector>

using namespace std;

int main()
{
    vector<vector<int>> vecs;
    int N; cin >> N;
    int Q; cin >> Q;
    
    vecs.resize(N);
    
    for(int i = 0; i < Q; ++i)
    {
        int Command; cin >> Command;
        int t; cin >> t;
        if(Command == 0)
        {
            int val; cin >> val;
            vecs[t].push_back(val);
            
        }
        else if(Command == 1)
        {
            for(int k = 0; k < vecs[t].size(); ++k)
              cout << (k == 0 ? "" : " ") << vecs[t][k];
            cout << endl;
        }
        else if(Command == 2)
        {
            vecs[t].clear();
        }
    }

    return 0;
}
