import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int X, Y, Z;
    int[] V;
    int[] F;
    int[] T;
    bool input() {
        scanf("%d %d %d\n", &X, &Y, &Z);
        if (X == 0 && Y == 0 && Z == 0) return false;
        Y++;
        F = new int[Y];
        T = new int[Y];
        V = readln.chomp.split(" ").map!(to!int).array;
        foreach (i; 0 .. Z) {
            int N, E, A; scanf("%d %d %d\n", &N, &E, &A);
            F[N] = A;
            T[N] = E;
        }
        return true;
    }
    void solve() {
        double[][] memo1 = new double[][](Y, Z * 100 + 1);
        double[][] memo2 = new double[][](Y, Z * 100 + 1);
        foreach (i; 0 .. Y) {
            memo1[i][] = -1;
            memo2[i][] = -1;
        }
        double dfs2(int x, int t) {
            double dfs1(int x, int t) {
                if (x >= Y) return t;
                if (memo1[x][t] >= 0) return memo1[x][t];
                double ret = 0;
                foreach (v; V) {
                    ret += dfs2(x + v, t);
                }
                return memo1[x][t] = ret / X;
            }
            if (x >= Y) return t;
            if (memo2[x][t] >= 0) return memo2[x][t];
            if (T[x] == 0) return dfs1(x, t);
            switch (T[x]) {
                case 1: return memo2[x][t] = dfs1(x + F[x], t);
                case 2: return memo2[x][t] = dfs1(x, t + F[x]);
                case 3: return memo2[x][t] = dfs1(x, max(0, t - F[x]));
                default: assert(0);
            }
        }
        writefln("%d", cast(int)dfs2(0, 0));
    }
    while (input) solve;
}