#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<sstream>
#include<set>
#include<map>
#include<algorithm>
#include<cassert>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair

int n,m,g;
int v[4],e[51],val[51];
double dp[51][5001];

int main(){
	while(cin>>n>>g>>m,n){
		rep(i,n)cin>>v[i];
		rep(i,g+1)e[i]=0;
		rep(i,m){
			int a,b,c; cin>>a>>b>>c;
			e[a]=b; val[a]=c;
		}
		rep(i,g+1)rep(j,5001)dp[i][j]=0;
		dp[0][0]=1;
		
		rep(i,g)rep(j,5001)if(dp[i][j]>0){
			rep(k,n){
				int t=min(g,i+v[k]),money=j;
				if(e[t]==1){
					t=min(g,t+val[t]);
				}
				else if(e[t]==2){
					money+=val[t];
				}
				else if(e[t]==3){
					money=max(0,money-val[t]);
				}
				dp[t][money]+=dp[i][j]/n;
			}
		}
		
		double ans=0;
		rep(i,5001)ans+=dp[g][i]*i;
		cout<<(int)ans<<endl;
	}
	return 0;
}