#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int n;                           // 空白の数
string p;                        // リストの文字
vector<vector<string> > formula; // パズル中の数式
string change;                   // 各空白に入れる文字
bool error;                      // 式計算のエラー有無

int calculate(const string& s, int a, int b)
{
    if(a > b){
        error = true;
        return 0;
    }

    int k = b;
    while(k >= a && s[k] != '+' && s[k] != '-')
        -- k;
    if(k >= a){
        int x = calculate(s, a, k-1);
        int y = calculate(s, k+1, b);
        if(s[k] == '+')
            return x + y;
        else
            return x - y;
    }

    if(b > a && s[a] == '0'){
        error = true;
        return 0;
    }

    k = b;
    while(k >= a && s[k] != '*' && s[k] != '/')
        -- k;
    if(k >= a){
        int x = calculate(s, a, k-1);
        int y = calculate(s, k+1, b);
        if(s[k] == '*'){
            return x * y;
        }else{
            if(y == 0 || x % y != 0){
                error = true;
                return 0;
            }
            return x / y;
        }
    }

    int ret = 0;
    for(int i=a; i<=b; ++i){
        ret *= 10;
        ret += s[i] - '0';
    }

    return ret;
}

bool check(const string& s)
{
    int k = s.find('=');
    if(k == string::npos || s.find('=', k+1) != string::npos)
        return false;

    error = false;
    bool ret = calculate(s, 0, k-1) == calculate(s, k+1, s.size()-1);
    return !error && ret;
}

bool solve(int x, bitset<10> bs)
{
    if(x == n)
        return true;

    for(int i=0; i<n; ++i){
        if(bs[i])
            continue;
        bs[i] = true;

        change[x] = p[i];
        bool ok = true;
        for(unsigned j=0; j<formula[x].size(); ++j){
            string t = formula[x][j];
            for(unsigned k=0; k<t.size(); ++k){
                if(isalpha(t[k]))
                    t[k] = change[t[k]-'a'];
            }
            if(!check(t))
                ok = false;
        }

        if(ok && solve(x+1, bs))
            return true;

        bs[i] = false;
    }

    return false;
}

int main()
{
    for(;;){
        int h, w;
        cin >> h >> w;
        if(h == 0)
            return 0;

        vector<string> s(h+2, string(w+2, '#'));
        int tmp = 0;
        for(int i=1; i<=h; ++i){
            for(int j=1; j<=w; ++j){
                cin >> s[i][j];
                if(s[i][j] == '.'){
                    s[i][j] = 'a' + tmp;
                    ++ tmp;
                }
            }
        }

        cin >> n;
        p.assign(n, ' ');
        for(int i=0; i<n; ++i)
            cin >> p[i];

        bool ng = false;
        formula.assign(n, vector<string>());
        for(int i=0; i<h+2; ++i){
            char c = 0;
            string t;
            for(int j=0; j<w+2; ++j){
                if(s[i][j] != '#'){
                    t += s[i][j];
                    if(isalpha(s[i][j]))
                        c = s[i][j];
                }else{
                    if(t.size() >= 3){
                        if(c == 0){
                            if(!check(t))
                                ng = true;
                        }else{
                            formula[c-'a'].push_back(t);
                        }
                    }
                    c = 0;
                    t = "";
                }
            }
        }
        for(int j=0; j<w+2; ++j){
            char c = 0;
            string t;
            for(int i=0; i<h+2; ++i){
                if(s[i][j] != '#'){
                    t += s[i][j];
                    if(isalpha(s[i][j]))
                        c = s[i][j];
                }else{
                    if(t.size() > 2){
                        if(c == 0){
                            if(!check(t))
                                ng = true;
                        }else{
                            formula[c-'a'].push_back(t);
                        }
                    }
                    c = 0;
                    t = "";
                }
            }
        }
        if(ng){
            cout << "No" << endl;
            continue;
        }

        change.assign(n, ' ');
        if(solve(0, 0))
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
}

Measured memory_bytes: 920