#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n,q,opt,t,x;
	cin >> n;
	vector<int> a[n];
	cin >> q;
	while (q--)
	{
		cin >> opt;
		if (opt == 0)
		{
			cin >> t >> x;
			a[t].push_back(x);
		}
		if (opt == 1)
		{
			cin >> t;
			if (a[t].size()>0)
			{
				cout << a[t][0];
				for (int i=1; i<a[t].size(); i++)
					cout << ' ' << a[t][i];
			}
			cout << endl;
		}
		if (opt == 2)
		{
			cin >> t;
			a[t].clear();
		}
	}
	return 0;
}
