A = []
n, q = gets.chomp
n.to_i.times {
    A.push([])
}

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

