A = []
n, q = gets.chomp.split(" ").map &:to_i
n.times {
    A.push([])
}

q.to_i.times{
    choice,  t, x = gets.chomp.split(" ").map &:to_i
     case choice
     when 0
        A[t].push(x)
     when 1
        puts A[t].join(' ') 
     when 2
        A[t].clear
     end
}

