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


int main() {
	vector<int> v[1000];
	int n;
	int q;
	int t, x;
	int query;
	cin >> n;
	cin >> q;

	for (int i = 0; i < q; i++)
	{
		cin >> query;
		switch (query)
		{
		case 0:
			cin >> t >> x;
			v[t].push_back(x);
			break;
		case 1:
			cin >> t;
			
			for (int i = 0; i < v[t].size(); i++)
			{
				if (i != 0)cout << " ";
				cout << v[t][i];
			}
			cout << endl;
			break;
		case 2:
			cin >> t;
			v[t].clear();
			break;

		}
	}


	return 0;
}

