#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

const int MAX=200;
bool dp1[MAX][MAX];
bool dp2[MAX][MAX];
bool dp3[MAX][MAX];
bool dp4[MAX][MAX];
bool dp5[MAX][MAX];
bool dp6[MAX][MAX];
bool dp7[MAX][MAX];

bool edge1[MAX][MAX];
bool edge2[MAX][MAX];
bool edge3[MAX][MAX];
bool edge4[MAX][MAX];
bool edge5[MAX][MAX];
bool edge6[MAX][MAX];

void out(int N){
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){cout<<dp1[i][j]<<" ";}
    cout<<endl;
  }
  cout<<endl;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){cout<<dp2[i][j]<<" ";}
    cout<<endl;
  }
  cout<<endl;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){cout<<dp3[i][j]<<" ";}
    cout<<endl;
  }
  cout<<endl;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){cout<<dp4[i][j]<<" ";}
    cout<<endl;
  }
  cout<<endl;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){cout<<dp5[i][j]<<" ";}
    cout<<endl;
  }
  cout<<endl;
}

bool culclation(){
  ll N,M,S,T;
  cin>>N>>M>>S>>T;
  S--; T--;
  if(N==0 && M==0){return false;}
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      dp1[i][j]=false;
      dp2[i][j]=false;
      dp3[i][j]=false;
      dp4[i][j]=false;
      dp5[i][j]=false;
      dp6[i][j]=false;
      dp7[i][j]=false;

      edge1[i][j]=false;
      edge2[i][j]=false;
      edge3[i][j]=false;
      edge4[i][j]=false;
      edge5[i][j]=false;
      edge6[i][j]=false;
    }
  }
  queue<pair<pll,int>> Q;
  for(int i=0;i<M;i++){
    int u,v;
    char c;
    cin>>u>>v>>c;
    u--; v--;
    if(c==')'){edge1[u][v]=true;}
    if(c=='('){edge2[u][v]=true;}
    if(c==']'){edge3[u][v]=true;}
    if(c=='['){edge4[u][v]=true;}
    if(c=='+'){edge5[u][v]=true;}
    if(c=='*'){edge6[u][v]=true;}
    if(c=='a'){dp1[u][v]=true; Q.push({{u,v},1});}
  }
  while(!Q.empty()){
    int u=Q.front().F.F,v=Q.front().F.S,tp=Q.front().S; Q.pop();
    if(dp1[u][v]){
      for(int w=0;w<N;w++){
        if(edge1[v][w] && !dp2[u][w]){
          dp2[u][w]=true;
          Q.push({{u,w},2});
        }
        if(edge3[v][w] && !dp3[u][w]){
          dp3[u][w]=true;
          Q.push({{u,w},3});
        }
        if(edge5[v][w] && !dp4[u][w]){
          dp4[u][w]=true;
          Q.push({{u,w},4});
        }
        if(edge6[v][w] && !dp5[u][w]){
          dp5[u][w]=true;
          Q.push({{u,w},5});
        }
      }
      for(int s=0;s<N;s++){
        if(edge5[s][u] && !dp6[s][v]){
          dp6[s][v]=true;
          Q.push({{s,v},6});
        }
        if(edge6[s][u] && !dp7[s][v]){
          dp7[s][v]=true;
          Q.push({{s,v},7});
        }
      }
    }
    if(dp2[u][v]){
      for(int s=0;s<N;s++){
        if(edge2[s][u] && !dp1[s][v]){
          dp1[s][v]=true;
          Q.push({{s,v},1});
        }
      }
    }
    if(dp3[u][v]){
      for(int s=0;s<N;s++){
        if(edge4[s][u] && !dp1[s][v]){
          dp1[s][v]=true;
          Q.push({{s,v},1});
        }
      }
    }
    if(dp4[u][v] || dp5[u][v]){
      for(int w=0;w<N;w++){
        if(dp1[v][w] && !dp1[u][w]){
          dp1[u][w]=true;
          Q.push({{u,w},1});
        }
      }
    }
    if(dp6[u][v] || dp7[u][v]){
      for(int s=0;s<N;s++){
        if(dp1[s][u] && !dp1[s][v]){
          dp1[s][v]=true;
          Q.push({{s,v},1});
        }
      }
    }
  }
  cout<<(dp1[S][T]?"Yes":"No")<<endl;
  // out(N);
  return true;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(culclation());

  


  return 0;
}



Measured memory_bytes: 9960