import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nq = readints;
    int n = nq[0], q = nq[1];

    auto xxs = new int[][](n);
    for (int i = 0; i < q; i++) {
        auto query = readints;
        switch (query[0]) {
        case 0:
            xxs[query[1]] ~= query[2];
            break;
        case 1:
            writeln(xxs[query[1]].map!(to!string).join(" "));
            break;
        case 2:
            xxs[query[1]] = [];
            break;
        default:
            break;
        }
    }
}

