MONEY = 5001

NONE, MOVE, GAIN, LOSE = (0..3).to_a
EVENT, VALUE = 0, 1

until (x, y, z = gets.split.map(&:to_i)).all?(&:zero?)
  roulette = gets.split.map(&:to_i)
  event = Array.new(y + 1){[NONE]}
  z.times do
    n, e, a = gets.split.map(&:to_i)
    event[n] = [e, a]
  end

  answer = 0.0
  dp = Array.new(y + 1){Array.new(MONEY){0.0}}
  dp[0][0] = 1
  y.times do |current|
    MONEY.times do |money|
      next if dp[current][money] == 0.0
      p = dp[current][money] / roulette.size.to_f
      roulette.each do |spot|
        nex = current + spot
        unless nex < y
          dp[y][money] += p
        else
          case event[nex][EVENT]
            when NONE
              dp[nex][money] += p
            when MOVE
              nex += event[nex][VALUE]
              if nex < y
                dp[nex][money] += p
              else
                dp[y][money] += p
              end
            when GAIN
              dp[nex][money + event[nex][VALUE]] += p
            when LOSE
              dp[nex][[0, money - event[nex][VALUE]].max] += p
          end
        end
      end
    end
  end
  p MONEY.times.map.inject(0.0){|result, money| result + money.to_f * dp[y][money]}.to_i
end