### global variables

$rlts = []
$brds = []

$ecache = []

### subroutines

def exp_money(pos, money)
  return money if pos >= $brds.length
  return $ecache[pos][money] if ! $ecache[pos][money].nil?

  e, a = $brds[pos]
  case e
  when 1
    return ($ecache[pos][money] = exp_money(pos + a, money))
  when 2
    money += a
  when 3
    money = (money >= a) ? money - a : 0
  end

  msum = 0.0

  for v in $rlts
    msum += exp_money(pos + v, money)
  end

  $ecache[pos][money] = msum / $rlts.length
end

### main

while true
  x, y, z = gets.strip.split(' ').map{|s| s.to_i}
  break if x == 0 && y == 0 && z == 0

  $rlts = gets.strip.split(' ').map{|s| s.to_i}

  $brds = (0...y).map{[0, 0]}
  z.times do
    n, e, a = gets.strip.split(' ').map{|s| s.to_i}
    $brds[n] = [e, a]
  end
  #p $rlts
  #p $brds

  $ecache = (0...y).map{{}}
  #p $ecache

  puts exp_money(0, 0).to_i
end