#include <iostream>
#include <vector>

int main() {
  int n, q;
  std::cin >> n >> q;
  std::vector<int> a[n];
  for (int i = 0; i < q; ++i) {
    int c, t;
    std::cin >> c >> t;
    switch (c) {
    case 0:
      int x;
      std::cin >> x;
      a[t].push_back(x);
      break;
    case 1:
      for (size_t i = 0; i < a[t].size(); i++) {
        if (i > 0)
          std::cout << " ";
        std::cout << a[t].at(i);
      }
      std::cout << std::endl;
      break;
    case 2:
      a[t].clear();
      break;
    }
  }
}

