#include <bits/stdc++.h>
#define int long long
using namespace std;

const string TBL = "a()[]+*";
map<pair<int, int>, int> trans;

void solve() {
    int n, m, s, t; cin >> n >> m >> s >> t;
    if (n == 0) exit(0);
    s--; t--;

    vector<vector<vector<bool>>> dp(n, vector<vector<bool>>(n, vector<bool>(9)));
    struct X { int i, j, c; };
    queue<X> q;
    while (m--) {
        int i, j; cin >> i >> j;
        i--; j--;
        char c_; cin >> c_;
        int c = TBL.find(c_);
        if (c == 6) c--;
        if (!dp[i][j][c]) dp[i][j][c] = true, q.push({i, j, c});
    }

    while (!q.empty()) {
        X x = q.front(); q.pop();
        for (int c = 0; c < 9; c++) {
            // (x.i, x.j), (x.j, k) -> (x.i, k)
            if (trans.count({x.c, c})) {
                int c2 = trans[{x.c, c}];
                for (int k = 0; k < n; k++) {
                    if (dp[x.j][k][c] && !dp[x.i][k][c2]) {
                        dp[x.i][k][c2] = true;
                        q.push({x.i, k, c2});
                    }
                }
            }
            // (k, x.i), (x.i, x.j) -> (k, x.j)
            if (trans.count({c, x.c})) {
                int c2 = trans[{c, x.c}];
                for (int k = 0; k < n; k++) {
                    if (dp[k][x.i][c] && !dp[k][x.j][c2]) {
                        dp[k][x.j][c2] = true;
                        q.push({k, x.j, c2});
                    }
                }
            }
        }
    }
    cout << (dp[s][t][0] ? "Yes" : "No") << endl;
}

signed main() {
    trans[{0, 5}] = 6;
    trans[{1, 0}] = 7;
    trans[{3, 0}] = 8;
    trans[{6, 0}] = 0;
    trans[{7, 2}] = 0;
    trans[{8, 4}] = 0;
    while (1) solve();
}
