#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

int v[4];
int e[51];
int a[51];
double dp[51][5010][2];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int vn, g, en;
	while (cin >> vn >> g >> en , vn) {

		for (int i = 0; i < vn; i++) {
			cin >> v[i];
		}

		memset(e, 0, sizeof e);
		for (int i = 0; i < en; i++) {
			int n;
			cin >> n;
			cin >> e[n] >> a[n];
		}

		memset(dp, 0, sizeof dp);
		dp[0][0][0] = 1.0;

		for (int i = 0; i < g; i++) {
			for (int j = 0; j <= 5000; j++) {
				for (int skip = 0; skip <= 1; skip++) {
					if (dp[i][j][skip] == 0) continue;

					int nj = j;
					if (skip == 0) {
						if (e[i] == 1) {
							int ni = min(i + a[i], g);
							dp[ni][j][1] += dp[i][j][0];
							continue;
						}
						if (e[i] == 2) nj = j + a[i];
						if (e[i] == 3) nj = max(0, j - a[i]);
					}

					for (int k = 0; k < vn; k++) {
						int ni = min(i + v[k], g);
						dp[ni][nj][0] += dp[i][j][skip] / vn;
					}
				}
			}
		}

		double ans = 0;
		for (int j = 0; j <= 5000; j++) {
			for (int s = 0; s < 2; s++) {
				ans += j * dp[g][j][s];
			}
		}
		cout << int(ans) << endl;
	}
}