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

/*
 S -> exp

0 exp -> exp opexp
 exp -> ( exp)
 exp -> [ exp]
 exp -> "a"
1 opexp -> op exp
2 exp) -> exp )
3 exp] -> exp ]
4 op -> "+" "*"
5 ) -> )
6 ] -> ]
7 ( -> (
8 [ -> [
*/

struct N {
  int i, j, k;
  int d;
};
bool operator<(const N &l, const N &r) { return l.d < r.d; }

int main() {
  int n, m, s, t;
  while (true) {
    cin >> n >> m >> s >> t;
    if (n == 0)
      break;
    s--;
    t--;
    vector<vector<pair<int, char>>> ps(n);
    for (int i = 0; i < m; i++) {
      int a, b;
      char c;
      cin >> a >> b >> c;
      a--;
      b--;
      ps[a].emplace_back(b, c);
    }
    vector<vector<vector<bool>>> dp(n);
    for (int i = 0; i < n; i++) {
      dp[i].resize(n);
      for (int j = 0; j < n; j++)
        dp[i][j].resize(9);
    }

    multiset<N> q;

    for (int i = 0; i < n; i++) {
      // i -> p.first p.second
      for (auto &p : ps[i]) {
        if (p.second == 'a') {
          dp[i][p.first][0] = true;
          q.insert(N{i, p.first, 0, 0});
        } else if (p.second == '+' || p.second == '*') {
          dp[i][p.first][4] = true;
          q.insert(N{i, p.first, 4, 0});
        } else if (p.second == ')') {
          dp[i][p.first][5] = true;
          q.insert(N{i, p.first, 5, 0});
        } else if (p.second == ']') {
          dp[i][p.first][6] = true;
          q.insert(N{i, p.first, 6, 0});
        } else if (p.second == '(') {
          dp[i][p.first][7] = true;
          q.insert(N{i, p.first, 7, 0});
        } else if (p.second == '[') {
          dp[i][p.first][8] = true;
          q.insert(N{i, p.first, 8, 0});
        }
      }
    }

    while (q.size()) {
      auto now = *q.begin();
      q.erase(q.begin());
      for (int i = 0; i < n; i++) {
        int k = now.i, j = now.j;
        if (!dp[i][j][0]) {
          if (now.k == 1 && dp[i][k][0] && dp[k][j][1]) {
            dp[i][j][0] = true;
            q.insert(N{i, j, 0, now.d + 1});
          } else if (now.k == 2 && dp[i][k][7] && dp[k][j][2]) {
            dp[i][j][0] = true;
            q.insert(N{i, j, 0, now.d + 1});
          } else if (now.k == 3 && dp[i][k][8] && dp[k][j][3]) {
            dp[i][j][0] = true;
            q.insert(N{i, j, 0, now.d + 1});
          }
        }
        if (!dp[i][j][1]) {
          if (now.k == 0 && dp[i][k][4] && dp[k][j][0]) {
            dp[i][j][1] = true;
            q.insert(N{i, j, 1, now.d + 1});
          }
        }
        if (!dp[i][j][2]) {
          if (now.k == 5 && dp[i][k][0] && dp[k][j][5]) {
            dp[i][j][5] = true;
            q.insert(N{i, j, 2, now.d + 1});
          }
        }
        if (!dp[i][j][3]) {
          if (now.k == 6 && dp[i][k][0] && dp[k][j][6]) {
            dp[i][j][6] = true;
            q.insert(N{i, j, 3, now.d + 1});
          }
        }
      }
      for (int j = 0; j < n; j++) {
        int i = now.i, k = now.j;
        if (!dp[i][j][0]) {
          if (now.k == 0 && dp[i][k][0] && dp[k][j][1]) {
            dp[i][j][0] = true;
            q.insert(N{i, j, 0, now.d + 1});
          } else if (now.k == 7 && dp[i][k][7] && dp[k][j][2]) {
            dp[i][j][0] = true;
            q.insert(N{i, j, 0, now.d + 1});
          } else if (now.k == 8 && dp[i][k][8] && dp[k][j][3]) {
            dp[i][j][0] = true;
            q.insert(N{i, j, 0, now.d + 1});
          }
        }
        if (!dp[i][j][1]) {
          if (now.k == 4 && dp[i][k][4] && dp[k][j][0]) {
            dp[i][j][1] = true;
            q.insert(N{i, j, 1, now.d + 1});
          }
        }
        if (!dp[i][j][2]) {
          if (now.k == 0 && dp[i][k][0] && dp[k][j][5]) {
            dp[i][j][2] = true;
            q.insert(N{i, j, 2, now.d + 1});
          }
        }
        if (!dp[i][j][3]) {
          if (now.k == 0 && dp[i][k][0] && dp[k][j][6]) {
            dp[i][j][3] = true;
            q.insert(N{i, j, 3, now.d + 1});
          }
        }
      }
    }
    if (dp[s][t][0]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 70136