/*By pigeatshit*/

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <map>
#define LL long long
#define reset(c,x) memset (c, x, sizeof (c))
#define PN printf("\n")
#define NN int n;scanf("%d", &n)
#define NM int n,m;scanf("%d%d", &n, &m)
#define NMK int n,m,k;scanf("%d%d%d", &n, &m, &k)

using namespace std;

int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};

int judge(char c)
{
    if(c == 'U') return 0;
    if(c == 'D') return 1;
    if(c == 'L') return 2;
    if(c == 'R') return 3;
    return -1;
}

struct MAZE
{
    char c;
    int damage;
} m[1005][1005];

struct S
{
    char dir;
    int walk;
} step[1005];

int potion[20];
int pflag[20];

int cmp(const int &aa, const int &bb)
{
    return aa<bb?1:0;
}

int dp[20][1005];

int main()
{
    int nowh,maxh;
    scanf("%d%d",&nowh,&maxh);
    while(nowh != 0 || maxh != 0)
    {
        int mark = 0;
        reset(pflag, 0);
        int r,c;
        scanf("%d%d",&r,&c);
//        getchar();
        for(int i = 0; i < r; i++)
        {
            char st[1005];
            scanf("%s",st);
            for(int j = 0; j < c; j++)
            {
                m[i][j].c = st[j];
            }
        }

//        for(int i = 0; i < r; i++)
//        {
//            for(int j = 0; j < c; j++)
//                printf("%c",m[i][j].c);
//            PN;
//        }
        int t;
        scanf("%d",&t);
        while(t--)
        {
            char kind[3];
            int dama;
            scanf("%s",kind);
            scanf("%d",&dama);
            for(int i = 0; i < r; i++)
                for(int j = 0; j < c; j++)
                    if(m[i][j].c == kind[0]) m[i][j].damage = dama;
        }
        int s;
        scanf("%d",&s);
        for(int i = 0; i < s; i++)
        {
            char tmp[3];
            scanf("%s",tmp);
            step[i].dir = tmp[0];
            scanf("%d",&step[i].walk);
        }

        int p;
        scanf("%d",&p);
        for(int i = 0; i < p; i++)
            scanf("%d",potion+i);

        sort(potion, potion+p, cmp);

        int posx = 0, posy = 0;
        for(int i = 0; i < s; i++)
        {
            char dirc = step[i].dir;
            int wak = step[i].walk;
            int next = judge(dirc);
            while(wak--)
            {
                struct MAZE posnow = m[posy + (dy[next])][posx + (dx[next])];
                if(posnow.damage >= maxh)
                {
                    printf("NO\n");
                    mark = 1;
                    break;
                }
                if(nowh - posnow.damage > 0)
                {
                    posx = posx + (dx[next]);
                    posy = posy + (dy[next]);
                    nowh -= posnow.damage;
                    continue;
                }
                int flag = 0;
                int minn = 0x7FFFFFFF;
                int rec = 0;
                for(int choose = 1; choose < 1<<p; choose++)
                {
                    int sum = 0;
                    for(int i = 0; i < p; i++)
                    {
                        int cc = (choose>>i)&1;
                        if(cc == 1 && pflag[i] == 0) sum += potion[i];
                    }
                    if(sum + nowh - posnow.damage <= 0) continue;
                    if(sum + nowh < minn)
                    {
                        minn = sum + nowh;
                        rec = choose;
                        flag = 1;
                    }
                }
                if(flag == 1)
                {
                    for(int i = 0; i < p; i++)
                    {
                        int cc = (rec>>i)&1;
                        if(cc == 1 && pflag[i] == 0)
                            pflag[i] = 1;
                    }
                    nowh = min(maxh, minn) - posnow.damage;
                    posx = posx + (dx[next]);
                    posy = posy + (dy[next]);
                }

                if(flag == 0)
                {
                    printf("NO\n");
                    mark = 1;
                    break;
                }
                if(mark == 1) break;
            }
            if(mark == 1) break;
        }

        if(mark == 0) printf("YES\n");
        scanf("%d%d",&nowh,&maxh);
    }
    return 0;
}

Measured memory_bytes: 1688