#include <iostream>
#include<vector>

using namespace std;
void show(vector<int> a);

int main()
{
    int num;//数组数量
   cin>>num;
    vector <int>p[num];
    int opr;cin>>opr;
    while(opr--)
    {
        int oper;
        cin>>oper;
        switch(oper)
        {

            case 0:int number,mag;
            cin>>number>>mag;
            p[number].push_back(mag);
            break;
            case 1:int number1;
            cin>>number1;
            show(p[number1]);
            break;
            case 2:
                int number2;
                cin>>number2;
                if(p[number2].empty()==false)
                p[number2].clear();
                break;
        }

    }
}
void show(vector<int> a)
{
     vector<int>::iterator point;
     if(a.empty()==false)
     {
     for(point=a.begin();point!=a.end();point++)
     {
         vector<int>::iterator point1=point;
         if(++point1==a.end())
            cout<<*point<<endl;
         else
            cout<<*point<<" ";
     }
     }
     else cout<<endl;
}

