#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int main(){
    int n,q,query,x,t;;
    scanf("%d", &n);
    vector<int> A[n];
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {        
        scanf("%d %d", &query,&t);
        switch (query){
            case 0:
                scanf("%d",&x);
                A[t].push_back(x);                       
                break;
            case 1:
            if (A[t].size()==0)
            {
                printf("\n");
            }else
            {           
            
                printf("%d",A[t][0]);
                for(int i = 1; i < A[t].size(); i++){
                    printf(" %d",A[t][i]);
                }
                    printf("\n");
            }
                break;
            case 2:
                A[t].clear();
                break;
            default:
                break;
        }
    }    
    return 0;
}
