#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, q;
  cin >> n >> q;
  vector<vector<int> > v(n);
  for (int i = 0; i < q; i++) {
    int cmd;
    cin >> cmd;
    if (cmd == 0) {
      int t, x;
      cin >> t >> x;
      v.at(t).push_back(x);
    }
    if (cmd == 1) {
      int t;
      cin >> t;
      if (v.at(t).empty()) {
        cout << endl;
      } else {
        for (int j = 0; j < v.at(t).size(); j++) {
          if (j == v.at(t).size() - 1) {
            cout << v.at(t).at(j) << endl;
          } else {
            cout << v.at(t).at(j) << " ";
          }
        }
      }
    }
    if (cmd == 2) {
      int t;
      cin >> t;
      if (!v.at(t).empty())
      v.at(t).clear();
    }
  }
}
