while gets do
  x, y, z = $_.split.map(&:to_i)
  break if [x, y, z].all?(&:zero?)
  sqs = Array.new(y + 1){{e:0, a:0, ps:Hash.new(0)}}
  vs = gets.split.map(&:to_i)
  z.times do
    n, e, a = gets.split.map(&:to_i)
    sqs[n][:e] = e
    sqs[n][:a] = e == 3 ? a * -1 : a
  end
  sqs[0][:ps][0] = 1.0
  sqs.each_with_index do |sq, i|
    break if i == y
    sq[:ps].each do |m, p|
      vs.each do |v|
        ni = i + v
        nsq = sqs[[ni, y].min]
        if nsq[:e] == 1  
          nsq = sqs[ni + nsq[:a]]
          nm = m
        else
          nm = [m + nsq[:a], 0].max
        end
        nsq[:ps][nm] += p / x
      end
    end
  end
  puts sqs[y][:ps].inject(0){|sum, (m, p)| sum += m * p}.to_i
end