#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vb vector< bool >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define sort(a) sort(a.begin(),a.end())
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define moddd (1000*1000*1000+9)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define endl "\n"
#define flush fflush(stdout)
#define pi 3.14159265358979323846264338327950
#define primeDEN 727999983
//cout<<fixed<<setprecision(15)<<ans;

template <typename T>
void printvec(vector<T>& vec){
	for(int i=0;i<vec.size();i++){
		cout<<vec[i]<<" ";
	}
	cout<<endl;
}

typedef struct edge{
	int a;
	int b;
	bool isartifact;
	bool isbridge;
}edge;

vector<vector<edge> > adj(300*1000);
vector<vector<edge> > tree(300*1000);
vector<edge> edgearr(300*1000);
vb visited(300*1000,false),isarti(300*1000,false);
vi disc(300*1000,INT_MAX),low(300*1000);
vi comp(300*1000);
int ctr=0;

void bridgedfs(int curr,int prev){
	visited[curr]=true;
	//cout<<curr<<" "<<ctr<<endl;
	disc[curr]=ctr;
	low[curr]=ctr;
	ctr++;
	int children=0;
	int i;
	for(i=0;i<adj[curr].size();i++){
		if(!visited[adj[curr][i].b]){
			children++;
			bridgedfs(adj[curr][i].b,curr);
			low[curr]=min(low[curr],low[adj[curr][i].b]);
			// if(prev==-1&&children>=2){
			// 	adj[curr][i].isbridge=true;
			// 	//cout<<adj[curr][i].a<<" "<<adj[curr][i].b<<endl;
			// 	if(children==2){
			// 		adj[curr][0].isbridge=true;
			// 		//cout<<adj[curr][i].a<<" "<<adj[curr][i].b<<endl;
			// 	}
			// }
			if(low[adj[curr][i].b]>disc[curr]){
				adj[curr][i].isbridge=true;
			}
		}
		else if(adj[curr][i].b!=prev){
			//if(curr==5) cout<<adj[curr][i].b<<disc[adj[curr][i].b]<<endl;
			low[curr]=min(low[curr],disc[adj[curr][i].b]);
		}
	}
}

void constructtree(int curr,int prev,int num){
	visited[curr]=true;
	comp[curr]=num;
	int i;
	int x=num;
	for(i=0;i<adj[curr].size();i++){
		if(visited[adj[curr][i].b]){
			//cout<<curr<<" "<<adj[curr][i].b<<" "<<num<<" "<<isarti[num]<<endl;
			if(adj[curr][i].isartifact) isarti[num]=true;
			continue;
		}
		if(adj[curr][i].isbridge){
			continue;
			constructtree(adj[curr][i].b,curr,++x);
			tree[comp[curr]].pb(edge{comp[curr],comp[adj[curr][i].b],adj[curr][i].isartifact,false});
			tree[comp[adj[curr][i].b]].pb(edge{comp[adj[curr][i].b],comp[curr],adj[curr][i].isartifact,false});
		}
		else{
			constructtree(adj[curr][i].b,curr,num);
			if(adj[curr][i].isartifact) isarti[num]=true;
		}
	}
}

int aa,bb;

void dfs(int curr,int prev,bool found){
	visited[curr]=true;
	found=found||isarti[curr];
	if(comp[bb]==curr&&found){
		cout<<"YES";
		exit(0);
	}
	int i;
	for(i=0;i<tree[curr].size();i++){
		if(!visited[tree[curr][i].b]){
			dfs(tree[curr][i].b,curr,tree[curr][i].isartifact||found);
		}
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	int ttt=1;
	//cin>>ttt;
	while(ttt--){
		int n,m,ans=0;
		cin>>n>>m;
		int i;
		for(i=0;i<m;i++){
			int a,b,c;
			cin>>a>>b>>c;
			a--; b--;
			adj[a].pb(edge{a,b,c,false});
			adj[b].pb(edge{b,a,c,false});
			edgearr[i]=edge{a,b,c,false};
			edgearr[i]=edge{b,a,c,false};
		}
		bridgedfs(0,-1);
		for(i=0;i<n;i++){
			visited[i]=false;
		}
		int x=0;
		for(i=0;i<n;i++){
			if(!visited[i]) constructtree(i,-1,x++);
		}
		for(i=0;i<m;i++){
			if(comp[edgearr[i].a]==comp[edgearr[i].b]) continue;
			//cout<<comp[edgearr[i].a]<<" "<<comp[edgearr[i].b]<<" "<<edgearr[i].isartifact<<endl;
			tree[comp[edgearr[i].a]].pb(edge{comp[edgearr[i].a],comp[edgearr[i].b],edgearr[i].isartifact,false});
			tree[comp[edgearr[i].b]].pb(edge{comp[edgearr[i].b],comp[edgearr[i].a],edgearr[i].isartifact,false});
		}
		cin>>aa>>bb;
		aa--; bb--;
		for(i=0;i<n;i++){
			visited[i]=false;
		}
		//for(int i=0;i<n;i++) cout<<comp[i]<<" ";
		dfs(comp[aa],-1,false);

		//	cout<<isarti[0]<<endl;
		cout<<"NO";
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pb push_back
#define sz size
#define F first
#define S second
int inf =1e9;
const int N=3e5+3;
int low[N], Num[N], tim=1;
vector<pair<int, pair<int,int>>>adj[N];
bool bridge[N];
void dfs(int u, int p)
{
    low[u] = Num[u] = tim++;

    for (auto d: adj[u])
    {
        int idx =d .S .S;
        if (d.F == p)
            continue;

        if (Num[d.F] == 0)
        {
            dfs(d.F, u);
            if (low[d.F] > Num[u])
            {
                bridge[idx]=1;
            }
            low[u] = min(low[u], low[d.F]);
        }
        else
            low[u] = min(low[u], Num[d.F]);
    }

}
int color=1;
bool f;
int vis[N];
bool bn [N];
void dfs2(int u)
{
    vis[u] =color;
    for (auto v : adj[u]) {
        if(bridge[v.S.S]){
            continue;
        }
        if (!vis[v.F])
        {
           if(v .S.F )
                f =1;
           dfs2(v.F);
        }
    }

}
int a,b;
bool f2;
bool vis3[N];
void dfs3(int u)
{
    vis3[u]=1;
    for(auto v:adj[u]){
        if(!vis3[v.F]){
            if(bridge[v.S.S])if(v.S.F)f=1;
            if(v.F==b&&f){f2=1;}
            dfs3(v.F);
        }

    }
}

int main()
{
#ifdef Mohammad
    freopen("input.in","r",stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin >> n >> m;
    for (int i=1; i<= m ; i++)
    {
        int u,v,w;
        cin >> u >> v >> w;
        adj[u].pb({ v, {w,i}});
        adj[v].pb({ u, {w,i}});
    }
    dfs(1, 0);
    cin >> a >>b;
    for (int i=1; i<= n; i++)
    {
        f=0;
        if (!vis[i])
            dfs2(i);
        if (f)
            bn [color]= 1;
        color++;
    }
    if(vis[a]==vis[b]){
        if(bn[ vis[a] ] )cout<<"YES"<<endl;
        else cout<<"NO\n";
        return 0;
    }
    f=0;
    dfs3(a);
    if(f2||bn[vis[a]]||bn[vis[b]])cout<<"YES\n";
    else cout<<"NO\n";
}


#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pb push_back
#define sz size
#define F first
#define S second
int inf =1e9;
const int N=3e5+3;
int low[N], Num[N], tim=1;
vector<pair<int, pair<int,int>>>adj[N];
bool bridge[N];
void dfs(int u, int p)
{
    low[u] = Num[u] = tim++;

    for (auto d: adj[u])
    {
        int idx =d .S .S;
        if (d.F == p)
            continue;

        if (Num[d.F] == 0)
        {
            dfs(d.F, u);
            if (low[d.F] > Num[u])
            {
                //cout<<idx<<endl;
                bridge[idx]=1;
            }
            low[u] = min(low[u], low[d.F]);
        }
        else
            low[u] = min(low[u], Num[d.F]);
    }

}
int color=1;
bool f;
int vis[N];
bool bn [N];
void dfs2(int u)
{
    //cout<<u<<endl;
    vis[u] =color;
    for (auto v : adj[u]) {
        if(bridge[v.S.S]){
            continue;
        }
        if(v .S.F )f =1;
        if (!vis[v.F])
        {
           dfs2(v.F);
        }
    }

}
int a,b;
bool f2;
bool vis3[N];
void dfs3(int u ,bool fl )
{
    //cout<<u<<endl;
    vis3[u]=1;
    for(auto v:adj[u]){
        if(!vis3[v.F]){
            if(v.F==b&&(fl|v.S.F)){f2=1;}
            dfs3(v.F,fl|v.S.F);
        }

    }
}

int main()
{
#ifdef Mohammad
    freopen("input.in","r",stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin >> n >> m;
    for (int i=1; i<= m ; i++)
    {
        int u,v,w;
        cin >> u >> v >> w;
        adj[u].pb({ v, {w,i}});
        adj[v].pb({ u, {w,i}});
    }
    dfs(1, 0);
    cin >> a >>b;
    for (int i=1; i<= n; i++)
    {
        f=0;
        if (!vis[i])
            dfs2(i);
        if(f) bn[color]= 1;
        color++;
    }
    if(vis[a]==vis[b]){
        if( bn[ vis[a] ] )cout<<"YES"<<endl;
        else cout<<"NO\n";
        return 0;
    }
    f=0;
    dfs3(a,0);
    if(f2||bn[vis[a]]||bn[vis[b]])cout<<"YES\n";
    else cout<<"NO\n";
}


#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pb push_back
#define sz size
#define F first
#define S second
int inf =1e9;
const int N=3e5+3;
int low[N], Num[N], tim=1;
vector<pair<int, pair<int,int>>>adj[N];
bool bridge[N];
void dfs(int u, int p)
{
    low[u] = Num[u] = tim++;

    for (auto d: adj[u])
    {
        int idx =d .S .S;
        if (d.F == p)
            continue;

        if (Num[d.F] == 0)
        {
            dfs(d.F, u);
            if (low[d.F] > Num[u])
            {
                //cout<<idx<<endl;
                bridge[idx]=1;
            }
            low[u] = min(low[u], low[d.F]);
        }
        else
            low[u] = min(low[u], Num[d.F]);
    }

}
int color=1;
bool f;
int vis[N];
bool bn [N];
void dfs2(int u)
{
    vis[u] =color;
    for (auto v : adj[u]) {
        if(bridge[v.S.S]){
            continue;
        }
        if (!vis[v.F])
        {
           if(v .S.F )
                f =1;
           dfs2(v.F);
        }
    }

}
int a,b;
bool f2;
bool vis3[N];
void dfs3(int u ,bool fl )
{
    //cout<<u<<endl;
    vis3[u]=1;
    for(auto v:adj[u]){
        if(!vis3[v.F]){
            if(v.F==b&&(fl|v.S.F)){f2=1;}
            dfs3(v.F,fl|v.S.F);
        }

    }
}

int main()
{
#ifdef Mohammad
    freopen("input.in","r",stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin >> n >> m;
    for (int i=1; i<= m ; i++)
    {
        int u,v,w;
        cin >> u >> v >> w;
        adj[u].pb({ v, {w,i}});
        adj[v].pb({ u, {w,i}});
    }
    dfs(1, 0);
    cin >> a >>b;
    for (int i=1; i<= n; i++)
    {
        f=0;
        if (!vis[i])
            dfs2(i);
        if (f)
            bn [color]= 1;
        color++;
    }
    if(vis[a]==vis[b]){
        if(bn[ vis[a] ] )cout<<"YES"<<endl;
        else cout<<"NO\n";
        return 0;
    }
    f=0;
    dfs3(a,0);
    if(f2||bn[vis[a]]||bn[vis[b]])cout<<"YES\n";
    else cout<<"NO\n";
}


#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pb push_back
#define sz size
#define F first
#define S second
int inf =1e9;
const int N=3e5+3, L= 20;
int low[N], Num[N], tim=1;
vector<pair<int, pair<int,int>>>adj[N];
bool bridge[N];
int a,b;
int color=1;
bool f;
int vis[N];
bool bn [N];
void dfs(int u, int p)
{
    low[u] = Num[u] = tim++;

    for (auto d: adj[u])
    {
        int idx =d .S .S;
        if (d.F == p)
            continue;

        if (Num[d.F] == 0)
        {
            dfs(d.F, u);
            if (low[d.F] > Num[u])
            {
                //cout<<idx<<endl;
                bridge[idx]=1;
            }
            low[u] = min(low[u], low[d.F]);
        }
        else
            low[u] = min(low[u], Num[d.F]);
    }

}
void dfs2(int u)
{
    //cout<<u<<endl;
    vis[u] =color;
    for (auto v : adj[u])
    {
        if(bridge[v.S.S])
        {
            continue;
        }
        if(v .S.F )f=1;

        if (!vis[v.F])
        {
            dfs2(v.F);
        }
    }
}
vector<pair<int,int>>g[N];
bool bol[N];
void tree(int u)
{
    bol [u] =1;
    for (auto p : adj[u])
    {
        int v = p.F;
        int w = p.S.F||bn[vis[u]]||bn[vis[v]];
        if (bol[v])continue;
        if (vis[u] != vis[v])
        {
            g[vis[v]].pb({vis[u], w});
            g[vis[u]].pb({vis[v], w});
        }
        tree(v);
    }
}
int dpth[N], lca[N][L], ww[N][L];
void dfsLCA(int u,int p)
{
    lca[u][0]=p;
    for(auto v:g[u])
    {
        if (v.F!=p)
        {
            dpth[v.F]=dpth[u]+1;
            ww[v.F][0] = v.S;
            dfsLCA(v.F,u);
        }
    }
}
int getLCA(int x,int y)
{
    if (dpth[y]>dpth[x])
        swap(x,y);
    if (dpth[x]>dpth[y])
    {
        int k=dpth[x]-dpth[y];
        for(int i=0;i<L;++i)
          if((1<<i)&k)x=lca[x][i];
    }
    if (x==y)return y;
    for (int j=L-1; j>=0; j--)
    {
        int a=lca[x][j],b=lca[y][j];
        if (a!=b)x=a,y=b;
    }
    return lca[x][0];
}
bool getll(int u, int v)
{
    int k = dpth[u] - dpth[v];
    bool ret =0;
    for (int j = L-1 ; j>=0 ; j--)
    {
        if (k &(1<<j))
        {
            ret |= ww[u][j];
            u = lca[u][j];
        }
    }
    return ret;
}
int main()
{
#ifdef Mohammad
    freopen("input.in","r",stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin >> n >> m;
    for (int i=1; i<= m ; i++)
    {
        int u,v,w;
        cin >> u >> v >> w;
        adj[u].pb({ v, {w,i}});
        adj[v].pb({ u, {w,i}});
    }
    dfs(1, 0);
    cin >> a >>b;
    for (int i=1; i<= n; i++)
    {
        f=0;
        if (!vis[i])
            dfs2(i);
        bn[color] = f;
        color++;
    }
    tree(1);
    dfsLCA(1, 0);
    for (int j=1; j<L; j++)
        for (int i=1; i<=n ; i++)
        {
            lca[i][j] = lca[lca[i][j-1]][j-1];
            ww[i][j] = ww[lca[i][j-1]][j-1] || ww[i][j-1];
        }
    if(vis[a]==vis[b])
    {
        if( bn[ vis[a] ] )
            cout<<"YES"<<endl;
        else
            cout<<"NO\n";
        return 0;
    }
    int l = getLCA(vis[a], vis[b]);
    bool la = getll(vis[a], l) || getll(vis[b], l);
    cout<< (la?"YES":"NO")<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pb push_back
#define sz size
#define F first
#define S second
int inf =1e9;
const int N=3e5+3;
int low[N], Num[N], tim=1;
vector<pair<int, pair<int,int>>>adj[N];
bool bridge[N];
void dfs(int u, int p)
{
    low[u] = Num[u] = tim++;

    for (auto d: adj[u])
    {
        int idx =d .S .S;
        if (d.F == p)
            continue;

        if (Num[d.F] == 0)
        {
            dfs(d.F, u);
            if (low[d.F] > Num[u])
            {
                //cout<<idx<<endl;
                bridge[idx]=1;
            }
            low[u] = min(low[u], low[d.F]);
        }
        else
            low[u] = min(low[u], Num[d.F]);
    }

}
int color=1;
bool f;
int vis[N];
bool bn [N];
void dfs2(int u)
{
    //cout<<u<<endl;
    vis[u] =color;
    for (auto v : adj[u]) {
        if(bridge[v.S.S]){
            continue;
        }
        if(v .S.F )f =1;
        if (!vis[v.F])
        {
           dfs2(v.F);
        }
    }

}
int a,b;
bool f2;
bool vis3[N];
void dfs3(int u ,bool fl )
{
    vis3[u]=1;
    for(auto v:adj[u])
    {
        if(v.F==b&&( fl || bn[vis[u]]) ){f2=1;}
        if(v.F==b&&( fl ||  v.S.F ) ){f2=1;}
        if(!vis3[v.F])
        {
            dfs3(v.F, fl || bn[vis[u]] || v.S.F );
        }
    }
}

int main()
{
#ifdef Mohammad
    freopen("input.in","r",stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin >> n >> m;
    for (int i=1; i<= m ; i++)
    {
        int u,v,w;
        cin >> u >> v >> w;
        adj[u].pb({ v, {w,i}});
        adj[v].pb({ u, {w,i}});
    }
    dfs(1, 0);
    cin >> a >>b;
    for (int i=1; i<= n; i++)
    {
        f=0;
        if (!vis[i])
            dfs2(i);
        if(f) bn[color]= 1;
        color++;
    }
    if(vis[a]==vis[b]){
        if( bn[ vis[a] ] )cout<<"YES"<<endl;
        else cout<<"NO\n";
        return 0;
    }
    f=0;
    dfs3(a,0);
    if(f2||bn[vis[a]]||bn[vis[b]])cout<<"YES\n";
    else cout<<"NO\n";
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>ii;
typedef vector<ii> vii;
vector< vii > G,T;
int D[300100];
int L[300100];
int C[300100];
int A[300100];
int id;
void dfs(int u, int p){
	D[u]=L[u]=id++;
	int v;
	for(int i=0;i<G[u].size();i++){
		v=G[u][i].first;
		if(v==p)continue;
		if(D[v]==-1)dfs(v,u);
		L[u]=min(L[u],L[v]);
	}
}
void dfsC(int u, int p){
	int v;
	for(int i=0;i<G[u].size();i++){
		v=G[u][i].first;
		if(v==p)continue;
		if(D[u]>=L[v]){
			if(G[u][i].second)A[C[u]]=1;
			if(C[v]==-1){
				C[v]=C[u];
				dfsC(v,u);
			}
		}else{
			if(C[v]==-1){
				C[v]=id++;
				T[C[u]].push_back(ii(C[v],G[u][i].second));
				T[C[v]].push_back(ii(C[u],G[u][i].second));
				dfsC(v,u);
			}
		}
	}
}
bool dfs(int u, int w, int p, bool c){
	c=c or A[u];
	if(u==w){
		return c;
	}
	int v;
	bool sw=0;
	for(int i=0;i<T[u].size();i++){
		v=T[u][i].first;
		if(v!=p){
			sw= sw or dfs(v,w,u,c or T[u][i].second);
		}
	}
	return sw;
}
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m)!=EOF){
		G.assign(n,vii());
		T.assign(n,vii());
		memset(D,-1,sizeof D);
		int u,v,w;
		while(m--){
			scanf("%d %d %d",&u,&v,&w);u--;v--;
			G[u].push_back(ii(v,w));
			G[v].push_back(ii(u,w));
		}

		scanf("%d %d",&u,&v);u--;v--;
		id=0;
		dfs(0,-1);

		memset(C,-1,sizeof C);
		memset(A,0,sizeof A);
		id=1;
		C[0]=0;
		dfsC(0,-1);
		//for(int i=0;i<n;i++)cout<<i+1<<" "<<C[i]<<endl;
		if(dfs(C[u],C[v],-1,0) or A[C[u]] or A[C[v]])
			cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>ii;
typedef vector<ii> vii;
vector< vii > G,T;
int D[300100];
int L[300100];
int C[300100];
int A[300100];
int id;
void dfs(int u, int p){
	D[u]=L[u]=id++;
	int v;
	for(int i=0;i<G[u].size();i++){
		v=G[u][i].first;
		if(v==p)continue;
		if(D[v]==-1)dfs(v,u);
		L[u]=min(L[u],L[v]);
	}
}
void dfs(int u){
	int v;
	for(int i=0;i<G[u].size();i++){
		v=G[u][i].first;
		if(D[u]>=L[v]){
			if(G[u][i].second)A[C[u]]=1;
			if(C[v]==-1){
				C[v]=C[u];
				dfs(v);
			}
		}else{
			if(C[v]==-1){
				C[v]=id++;
				T[C[u]].push_back(ii(C[v],G[u][i].second));
				T[C[v]].push_back(ii(C[u],G[u][i].second));

				dfs(v);
			}
		}
	}
}
bool dfs(int u, int w, int p, bool c){
	c=c or A[u];
	if(u==w){
		return c;
	}
	int v;
	bool sw=0;
	for(int i=0;i<T[u].size();i++){
		v=T[u][i].first;
		if(v!=p){
			sw= sw or dfs(v,w,u,c or T[u][i].second);
		}
	}
	return sw;
}
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m)!=EOF){
		G.assign(n,vii());
		T.assign(n,vii());
		memset(D,-1,sizeof D);
		int u,v,w;
		while(m--){
			scanf("%d %d %d",&u,&v,&w);u--;v--;
			G[u].push_back(ii(v,w));
			G[v].push_back(ii(u,w));
		}

		scanf("%d %d",&u,&v);u--;v--;
		id=0;
		dfs(0,-1);

		memset(C,-1,sizeof C);
		memset(A,0,sizeof A);
		id=1;
		C[0]=0;
		dfs(0);
		//for(int i=0;i<n;i++)cout<<i+1<<" "<<C[i]<<endl;
		if(dfs(C[u],C[v],-1,0) or A[C[u]] or A[C[v]])
			cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>ii;
typedef vector<ii> vii;
vector< vii > G,T;
int D[300100];
int L[300100];
int C[300100];
int A[300100];
int id;
void dfs(int u, int p){
	D[u]=L[u]=id++;
	int v;
	for(int i=0;i<G[u].size();i++){
		v=G[u][i].first;
		if(v==p)continue;
		if(D[v]==-1){
			dfs(v,u);
			L[u]=min(L[u],L[v]);
		}L[u]=min(L[u],D[v]);
	}
}
void dfsC(int u, int p){
	int v;
	for(int i=0;i<G[u].size();i++){
		v=G[u][i].first;
		if(v==p)continue;
		if(D[u]>=L[v]){
			if(G[u][i].second)A[C[u]]=1;
			if(C[v]==-1){
				C[v]=C[u];
				dfsC(v,u);
			}
		}else{
			if(C[v]==-1){
				C[v]=id++;
				T[C[u]].push_back(ii(C[v],G[u][i].second));
				T[C[v]].push_back(ii(C[u],G[u][i].second));
				dfsC(v,u);
			}
		}
	}
}
bool dfs(int u, int w, int p, bool c){
	c=c or A[u];
	if(u==w){
		return c;
	}
	int v;
	bool sw=0;
	for(int i=0;i<T[u].size();i++){
		v=T[u][i].first;
		if(v!=p){
			sw= sw or dfs(v,w,u,c or T[u][i].second);
		}
	}
	return sw;
}
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m)!=EOF){
		G.assign(n,vii());
		T.assign(n,vii());
		memset(D,-1,sizeof D);
		int u,v,w;
		while(m--){
			scanf("%d %d %d",&u,&v,&w);u--;v--;
			G[u].push_back(ii(v,w));
			G[v].push_back(ii(u,w));
		}

		scanf("%d %d",&u,&v);u--;v--;
		id=0;
		dfs(0,-1);

		memset(C,-1,sizeof C);
		memset(A,0,sizeof A);
		id=1;
		C[0]=0;
		dfsC(0,-1);
		//for(int i=0;i<n;i++)cout<<i+1<<" "<<C[i]<<endl;
		if(dfs(C[u],C[v],-1,0) or A[C[u]] or A[C[v]])
			cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>ii;
typedef vector<ii> vii;
vector< vii > G,T;
int D[300100];
int L[300100];
int C[300100];
int A[300100];
int id;
void dfs(int u, int p){
	D[u]=L[u]=id++;
	int v;
	for(int i=0;i<G[u].size();i++){
		v=G[u][i].first;
		if(v==p)continue;
		if(D[v]==-1)dfs(v,u);
		L[u]=min(L[u],L[v]);
	}
}
void dfs(int u){
	int v;
	for(int i=0;i<G[u].size();i++){
		v=G[u][i].first;
		if(D[u]>=L[v]){
			if(G[u][i].second)A[C[u]]=1;
			if(C[v]==-1){
				C[v]=C[u];
				dfs(v);
			}
		}else{
			if(C[v]==-1){
				C[v]=id++;
				T[C[u]].push_back(ii(C[v],G[u][i].second));
				dfs(v);
			}
		}
	}
}
bool dfs(int u, int w, int p, bool c){
	if(u==w){
		return c;
	}
	c=c or A[u];
	int v;
	bool sw=0;
	for(int i=0;i<T[u].size();i++){
		v=T[u][i].first;
		if(v!=p){
			sw= sw or dfs(v,w,u,c or T[u][i].second);
		}
	}
	return sw;
}
int main(){
	int n,m;
	while(scanf("%d %d",&n,&m)!=EOF){
		G.assign(n,vii());
		T.assign(n,vii());
		memset(D,-1,sizeof D);
		int u,v,w;
		while(m--){
			scanf("%d %d %d",&u,&v,&w);u--;v--;
			G[u].push_back(ii(v,w));
			G[v].push_back(ii(u,w));
		}

		scanf("%d %d",&u,&v);u--;v--;
		id=0;
		dfs(0,-1);

		memset(C,-1,sizeof C);
		memset(A,0,sizeof A);
		id=1;
		C[0]=0;
		dfs(0);
		if(dfs(C[u],C[v],-1,0) or A[C[u]] or A[C[v]])cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
vector < pair<int,int>  > g[300005];
vector<int>g2[300005];
vector<bool> used;
vector<int> order;
vector<vector<int> > adj;
vector<bool> visited;
set<pair<ll,ll> >wei, artbridges;
vector<int> tin, low;
int timer;
int s,e;
bool artis[300005];
int n,m;
vector<pair<ll,ll> >comps[300005];
int nodecomp[300005];
ll f;

void dfs3(int v, int p = -1)
{
    visited[v] = true;
    tin[v] = low[v] = timer++;
    for (pair<int,int> x : g[v])
    {
        int to=x.first;
        if (to == p) continue;
        if (visited[to])
        {
            low[v] = min(low[v], tin[to]);
        }
        else
        {
            dfs3(to, v);
            low[v] = min(low[v], low[to]);
            if (low[to] > tin[v])
            {
                //cout<<v<<" "<<to<<endl;
                wei.insert({v,to});
                wei.insert({to,v});
              //  cout<<v<<" "<<to<<endl;
            }

        }
    }
}

ll comp=1;
void find_bridges()
{
    timer = 0;
    visited.assign(n+1, false);
    tin.assign(n+1, -1);
    low.assign(n+1, -1);
    for (int i = 1; i <= n; ++i)
    {
        if (!visited[i])
        {

            dfs3(i);
        }
    }
}
ll artifact=0;
void creatcomponents(int v)
{
    visited[v] = true;
    nodecomp[v]=comp;
   // cout<<v<<" "<<comp<<endl;
    //component.push_back (v);
    for (size_t i=0; i<g[v].size(); ++i)
        if (!visited[g[v][i].first  ]&&!wei.count({v,g[v][i].first}))
        {
            //g2[comp].push_back({++comp,g[v][i].second});
           // cout<<g[v][i].second<<endl;
            creatcomponents(g[v][i].first);
        }
}

void dfs5(int v,bool art=0)
{
    visited[v] = true;

    //component.push_back (v);
    for (size_t i=0; i<g[v].size(); ++i){
            int u=g[v][i].first,art=g[v][i].second;
        if(art==1){
            if(!wei.count({v,u})){
                artis[nodecomp[u]]=1;
            }
            else{
                artbridges.insert({nodecomp[v],nodecomp[u]});
                artbridges.insert({nodecomp[u],nodecomp[v]});
            }
        }
        if(!visited[u]){
            dfs5(u);
        }
    }
}

void findpath(int node,int art){
    visited[node]=1;
    if(node==nodecomp[e]&&art)f=1;
    for(int i=0;i<g2[node].size();i++){
            int u=g2[node][i];
        if(!visited[u]){
            findpath(u,(artbridges.count({node,u})>0)||artis[u]||art);
            //cout<<node<<" "<<u<<" "<<artbridge.count({node,u})<<endl;

        }
    }
}
int main()
{

    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
      //  cout<<z<<endl;
        g[x].push_back({y,z});
        g[y].push_back({x,z});

    }
    cin>>s>>e;

    find_bridges();
    visited.assign(n+1,false);

    for(int i=1;i<=n;i++){
        if(!visited[i]){
            creatcomponents(i);
            comp++;
        }
        artifact=0;
    }
    visited.assign(n+1,false);
    for(int i=1;i<=n;i++){
        if(!visited[i])
        dfs5(i);
    }
   // cout<<artis[1]<<endl;
    for(auto it: wei){
        int fi=nodecomp[it.first],sec=nodecomp[it.second];
        //cout<<nodecomp[fi]<<" "<<nodecomp[sec]<<endl;
        g2[fi].push_back(sec);

    }
    visited.assign(n+1,false);
       findpath(nodecomp[s],artis[nodecomp[s]]);

    //return 0;
    if(f)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
vector < pair<int,int>  > g[100005];
vector<int>g2[100005];
vector<bool> used;
vector<int> order;
vector<vector<int> > adj;
vector<bool> visited;
set<pair<ll,ll> >wei, artbridges;
vector<int> tin, low;
int timer;
int s,e;
bool artis[100005];
int n,m;
vector<pair<ll,ll> >comps[100005];
int nodecomp[100005];
ll f;

void dfs3(int v, int p = -1)
{
    visited[v] = true;
    tin[v] = low[v] = timer++;
    for (pair<int,int> x : g[v])
    {
        int to=x.first;
        if (to == p) continue;
        if (visited[to])
        {
            low[v] = min(low[v], tin[to]);
        }
        else
        {
            dfs3(to, v);
            low[v] = min(low[v], low[to]);
            if (low[to] > tin[v])
            {
                //cout<<v<<" "<<to<<endl;
                wei.insert({v,to});
                wei.insert({to,v});
              //  cout<<v<<" "<<to<<endl;
            }

        }
    }
}

ll comp=1;
void find_bridges()
{
    timer = 0;
    visited.assign(n+1, false);
    tin.assign(n+1, -1);
    low.assign(n+1, -1);
    for (int i = 1; i <= n; ++i)
    {
        if (!visited[i])
        {

            dfs3(i);
        }
    }
}
ll artifact=0;
void creatcomponents(int v)
{
    visited[v] = true;
    nodecomp[v]=comp;
   // cout<<v<<" "<<comp<<endl;
    //component.push_back (v);
    for (size_t i=0; i<g[v].size(); ++i)
        if (!visited[g[v][i].first  ]&&!wei.count({v,g[v][i].first}))
        {
            //g2[comp].push_back({++comp,g[v][i].second});
           // cout<<g[v][i].second<<endl;
            creatcomponents(g[v][i].first);
        }
}

void dfs5(int v,bool art=0)
{
    visited[v] = true;

    //component.push_back (v);
    for (size_t i=0; i<g[v].size(); ++i){
            int u=g[v][i].first,art=g[v][i].second;
        if(art==1){
            if(!wei.count({v,u})){
                artis[nodecomp[u]]=1;
            }
            else{
                artbridges.insert({nodecomp[v],nodecomp[u]});
                artbridges.insert({nodecomp[u],nodecomp[v]});
            }
        }
        if(!visited[u]){
            dfs5(u);
        }
    }
}

void findpath(int node,int art){
    visited[node]=1;
    if(node==nodecomp[e]&&art)f=1;
    for(int i=0;i<g2[node].size();i++){
            int u=g2[node][i];
        if(!visited[u]){
            findpath(u,(artbridges.count({node,u})>0)||artis[u]||art);
            //cout<<node<<" "<<u<<" "<<artbridge.count({node,u})<<endl;

        }
    }
}
int main()
{

    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int x,y,z;
        cin>>x>>y>>z;
      //  cout<<z<<endl;
        g[x].push_back({y,z});
        g[y].push_back({x,z});

    }
    cin>>s>>e;

    find_bridges();
    visited.assign(n+1,false);

    for(int i=1;i<=n;i++){
        if(!visited[i]){
            creatcomponents(i);
            comp++;
        }
        artifact=0;
    }
    visited.assign(n+1,false);
    for(int i=1;i<=n;i++){
        if(!visited[i])
        dfs5(i);
    }
   // cout<<artis[1]<<endl;
    for(auto it: wei){
        int fi=nodecomp[it.first],sec=nodecomp[it.second];
        //cout<<nodecomp[fi]<<" "<<nodecomp[sec]<<endl;
        g2[fi].push_back(sec);

    }
    visited.assign(n+1,false);
       findpath(nodecomp[s],artis[nodecomp[s]]);

    //return 0;
    if(f)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pp;
double PI=acos(-1);
int const N = 5e5 + 10,M=5e6+10, oo = 1e9;
const int mod = oo+7;
const ll  OO = 1e18;

int n,m,at[N],low[N],desc[N],vis[N],id[N],cur;
vector<pp > adj[N],alt[N];
set<pp > br;
void go(int u,int p){
    static int tim=0;
    vis[u]=1;
    desc[u]=low[u]=tim++;
    for(auto v:adj[u]){
        if(!vis[v.first]){
            go(v.first,u);
            low[u]=min(low[u],low[v.first]);
            if(low[v.first]>low[u]){
                br.insert({u,v.first}),br.insert({v.first,u});
            }
        }else if(v.first!=p)low[u]=min(low[u],desc[v.first]);
    }
}
int dfs(int u){
    vis[u]=1;
    int o=0;
    id[u]=cur;
    for(auto v:adj[u]){
        if(vis[v.first]){
            if(br.count({u,v.first}))alt[cur].push_back(v);
            continue;
        }
        if(br.count({u,v.first})){
            alt[cur].push_back(v);
            continue;
        }
        o|=dfs(v.first)||v.second;
    }
    return o;
}

bool dfs2(int u,int d,int y=0){
    if(u==id[d]){
        return y|at[u];
    }
    vis[u]=1;
    y|=at[u];
    for(auto v:alt[u]){
        if(vis[id[v.first]])continue;
        if(dfs2(id[v.first],d,y|v.second))return 1;
    }
    return 0;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        adj[a].push_back({b,c});
        swap(a,b);
        adj[a].push_back({b,c});
    }
    int a,b;
    cin>>a>>b;
    go(1,0);
    memset(vis,0,sizeof vis);
    for(int i=1;i<=n;i++){
        if(vis[i])continue;
        cur=i;
        at[i]=dfs(i);
    }
    memset(vis,0,sizeof vis);
    if(dfs2(a,b))cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pp;
double PI=acos(-1);
int const N = 5e5 + 10,M=5e6+10, oo = 1e9;
const int mod = oo+7;
const ll  OO = 1e18;

int n,m,at[N],low[N],desc[N],vis[N],id[N],cur;
vector<pp > adj[N],alt[N];
set<pp > br;
void go(int u,int p){
    static int tim=0;
    vis[u]=1;
    desc[u]=low[u]=tim++;
    for(auto v:adj[u]){
        if(!vis[v.first]){
            go(v.first,u);
            low[u]=min(low[u],low[v.first]);
            if(low[v.first]>low[u]){
                br.insert({u,v.first}),br.insert({v.first,u});
            }
        }else if(v.first!=p)low[u]=min(low[u],desc[v.first]);
    }
}
int dfs(int u){
    vis[u]=1;
    int o=0;
    id[u]=cur;
    for(auto v:adj[u]){
        if(vis[v.first]){
            if(br.count({u,v.first}))alt[cur].push_back(v);
            if(id[v.first]==cur)o|=v.second;
            continue;
        }
        if(br.count({u,v.first})){
            alt[cur].push_back(v);
            continue;
        }
        o|=dfs(v.first)||v.second;
    }
    return o;
}

bool dfs2(int u,int d,int y=0){
    u=id[u];
    if(u==id[d])return y|at[u];
    vis[u]=1;
    y|=at[u];
    for(auto v:alt[u]){
        if(vis[id[v.first]])continue;
        if(dfs2(id[v.first],d,y|v.second))return 1;
    }
    return 0;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        adj[a].push_back({b,c});
        swap(a,b);
        adj[a].push_back({b,c});
    }
    int a,b;
    cin>>a>>b;
    go(1,0);
    memset(vis,0,sizeof vis);
    for(int i=1;i<=n;i++){
        if(vis[i])continue;
        cur=i;
        at[i]=dfs(i);
    }
    memset(vis,0,sizeof vis);
    if(dfs2(a,b))cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pp;
double PI=acos(-1);
int const N = 5e5 + 10,M=5e6+10, oo = 1e9;
const int mod = oo+7;
const ll  OO = 1e18;

int n,m,at[N],low[N],desc[N],vis[N],id[N],cur;
vector<pp > adj[N],alt[N];
set<pp > br;
void go(int u,int p){
    static int tim=0;
    vis[u]=1;
    desc[u]=low[u]=tim++;
    for(auto v:adj[u]){
        if(!vis[v.first]){
            go(v.first,u);
            low[u]=min(low[u],low[v.first]);
            if(low[v.first]>low[u]){
                br.insert({u,v.first}),br.insert({v.first,u});
            }
        }else if(v.first!=p)low[u]=min(low[u],desc[v.first]);
    }
}
int dfs(int u){
    vis[u]=1;
    int o=0;
    id[u]=cur;
    for(auto v:adj[u]){
        if(vis[v.first]){
            if(br.count({u,v.first}))alt[cur].push_back(v);
            continue;
        }
        if(br.count({u,v.first})){
            alt[cur].push_back(v);
            continue;
        }
        o|=dfs(v.first)||v.second;
    }
    return o;
}

bool dfs2(int u,int d,int y=0){
    u=id[u];
    if(u==id[d])return y|at[u];
    vis[u]=1;
    y|=at[u];
    for(auto v:alt[u]){
        if(vis[id[v.first]])continue;
        if(dfs2(id[v.first],d,y|v.second))return 1;
    }
    return 0;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        adj[a].push_back({b,c});
        swap(a,b);
        adj[a].push_back({b,c});
    }
    int a,b;
    cin>>a>>b;
    go(1,0);
    memset(vis,0,sizeof vis);
    for(int i=1;i<=n;i++){
        if(vis[i])continue;
        cur=i;
        at[i]=dfs(i);
    }
    memset(vis,0,sizeof vis);
    if(dfs2(a,b))cout<<"YES\n";
    else cout<<"NO\n";
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
using pii = pair<int, int>;
int n, m, s, e;
bool vis[N + 5];
vector<int> adjList[N + 5];
unordered_map<int, unordered_map<int, bool>> art;
bool re[N + 5];

bool dfs(int v, bool pba, int p) {
	vis[v] = true;
	for (int u : adjList[v]) {
		if (u == p) continue;
		re[v] = re[v] || re[u];
	}

	if (pba && re[v]) {
		return true;
	}

	for (int u : adjList[v]) {
		if (u == p) continue;
		if (pba && vis[u] && re[u]) {
			return true;
		}
		else if (!vis[u] && dfs(u, pba || art[u][v], v)) {
			return true;
		}
	}

	return false;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> m;

	int a, b, c;
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		adjList[a].push_back(b);
		adjList[b].push_back(a);
		if (c) {
			art[a][b] = true;
			art[b][a] = true;
		}
	}

	cin >> s >> e;

	re[e] = true;

	if (dfs(s, false, -1)) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
using pii = pair<int, int>;
int n, m, s, e, c, dsu[N + 5], compv[N + 5];
bool vis[N + 5], cca[N + 5];
vector<int> adjList[N + 5], order, components[N + 5];
unordered_set<int> adjListSC[N + 5];
unordered_map<int, unordered_map<int, bool>> eor, art, cart;

void dfs1(int v) {
	vis[v] = true;
	for (int u : adjList[v]) {
		if (!vis[u]) {
			eor[v][u] = true;
			eor[u][v] = false;
			dfs1(u);
		}
	}
	order.push_back(v);
}

void dfs2(int v) {
	vis[v] = true;
	components[c].emplace_back(v);
	compv[v] = c;
	for (int u : adjList[v]) {
		if (!vis[u] && !eor[v][u]) {
			dfs2(u);
		}
	}
}

bool dfs3(int v, int rwa) {
	vis[v] = true;
	rwa = rwa || cca[v];

	if (v == compv[e]) {
		return rwa;
	}

	for (int u : adjListSC[v]) {
		if (vis[u]) continue;
		if (dfs3(u, rwa || cart[u][v])) {
			return true;
		}
	}

	return false;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> m;

	int a, b;
	for (int i = 0; i < m; i++) {
		int c;
		cin >> a >> b >> c;
		adjList[a].push_back(b);
		adjList[b].push_back(a);
		if (c) {
			art[a][b] = true;
			art[b][a] = true;
		}
	}

	cin >> s >> e;

	dfs1(s);

	memset(vis, 0, sizeof vis);

	c = 1;
	for (int i = 0; i < n; i++) {
		int u = order[n - 1 - i];
		if (!vis[u]) {
			dfs2(u);
			c++;
		}
	}

	for (int i = 1; i < c; i++) {
		for (int v : components[i]) {
			for (int u : adjList[v]) {
				if (compv[u] != compv[v]) {
					adjListSC[i].insert(compv[u]);
					cart[i][compv[u]] = cart[i][compv[u]] || art[v][u];
				}
				else {
					cca[i] = cca[i] || art[u][v];
				}
			}
		}
	}

	memset(vis, 0, sizeof vis);

	if (dfs3(compv[s], false)) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
using pii = pair<int, int>;
int n, m, s, e, c, dsu[N + 5], compv[N + 5];
bool vis[N + 5], cca[N + 5];
vector<int> adjList[N + 5], order, components[N + 5];
unordered_set<int> adjListSC[N + 5];
unordered_map<int, unordered_map<int, bool>> eor, art, cart;

void dfs1(int v) {
	vis[v] = true;
	for (int u : adjList[v]) {
		if (!eor.count(v) && !eor[v].count(u)) {
			eor[v][u] = true;
			eor[u][v] = false;
		}
		if (!vis[u]) {
			dfs1(u);
		}
	}
	order.push_back(v);
}

void dfs2(int v) {
	vis[v] = true;
	components[c].emplace_back(v);
	compv[v] = c;
	for (int u : adjList[v]) {
		if (!vis[u] && eor[v][u]) {
			cca[c] = cca[c] || art[v][u];
			dfs2(u);
		}
	}
}

bool dfs3(int v, int rwa) {
	vis[v] = true;
	rwa = rwa || cca[v];

	if (v == compv[e]) {
		return rwa;
	}

	for (int u : adjListSC[v]) {
		if (vis[u]) continue;
		if (dfs3(u, rwa || cart[u][v])) {
			return true;
		}
	}

	return false;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> m;

	int a, b, c;
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		adjList[a].push_back(b);
		adjList[b].push_back(a);
		if (c) {
			art[a][b] = true;
			art[b][a] = true;
		}
	}

	cin >> s >> e;

	dfs1(s);

	memset(vis, 0, sizeof vis);

	c = 1;
	for (int u : order) {
		if (!vis[u]) {
			dfs2(u);
			c++;
		}
	}

	for (int i = 1; i < c; i++) {
		for (int v : components[c]) {
			for (int u : adjList[v]) {
				adjListSC[i].insert(compv[u]);
				cart[i][compv[u]] = true;
				cart[compv[u]][i] = true;
			}
		}
	}

	memset(vis, 0, sizeof vis);

	if (dfs3(compv[s], false)) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
using pii = pair<int, int>;
int n, m, s, e, dsu[N + 10];
bool vis[N + 5];
vector<int> adjList[N + 5];
unordered_map<int, unordered_map<int, bool>> art;

int root(int idx) {
	while (dsu[idx] != idx) {
		dsu[idx] = dsu[dsu[idx]];
		idx = dsu[idx];
	}
	return idx;
}

void join(int a, int b) {
	int rootA = root(a);
	int rootB = root(b);
	dsu[rootA] = rootB;
}

bool re[N + 5];

bool dfs(int v, bool pba, int p) {
	if (v == e) {
		return pba;
	}

	vis[v] = true;
	for (int u : adjList[v]) {
		if (u == p) continue;
		re[v] = re[v] || re[u];
	}
	for (int u : adjList[v]) {
		if (u == p) continue;
		if (pba && vis[u] && re[u]) {
			return true;
		}
		else if (!vis[u] && dfs(u, pba || art[u][v], v)) {
			return true;
		}
	}

	return false;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> m;

	int a, b, c;
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		adjList[a].push_back(b);
		adjList[b].push_back(a);
		if (c) {
			art[a][b] = true;
			art[b][a] = true;
		}
	}

	cin >> s >> e;

	for (int i = 1; i <= n; i++) {
		dsu[i] = i;
	}

	re[e] = true;

	if (dfs(s, false, -1)) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
using pii = pair<int, int>;
int n, m, s, e, c, dsu[N + 5], compv[N + 5];
bool vis[N + 5], cca[N + 5];
vector<int> adjList[N + 5], order, components[N + 5];
unordered_set<int> adjListSC[N + 5];
unordered_map<int, unordered_map<int, bool>> eor, art, cart;

void dfs1(int v) {
	vis[v] = true;
	for (int u : adjList[v]) {
		if (!vis[u]) {
			eor[v][u] = true;
			eor[u][v] = false;
			dfs1(u);
		}
	}
	order.push_back(v);
}

void dfs2(int v) {
	vis[v] = true;
	components[c].emplace_back(v);
	compv[v] = c;
	for (int u : adjList[v]) {
		if (!vis[u] && !eor[v][u]) {
			dfs2(u);
		}
	}
}

bool dfs3(int v, int rwa) {
	vis[v] = true;
	rwa = rwa || cca[v];

	if (v == compv[e]) {
		return rwa;
	}

	for (int u : adjListSC[v]) {
		if (vis[u]) continue;
		if (dfs3(u, rwa || cart[u][v])) {
			return true;
		}
	}

	return false;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> m;

	int a, b;
	for (int i = 0; i < m; i++) {
		int c;
		cin >> a >> b >> c;
		adjList[a].push_back(b);
		adjList[b].push_back(a);
		if (c) {
			art[a][b] = true;
			art[b][a] = true;
		}
	}

	cin >> s >> e;

	dfs1(s);

	memset(vis, 0, sizeof vis);

	c = 1;
	for (int i = 0; i < n; i++) {
		int u = order[n - 1 - i];
		if (!vis[u]) {
			dfs2(u);
			c++;
		}
	}

	for (int i = 1; i < c; i++) {
		for (int v : components[i]) {
			for (int u : adjList[v]) {
				if (compv[u] != compv[v]) {
					adjListSC[i].insert(compv[u]);
					cart[i][compv[u]] = cart[i][compv[u]] || art[v][u];
				}
				else {
					cca[i] = true;
				}
			}
		}
	}

	memset(vis, 0, sizeof vis);

	if (dfs3(compv[s], false)) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
using pii = pair<int, int>;
int n, m, s, e, dsu[N + 10];
bool vis[N + 5];
vector<int> adjList[N + 5];
vector<pii> edges;

int root(int idx) {
	while (dsu[idx] != idx) {
		dsu[idx] = dsu[dsu[idx]];
		idx = dsu[idx];
	}
	return idx;
}

void join(int a, int b) {
	int rootA = root(a);
	int rootB = root(b);
	dsu[rootA] = rootB;
}

void dfs(int v) {
	vis[v] = true;
	for (int u : adjList[v]) {
		join(v, u);
		if (!vis[u]) {
			dfs(u);
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> m;

	unordered_set<int> ini;
	int a, b, c;
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		if (c) {
			edges.push_back({a, b});
			ini.insert(a);
			ini.insert(b);
		}
		else {
			adjList[a].push_back(b);
			adjList[b].push_back(a);
		}
	}

	cin >> s >> e;

	for (int i = 1; i <= n; i++) {
		dsu[i] = i;
	}

	for (int v : ini) {
		if (!vis[v]) {
			dfs(v);
		}
	}

	for (pii ed : edges) {
		if (root(s) == root(ed.first) && root(e) == root(ed.second)) {
			cout << "YES\n";
			return 0;
		}
		if (root(e) == root(ed.first) && root(s) == root(ed.second)) {
			cout << "YES\n";
			return 0;
		}
	}

	cout << "NO\n";

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 300000;
using pii = pair<int, int>;
int n, m, s, e, c, dsu[N + 5], compv[N + 5];
bool vis[N + 5], cca[N + 5];
vector<int> adjList[N + 5], order, components[N + 5];
unordered_set<int> adjListSC[N + 5];
unordered_map<int, unordered_map<int, bool>> eor, art, cart;

void dfs1(int v) {
	vis[v] = true;
	for (int u : adjList[v]) {
		if (!vis[u]) {
			eor[v][u] = true;
			eor[u][v] = false;
			dfs1(u);
		}
	}
	order.push_back(v);
}

void dfs2(int v) {
	vis[v] = true;
	components[c].emplace_back(v);
	compv[v] = c;
	for (int u : adjList[v]) {
		if (!vis[u] && !eor[v][u]) {
			cca[c] = cca[c] || art[v][u];
			dfs2(u);
		}
	}
}

bool dfs3(int v, int rwa) {
	vis[v] = true;
	rwa = rwa || cca[v];

	if (v == compv[e]) {
		return rwa;
	}

	for (int u : adjListSC[v]) {
		if (vis[u]) continue;
		if (dfs3(u, rwa || cart[u][v])) {
			return true;
		}
	}

	return false;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> m;

	int a, b;
	for (int i = 0; i < m; i++) {
		int c;
		cin >> a >> b >> c;
		adjList[a].push_back(b);
		adjList[b].push_back(a);
		if (c) {
			art[a][b] = true;
			art[b][a] = true;
		}
	}

	cin >> s >> e;

	dfs1(s);

	memset(vis, 0, sizeof vis);

	c = 1;
	for (int i = 0; i < n; i++) {
		int u = order[n - 1 - i];
		if (!vis[u]) {
			dfs2(u);
			c++;
		}
	}

	for (int i = 1; i < c; i++) {
		for (int v : components[i]) {
			for (int u : adjList[v]) {
				adjListSC[i].insert(compv[u]);
				cart[i][compv[u]] = cart[i][compv[u]] || art[v][u];
			}
		}
	}

	memset(vis, 0, sizeof vis);

	if (dfs3(compv[s], false)) {
		cout << "YES\n";
	}
	else {
		cout << "NO\n";
	}

	return 0;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<map>
#include<bitset>
#include<assert.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<chrono>
#include<stack>
#include<deque>
#include<random>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
vector<int>ad[N+2],tree[N+2];//rooted tree
vector<pair<int,int> >br;
vector<int>bkad[N+2];//edges doesn't belong to the tree(end nodes are in a chain)

int vis[N+2],lev[N+2];
void dfs(int node,int par,int lv)
{
  vis[node]=1,lev[node]=lv;
  for(auto x:ad[node])
  {
    if(x==par)continue;
    if(vis[x])
    {
      bkad[node].push_back(x);bkad[x].push_back(node);
    }
    else
    {
      tree[node].push_back(x);tree[x].push_back(node);
      dfs(x,node,lv+1);
    }
  }
}
int bridge(int node,int par)
{
  int mn=1e9;
  for(auto x:bkad[node])mn=min(mn,lev[x]);
  for(auto x:tree[node])
  {
    if(x==par)continue;
    mn=min(mn,bridge(x,node));
  }
  if(mn>=lev[node]&&par!=-1)br.push_back({par,node});
  return mn;
}
vector<int>ab[N+2];map<pair<int,int>,int>mp;
int com[N+2],f[N+2];
void dfs(int nd,int c)
{
  com[nd]=c;int id=-1;
  for(auto x:ad[nd])
  {
    id++;
    if(com[x]||mp[{nd,x}])continue;
    if(ab[nd][id])f[c]=1;dfs(x,c);
  }
}
int par[N+2],fl[N+2];
vector<pair<int,int> >an[N+2];
void dds(int nd,int pr,int lv,int bl)
{
  lev[nd]=lv;par[nd]=pr;fl[nd]=bl;
  for(auto x:an[nd])
    if(x.first!=pr)dds(x.first,nd,lv+1,x.second);
}
int raise(int a,int b)
{
  int ans=f[a]|f[b];
  if(lev[a]<lev[b])swap(a,b);
  while(lev[a]>lev[b])
  {
    ans|=fl[a];a=par[a];
    ans|=f[a];
  }
  while(a!=b)
  {
    ans|=fl[a];a=par[a];ans|=f[a];

    ans|=fl[b];b=par[b];ans|=f[b];
  }
  return ans;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  int n,m;cin>>n>>m;
  vector<vector<int> >ed;
  for(int i=1;i<=m;i++)
  {
    int u,v,w;cin>>u>>v>>w;
    ad[u].push_back(v);ad[v].push_back(u);
    ab[u].push_back(w);ab[v].push_back(w);

    ed.push_back({u,v,w});
  }
  dfs(1,-1,0);bridge(1,-1);
  for(auto x:br)
  {
    //cout<<x.first<<" "<<x.second<<endl;
    mp[x]=1;mp[{x.second,x.first}]=1;
  }
  int cnt=0;
  for(int i=1;i<=n;i++)
  {
    if(com[i]==0)dfs(i,++cnt);
  }
  for(int i=1;i<=n;i++)ab[i].clear();
  for(auto x:ed)
  {
    if(com[x[0]]==com[x[1]])continue;
    //cout<<com[x[0]]<<" "<<com[x[1]]<<" "<<x[2]<<endl;
    an[com[x[0]]].push_back({com[x[1]],x[2]});
    an[com[x[1]]].push_back({com[x[0]],x[2]});
  }
  dds(1,-1,0,0);
  int a,b;cin>>a>>b;
  if(raise(com[a],com[b]))cout<<"YES\n";else cout<<"NO\n";
  return 0;
}


#include<iostream>
#include<vector>
#include<cstring>
#include<map>
#include<bitset>
#include<assert.h>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<chrono>
#include<stack>
#include<deque>
#include<random>
#define long long long
using namespace std;
const int N=1e6,inf=1e9;
vector<int>ad[N+2],tree[N+2];//rooted tree
vector<pair<int,int> >br;
vector<int>bkad[N+2];//edges doesn't belong to the tree(end nodes are in a chain)

int vis[N+2],lev[N+2];
void dfs(int node,int par,int lv)
{
  vis[node]=1,lev[node]=lv;
  for(auto x:ad[node])
  {
    if(x==par)continue;
    if(vis[x])
    {
      bkad[node].push_back(x);bkad[x].push_back(node);
    }
    else
    {
      tree[node].push_back(x);tree[x].push_back(node);
      dfs(x,node,lv+1);
    }
  }
}
int bridge(int node,int par)
{
  int mn=1e9;
  for(auto x:bkad[node])mn=min(mn,lev[x]);
  for(auto x:tree[node])
  {
    if(x==par)continue;
    mn=min(mn,bridge(x,node));
  }
  if(mn>=lev[node]&&par!=-1)br.push_back({par,node});
  return mn;
}
vector<int>ab[N+2];map<pair<int,int>,int>mp;
int com[N+2],f[N+2];
void dfs(int nd,int c)
{
  if(com[nd])return ;
  com[nd]=c;int id=-1;
  for(auto x:ad[nd])
  {
    id++;
    if(mp[{nd,x}])continue;
    if(ab[nd][id])f[c]=1;dfs(x,c);
  }
}
int par[N+2],fl[N+2];
vector<pair<int,int> >an[N+2];
void dds(int nd,int pr,int lv,int bl)
{
  lev[nd]=lv;par[nd]=pr;fl[nd]=bl;
  for(auto x:an[nd])
    if(x.first!=pr)dds(x.first,nd,lv+1,x.second);
}
int raise(int a,int b)
{
  int ans=f[a]|f[b];
  if(lev[a]<lev[b])swap(a,b);
  while(lev[a]>lev[b])
  {
    ans|=fl[a];a=par[a];
    ans|=f[a];
  }
  while(a!=b)
  {
    ans|=fl[a];a=par[a];ans|=f[a];

    ans|=fl[b];b=par[b];ans|=f[b];
  }
  return ans;
}
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);

  int n,m;cin>>n>>m;assert(m>=n-1);
  vector<vector<int> >ed;
  for(int i=1;i<=m;i++)
  {
    int u,v,w;cin>>u>>v>>w;
    ad[u].push_back(v);ad[v].push_back(u);
    ab[u].push_back(w);ab[v].push_back(w);

    ed.push_back({u,v,w});
  }
  dfs(1,-1,0);bridge(1,-1);
  for(auto x:br)
  {
    //cout<<x.first<<" "<<x.second<<endl;
    mp[x]=1;mp[{x.second,x.first}]=1;
  }
  int cnt=0;
  for(int i=1;i<=n;i++)
  {
    if(com[i]==0)dfs(i,++cnt);
  }
  for(int i=1;i<=n;i++)ab[i].clear();
  for(auto x:ed)
  {
    if(com[x[0]]==com[x[1]])continue;
    //cout<<com[x[0]]<<" "<<com[x[1]]<<" "<<x[2]<<endl;
    an[com[x[0]]].push_back({com[x[1]],x[2]});
    an[com[x[1]]].push_back({com[x[0]],x[2]});
  }
  dds(1,-1,0,0);
  int a,b;cin>>a>>b;
  if(raise(com[a],com[b]))cout<<"YES\n";else cout<<"NO\n";
  return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <limits>
#include <utility>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <map>
#include <stack>
#include <numeric>
#include <set>
#include <list>

#define endl '\n'
using namespace std;

int n, m, dfsT, bccT, a, b;
vector<vector<pair<int, int>>> adj, bt;
vector<int> bccId, discovered, haveArtifacts;
vector<pair<int, int>> bridgeTree, artifacts;
stack<int> stk;

int scc(vector<int> &discovered, int here, pair<int, int> parent) {
    stk.push(here);
    int low = discovered[here] = ++dfsT;

    for (auto p : adj[here]) {
        int there = p.first;
        int isArtifact = p.second;

        if (discovered[there] == -1) {
            low = min(low, scc(discovered, there, {here, isArtifact}));
        } else if (there != parent.first) {
            low = min(low, discovered[there]);
        }
    }

    if (low == discovered[here]) {
        while (true) {
            int t = stk.top();stk.pop();
            bccId[t] = bccT;
            if (t == here)
                break;
        }
        bccT++;
        bridgeTree.push_back(parent);
    }
    return low;
}

void makeBridgeTree(vector<vector<pair<int, int>>> &bt) {
    bt.resize(bccT);
    for (int here = 0; here < bccT; here++) {
        auto parent = bridgeTree[here];
        if (parent.first != -1) {
            int there = bccId[parent.first];
            bt[here].push_back({there, parent.second});
            bt[there].push_back({here, parent.second});
        }
    }
}

bool dfs(vector<vector<pair<int, int>>> &bt,
        vector<int> visited, int here, bool meetArtifacts) {
    visited[here] = true;

    if (here == b)
        return meetArtifacts;

    for (auto p : bt[here]) {
        int there = p.first;
        int isArtifacts = p.second;
        bool next = (meetArtifacts || haveArtifacts[there] || isArtifacts);
        if (!visited[there]) {
            bool sub = dfs(bt, visited, there, next);
            if (sub)
                return sub;
        }
    }
    return false;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    adj = vector<vector<pair<int, int>>>(n);

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        adj[x-1].push_back({y-1, z});
        adj[y-1].push_back({x-1, z});
        if (z == 1)
            artifacts.push_back({x-1, y-1});
    }
    cin >> a >> b;

    discovered = bccId = vector<int>(n, -1);
    scc(discovered, 0, {-1, false});

    makeBridgeTree(bt);

    haveArtifacts = vector<int>(bccT, false);
    for (auto p : artifacts) {
        int f = bccId[p.first];
        int t = bccId[p.second];
        if (f == t)
            haveArtifacts[f] = true;
    }

    a = bccId[a-1];
    b = bccId[b-1];

    discovered.clear();
    discovered = vector<int>(bccT, false);
    bool ret = dfs(bt, discovered, a, haveArtifacts[a]);

    cout << (ret ? "YES" : "NO") << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <limits>
#include <utility>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <map>
#include <stack>
#include <numeric>
#include <set>
#include <list>

#define endl '\n'
using namespace std;

int n, m, dfsT, bccT, a, b;
vector<vector<int>> adj;
vector<int> bccId, discovered;
vector<pair<int, int>> artifacts;
stack<int> stk;

int scc(int here, int parent) {
    stk.push(here);
    int low = discovered[here] = ++dfsT;

    bool metParent = false;
    for (auto there : adj[here])
        if (discovered[there] == -1) {
            low = min(low, scc(there, here));
        } else if (there != parent || metParent) {
            low = min(low, discovered[there]);
        } else {
            metParent = true;
        }

    if (low == discovered[here]) {
        while (true) {
            int t = stk.top();stk.pop();
            bccId[t] = bccT;
            if (t == here)
                break;
        }
        bccT++;
    }
    return low;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    adj = vector<vector<int>>(n);

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        adj[x-1].push_back(y-1);
        adj[y-1].push_back(x-1);
        if (z == 1)
            artifacts.push_back({x-1, y-1});
    }
    cin >> a >> b;
    a--;b--;

    // add edge between a and b - could be multigraph
    adj[a].push_back(b);
    adj[b].push_back(a);

    discovered = bccId = vector<int>(n, -1);
    scc(0, -1);

    assert(bccId[a] == bccId[b]);

    bool ret = false;
    for (auto p : artifacts) {
        int f = p.first;
        int t = p.second;
        if (bccId[f] == bccId[a] && bccId[t] == bccId[a]) {
            ret = true;
            goto out;
        }
    }

out:
    cout << (ret ? "YES" : "NO") << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <limits>
#include <utility>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <map>
#include <stack>
#include <numeric>
#include <set>
#include <list>

#define endl '\n'
using namespace std;

int n, m, dfsT, bccT, a, b;
vector<vector<pair<int, int>>> adj;
vector<int> bccId, haveArtifacts;
vector<pair<int, int>> bridgeTree, artifacts;
stack<int> stk;

int scc(vector<int> &discovered, int here, pair<int, int> parent) {
    stk.push(here);
    int low = discovered[here] = ++dfsT;

    for (auto p : adj[here]) {
        int there = p.first;
        int isArtifact = p.second;

        if (discovered[there] == -1) {
            low = min(low, scc(discovered, there, {here, isArtifact}));
        } else if (there != parent.first) {
            low = min(low, discovered[there]);
        }
    }

    if (low == discovered[here]) {
        while (true) {
            int t = stk.top();stk.pop();
            bccId[t] = bccT;
            if (t == here)
                break;
        }
        bccT++;
        bridgeTree.push_back(parent);
    }
    return low;
}

vector<vector<pair<int, int>>> makeBridgeTree() {
    vector<vector<pair<int, int>>> bt(bccT);

    for (int here = 0; here < bccT; here++) {
        auto parent = bridgeTree[here];
        if (parent.first != -1) {
            int there = bccId[parent.first];
            bt[here].push_back({there, parent.second});
            bt[there].push_back({here, parent.second});
        }
    }

    return bt;
}

bool dfs(vector<vector<pair<int, int>>> &bt,
        vector<int> visited, int here, bool meetArtifacts) {
    visited[here] = true;

    if (here == b)
        return meetArtifacts;

    for (auto p : bt[here]) {
        int there = p.first;
        int isArtifacts = p.second;
        bool next = (meetArtifacts || haveArtifacts[there] || isArtifacts);
        if (!visited[there]) {
            bool sub = dfs(bt, visited, there, next);
            if (sub)
                return sub;
        }
    }
    return false;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    adj = vector<vector<pair<int, int>>>(n);

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        adj[x-1].push_back({y-1, z});
        adj[y-1].push_back({x-1, z});
        if (z == 1)
            artifacts.push_back({x-1, y-1});
    }
    cin >> a >> b;

    vector<int> discovered(n, -1);
    bccId = vector<int>(n, -1);
    scc(discovered, 0, {-1, false});

    vector<vector<pair<int, int>>> bt = makeBridgeTree();

    //cout << bccT << endl;
    //for (int here = 0; here < bccT; here++)
    //    for (auto p : bt[here]) {
    //        cout << here << " " << p.first << " " << p.second << endl;
    //    }

    haveArtifacts = vector<int>(bccT, false);
    for (auto p : artifacts) {
        int f = bccId[p.first];
        int t = bccId[p.second];
        if (f == t)
            haveArtifacts[f] = true;
    }

    a = bccId[a-1];
    b = bccId[b-1];

    //cout << a << " " << b << endl;

    vector<int> visited(bccT, false);
    bool ret = dfs(bt, visited, a, haveArtifacts[a]);

    cout << (ret ? "YES" : "NO") << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <limits>
#include <utility>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <map>
#include <stack>
#include <numeric>
#include <set>
#include <list>

#define endl '\n'
using namespace std;

int n, m, dfsT, bccT, a, b;
vector<vector<pair<int, int>>> adj;
vector<int> bccId, haveArtifacts;
vector<pair<int, int>> bridgeTree, artifacts;
stack<int> stk;

int scc(vector<int> &discovered, int here, pair<int, int> parent) {
    stk.push(here);
    int low = discovered[here] = ++dfsT;

    for (auto p : adj[here]) {
        int there = p.first;
        int isArtifact = p.second;

        if (discovered[there] == -1) {
            low = min(low, scc(discovered, there, {here, isArtifact}));
        } else if (there != parent.first) {
            low = min(low, discovered[there]);
        }
    }

    if (low == discovered[here]) {
        while (true) {
            int t = stk.top();stk.pop();
            bccId[t] = bccT;
            if (t == here)
                break;
        }
        bccT++;
        bridgeTree.push_back(parent);
    }
    return low;
}

vector<vector<pair<int, int>>> makeBridgeTree() {
    vector<vector<pair<int, int>>> bt(bccT);

    for (int here = 0; here < bccT; here++) {
        auto parent = bridgeTree[here];
        if (parent.first != -1) {
            int there = bccId[parent.first];
            bt[here].push_back({there, parent.second});
            bt[there].push_back({here, parent.second});
        }
    }

    return bt;
}

bool dfs(vector<vector<pair<int, int>>> &bt,
        vector<int> &visited, int here, bool meetArtifacts) {
    visited[here] = true;

    if (here == b)
        return meetArtifacts;

    for (auto p : bt[here]) {
        int there = p.first;
        int isArtifacts = p.second;
        bool next = (meetArtifacts || haveArtifacts[there] || isArtifacts);
        if (!visited[there]) {
            bool sub = dfs(bt, visited, there, next);
            if (sub)
                return sub;
        }
    }
    return false;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    adj = vector<vector<pair<int, int>>>(n);

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        adj[x-1].push_back({y-1, z});
        adj[y-1].push_back({x-1, z});
        if (z == 1)
            artifacts.push_back({x-1, y-1});
    }
    cin >> a >> b;

    vector<int> discovered(n, -1);
    bccId = vector<int>(n, -1);
    scc(discovered, 0, {-1, false});

    vector<vector<pair<int, int>>> bt = makeBridgeTree();

    //cout << bccT << endl;
    //for (int here = 0; here < bccT; here++)
    //    for (auto p : bt[here]) {
    //        cout << here << " " << p.first << " " << p.second << endl;
    //    }

    haveArtifacts = vector<int>(bccT, false);
    for (auto p : artifacts) {
        int f = bccId[p.first];
        int t = bccId[p.second];
        if (f == t)
            haveArtifacts[f] = true;
    }

    a = bccId[a-1];
    b = bccId[b-1];

    //cout << a << " " << b << endl;

    vector<int> visited(bccT, false);
    bool ret = dfs(bt, visited, a, haveArtifacts[a]);

    cout << (ret ? "YES" : "NO") << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <limits>
#include <utility>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <map>
#include <stack>
#include <numeric>
#include <set>
#include <list>

#define endl '\n'
using namespace std;

int n, m, dfsT, bccT, a, b;
vector<vector<pair<int, int>>> adj, bt;
vector<int> bccId, haveArtifacts, discovered;
vector<pair<int, int>> bridgeTree, artifacts;
stack<int> stk;

int scc(int here, pair<int, int> parent) {
    stk.push(here);
    int low = discovered[here] = ++dfsT;

    for (auto p : adj[here]) {
        int there = p.first;
        int isArtifact = p.second;

        if (discovered[there] == -1) {
            low = min(low, scc(there, {here, isArtifact}));
        } else if (there != parent.first) {
            low = min(low, discovered[there]);
        }
    }

    if (low == discovered[here]) {
        while (true) {
            int t = stk.top();stk.pop();
            bccId[t] = bccT;
            if (t == here)
                break;
        }
        bccT++;
        bridgeTree.push_back(parent);
    }
    return low;
}

void makeBridgeTree(vector<vector<pair<int, int>>> &bt) {
    bt.resize(bccT);
    for (int here = 0; here < bccT; here++) {
        auto parent = bridgeTree[here];
        if (parent.first != -1) {
            int there = bccId[parent.first];
            bt[here].push_back({there, parent.second});
            bt[there].push_back({here, parent.second});
        }
    }
}

bool dfs(vector<vector<pair<int, int>>> &bt, int here, bool meetArtifacts) {
    discovered[here] = true;

    if (here == b)
        return meetArtifacts;

    for (auto p : bt[here]) {
        int there = p.first;
        int isArtifacts = p.second;
        bool next = (meetArtifacts || haveArtifacts[there] || isArtifacts);
        if (discovered[there] == -1) {
            bool sub = dfs(bt, there, next);
            if (sub)
                return sub;
        }
    }
    return false;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    adj = vector<vector<pair<int, int>>>(n);

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        adj[x-1].push_back({y-1, z});
        adj[y-1].push_back({x-1, z});
        if (z == 1)
            artifacts.push_back({x-1, y-1});
    }
    cin >> a >> b;

    discovered = bccId = vector<int>(n, -1);
    scc(0, {-1, false});

    vector<vector<pair<int, int>>> bt;
    makeBridgeTree(bt);

    haveArtifacts = vector<int>(bccT, false);
    for (auto p : artifacts) {
        int f = bccId[p.first];
        int t = bccId[p.second];
        if (f == t)
            haveArtifacts[f] = true;
    }

    a = bccId[a-1];
    b = bccId[b-1];

    discovered.clear();
    discovered = vector<int>(bccT, -1);
    bool ret = dfs(bt, a, haveArtifacts[a]);

    cout << (ret ? "YES" : "NO") << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <limits>
#include <utility>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <map>
#include <stack>
#include <numeric>
#include <set>
#include <list>

#define endl '\n'
using namespace std;

int n, m, dfsT, bccT, a, b;
vector<vector<pair<int, int>>> adj, bt;
vector<int> bccId, haveArtifacts;
vector<pair<int, int>> bridgeTree, artifacts;
stack<int> stk;

int scc(vector<int> &discovered, int here, pair<int, int> parent) {
    stk.push(here);
    int low = discovered[here] = ++dfsT;

    for (auto p : adj[here]) {
        int there = p.first;
        int isArtifact = p.second;

        if (discovered[there] == -1) {
            low = min(low, scc(discovered, there, {here, isArtifact}));
        } else if (there != parent.first) {
            low = min(low, discovered[there]);
        }
    }

    if (low == discovered[here]) {
        while (true) {
            int t = stk.top();stk.pop();
            bccId[t] = bccT;
            if (t == here)
                break;
        }
        bccT++;
        bridgeTree.push_back(parent);
    }
    return low;
}

void makeBridgeTree(vector<vector<pair<int, int>>> &bt) {
    bt.resize(bccT);
    for (int here = 0; here < bccT; here++) {
        auto parent = bridgeTree[here];
        if (parent.first != -1) {
            int there = bccId[parent.first];
            bt[here].push_back({there, parent.second});
            bt[there].push_back({here, parent.second});
        }
    }
}

bool dfs(vector<vector<pair<int, int>>> &bt,
        vector<int> visited, int here, bool meetArtifacts) {
    visited[here] = true;

    if (here == b)
        return meetArtifacts;

    for (auto p : bt[here]) {
        int there = p.first;
        int isArtifacts = p.second;
        bool next = (meetArtifacts || haveArtifacts[there] || isArtifacts);
        if (!visited[there]) {
            bool sub = dfs(bt, visited, there, next);
            if (sub)
                return sub;
        }
    }
    return false;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    adj = vector<vector<pair<int, int>>>(n);

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        adj[x-1].push_back({y-1, z});
        adj[y-1].push_back({x-1, z});
        if (z == 1)
            artifacts.push_back({x-1, y-1});
    }
    cin >> a >> b;

    vector<int> discovered(n, -1);
    bccId = vector<int>(n, -1);
    scc(discovered, 0, {-1, false});

    makeBridgeTree(bt);

    haveArtifacts = vector<int>(bccT, false);
    for (auto p : artifacts) {
        int f = bccId[p.first];
        int t = bccId[p.second];
        if (f == t)
            haveArtifacts[f] = true;
    }

    a = bccId[a-1];
    b = bccId[b-1];

    vector<int> visited(bccT, false);
    bool ret = dfs(bt, visited, a, haveArtifacts[a]);

    cout << (ret ? "YES" : "NO") << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <limits>
#include <utility>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <map>
#include <stack>
#include <numeric>
#include <set>
#include <list>

#define endl '\n'
using namespace std;

int n, m, dfsT, bccT, a, b;
vector<vector<pair<int, int>>> adj, bt;
vector<int> bccId, haveArtifacts;
vector<pair<int, int>> bridgeTree, artifacts;
stack<int> stk;

int scc(vector<int> &discovered, int here, pair<int, int> parent) {
    stk.push(here);
    int low = discovered[here] = ++dfsT;

    for (auto p : adj[here]) {
        int there = p.first;
        int isArtifact = p.second;

        if (discovered[there] == -1) {
            low = min(low, scc(discovered, there, {here, isArtifact}));
        } else if (there != parent.first) {
            low = min(low, discovered[there]);
        }
    }

    if (low == discovered[here]) {
        while (true) {
            int t = stk.top();stk.pop();
            bccId[t] = bccT;
            if (t == here)
                break;
        }
        bccT++;
        bridgeTree.push_back(parent);
    }
    return low;
}

void makeBridgeTree(vector<vector<pair<int, int>>> &bt) {
    bt.resize(bccT);
    for (int here = 0; here < bccT; here++) {
        auto parent = bridgeTree[here];
        if (parent.first != -1) {
            int there = bccId[parent.first];
            bt[here].push_back({there, parent.second});
            bt[there].push_back({here, parent.second});
        }
    }
}

bool dfs(vector<vector<pair<int, int>>> &bt,
        vector<int> visited, int here, bool meetArtifacts) {
    visited[here] = true;

    if (here == b)
        return meetArtifacts;

    for (auto p : bt[here]) {
        int there = p.first;
        int isArtifacts = p.second;
        bool next = (meetArtifacts || haveArtifacts[there] || isArtifacts);
        if (!visited[there]) {
            bool sub = dfs(bt, visited, there, next);
            if (sub)
                return sub;
        }
    }
    return false;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    adj = vector<vector<pair<int, int>>>(n);

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        adj[x-1].push_back({y-1, z});
        adj[y-1].push_back({x-1, z});
        if (z == 1)
            artifacts.push_back({x-1, y-1});
    }
    cin >> a >> b;

    vector<int> discovered(n, -1);
    bccId = vector<int>(n, -1);
    scc(discovered, 0, {-1, false});

    makeBridgeTree(bt);

    haveArtifacts = vector<int>(bccT, false);
    for (auto p : artifacts) {
        int f = bccId[p.first];
        int t = bccId[p.second];
        if (f == t)
            haveArtifacts[f] = true;
    }

    a = bccId[a-1];
    b = bccId[b-1];

    discovered.clear();
    discovered = vector<int>(bccT, false);
    bool ret = dfs(bt, discovered, a, haveArtifacts[a]);

    cout << (ret ? "YES" : "NO") << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <limits>
#include <utility>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <map>
#include <stack>
#include <numeric>
#include <set>
#include <list>

#define endl '\n'
using namespace std;

int n, m, dfsT, bccT, a, b;
vector<vector<pair<int, int>>> adj;
vector<int> bccId, haveArtifacts;
vector<pair<int, int>> bridgeTree, artifacts;
stack<int> stk;

int scc(vector<int> &discovered, int here, pair<int, int> parent) {
    stk.push(here);
    int low = discovered[here] = ++dfsT;

    for (auto p : adj[here]) {
        int there = p.first;
        int isArtifact = p.second;

        if (discovered[there] == -1) {
            low = min(low, scc(discovered, there, {here, isArtifact}));
        } else if (there != parent.first) {
            low = min(low, discovered[there]);
        }
    }

    if (low == discovered[here]) {
        while (true) {
            int t = stk.top();stk.pop();
            bccId[t] = bccT;
            if (t == here)
                break;
        }
        bccT++;
        bridgeTree.push_back(parent);
    }
    return low;
}

void makeBridgeTree(vector<vector<pair<int, int>>> &bt) {
    bt.resize(bccT);
    for (int here = 0; here < bccT; here++) {
        auto parent = bridgeTree[here];
        if (parent.first != -1) {
            int there = bccId[parent.first];
            bt[here].push_back({there, parent.second});
            bt[there].push_back({here, parent.second});
        }
    }
}

bool dfs(vector<vector<pair<int, int>>> &bt,
        vector<int> visited, int here, bool meetArtifacts) {
    visited[here] = true;

    if (here == b)
        return meetArtifacts;

    for (auto p : bt[here]) {
        int there = p.first;
        int isArtifacts = p.second;
        bool next = (meetArtifacts || haveArtifacts[there] || isArtifacts);
        if (!visited[there]) {
            bool sub = dfs(bt, visited, there, next);
            if (sub)
                return sub;
        }
    }
    return false;
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    adj = vector<vector<pair<int, int>>>(n);

    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        adj[x-1].push_back({y-1, z});
        adj[y-1].push_back({x-1, z});
        if (z == 1)
            artifacts.push_back({x-1, y-1});
    }
    cin >> a >> b;

    vector<int> discovered(n, -1);
    bccId = vector<int>(n, -1);
    scc(discovered, 0, {-1, false});

    vector<vector<pair<int, int>>> bt;
    makeBridgeTree(bt);

    haveArtifacts = vector<int>(bccT, false);
    for (auto p : artifacts) {
        int f = bccId[p.first];
        int t = bccId[p.second];
        if (f == t)
            haveArtifacts[f] = true;
    }

    a = bccId[a-1];
    b = bccId[b-1];

    vector<int> visited(bccT, false);
    bool ret = dfs(bt, visited, a, haveArtifacts[a]);

    cout << (ret ? "YES" : "NO") << endl;
    return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
typedef long long ll;
using namespace std;

int n,m;
int st,en;
vector <int > v[300010];
vector <pair<int,int> > brdg;
int no_scc[300010];
vector <pair<int,int> > Art;
int num[300010];
int low[300010];
int par[300010];
vector <int > vtree[300010];
int T=1;
map<pair<int,int> , bool > mp;
void dfs (int nod){
    num[nod]=low[nod]=T++;
    for (int i=0;i<v[nod].size();i++){
        if (v[nod][i]==par[nod])continue;
        if (num[v[nod][i]]==0){
            par[v[nod][i]]=nod;
            dfs (v[nod][i]);
            low[nod]=min(low[nod],low[v[nod][i]]);
            if (num[nod]<low[v[nod][i]]){
                mp[{nod,v[nod][i]}]=true;
                mp[{v[nod][i],nod}]=true;
                brdg.push_back ({nod,v[nod][i]});
                //vtree[nod].push_back (v[nod][i]);
                //vtree[v[nod][i]].push_back (nod);
            }
        }else {
            low[nod]=min(low[nod],low[v[nod][i]]);
        }
    }
}

void cc (int nod ,int c){
    no_scc[nod]=c;
    //cout <<nod<<" ";
    for (int i=0;i<v[nod].size();i++){
        //cout <<mp[{3,4}]<<endl;
        if (mp[{nod,v[nod][i]}]==false&&no_scc[v[nod][i]]==0){
            //cout <<mp [{nod,v[nod][i]}]<<endl;
            cc (v[nod][i],c);
        }
    }
}

int art[300010];
map <pair<int,int> , bool > mp1;

int dfs1 (int nod,int pt,bool ch){
    //cout <<nod<<endl;
    if (nod==no_scc[en]&&ch)return 1;
    if (nod==no_scc[en])return 0;
    int res=0;
    for (int i=0;i<vtree[nod].size();i++){
            //cout <<"ASDF";
        if (vtree[nod][i]==pt)continue;
        res+=dfs1 (vtree[nod][i],nod,mp1[{nod,vtree[nod][i]}]+art[vtree[nod][i]]);
    }
    return res;
}

int main()
{
    cin >>n>>m;
    for (int i=0;i<m;i++){
        int a,b,c;cin >>a>>b>>c;
        v[a].push_back (b);
        v[b].push_back (a);
        if (c){
            Art.push_back({a,b});
        }
    }
    cin >>st>>en;
    //cout <<endl;
    dfs (1);

    int ccnum=1;
    for(int i=1;i<=n;i++){
        if (no_scc[i]==0){
            //cout <<i <<"ASDFASDF" <<endl;
            cc(i,ccnum);
            ccnum++;
        }
    }
    //cout <<endl;
    for (int i=0;i<Art.size();i++){
        pair<int,int> b=Art[i];
        if (no_scc[b.F]==no_scc[b.S]){
            art[no_scc[b.F]]++;
        }else {
            mp1[{no_scc[b.F],no_scc[b.S]}]=true;
            mp1[{no_scc[b.S],no_scc[b.F]}]=true;
        }
    }
    for (int i=0;i<brdg.size();i++){
        int a=brdg[i].F;
        int b=brdg[i].S;
        vtree[no_scc[a]].push_back (no_scc[b]);
        vtree[no_scc[b]].push_back (no_scc[a]);
    }
    //cout <<no_scc[st]<<" "<<no_scc[en]<<endl;
    int ans=dfs1 (no_scc[st],-1,art[no_scc[st]]);

    if (ans){
        cout <<"YES"<<endl;
    }else {
        cout <<"NO"<<endl;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define PMax 100000000
#define GNode 100
using ll= long long;

///vector
int a[40000][40000];

int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll l,r;
        cin>>l>>r;
        double x=floor(r/l);
        if(x==1)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }

    }

}


#include<bits/stdc++.h>
using namespace std;
#define PMax 100000000
#define GNode 100
using ll= long long;

///vector
int a[7500][7500];

int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll l,r;
        cin>>l>>r;
        double x=floor(r/l);
        if(x==1)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }

    }

}


#include<bits/stdc++.h>
using namespace std;
#define PMax 100000000
#define GNode 100
using ll= long long;

///vector

int a[7900][7900];

int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll l,r;
        cin>>l>>r;
        double x=floor(r/l);
        if(x==1)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }

    }

}


#include<bits/stdc++.h>
using namespace std;
#define PMax 100000000
#define GNode 100
using ll= long long;

///vector
int a[32000][32000];

int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll l,r;
        cin>>l>>r;
        double x=floor(r/l);
        if(x==1)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }

    }

}


#include<bits/stdc++.h>
using namespace std;
#define PMax 100000000
#define GNode 100
using ll= long long;

///vector
//int a[40000][40000];

int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll l,r;
        cin>>l>>r;
        double x=floor(r/l);
        if(x==1)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }

    }

}


#include<bits/stdc++.h>
using namespace std;
#define PMax 100000000
#define GNode 100
using ll= long long;

///vector

int a[8000][8000];

int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll l,r;
        cin>>l>>r;
        double x=floor(r/l);
        if(x==1)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }

    }

}


#include<bits/stdc++.h>
using namespace std;
#define PMax 100000000
#define GNode 100
using ll= long long;

///vector
int a[7800][7800];

int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll l,r;
        cin>>l>>r;
        double x=floor(r/l);
        if(x==1)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }

    }

}


#include<bits/stdc++.h>
using namespace std;
#define PMax 100000000
#define GNode 100
using ll= long long;

///vector
vector<ll>prime;
vector<int>graph[GNode];

///markers
bool pmark[PMax];
bool Dvis[GNode];
bool Bvis[GNode];

///Sieve
void sieve()
{
    ll i,j;
    pmark[1]=1;
    for(i=4; i<=PMax; i+=2)
    {
        pmark[i]=1;
    }
    prime.push_back(2);
    for(i=3; i<=PMax; i+=2)
    {
        if(!pmark[i])
        {
            prime.push_back(i);
            for(j=i*i; j<=PMax; j+=i*2)
            {
                pmark[j]=1;
            }
        }
    }
}

///BFS
void BFS(int s)
{

    queue<int>Q;
    Q.push(s);
    Bvis[s]=1;
    while(!Q.empty())
    {
        int u=Q.front();
        Q.pop();
        for(int v:graph[u])
        {

            if(Dvis[v]==0)
            {
                int x=graph[u][v];
                Bvis[x]=1;
                Q.push(x);

            }
        }

    }

}
///DFS
void DFS(int u)
{

    Dvis[u]=1;
    for(int v:graph[u])
    {

        if(Dvis[v]==0)
        {

            DFS(v);
        }

    }
}

///DSU
class DSU
{
public:
    ll parent[100],rnk[100];

    DSU(int n)
    {
        for(int i=0; i<n; i++)
        {

            parent[i] = i;
            rnk[i] = 0;
        }

    }

    int find_set(int v)
    {
        if (v == parent[v])
        {
            return v;
        }
        return parent[v] = find_set(parent[v]);
    }
    void union_set(int a, int b)
    {
        a = find_set(a);
        b = find_set(b);
        if (a != b)
        {
            if (rnk[a] < rnk[b])
                swap(a, b);
            parent[b] = a;
            if (rnk[a] == rnk[b])
                rnk[a]++;
        }
    }
};

int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll l,r;
        cin>>l>>r;
        double x=floor(r/l);
        if(x==1)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }

    }

}


#include<bits/stdc++.h>
using namespace std;
#define PMax 100000000
#define GNode 100
using ll= long long;

///vector

int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll l,r;
        cin>>l>>r;
        double x=floor(r/l);
        if(x==1)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }

    }

}


#include<bits/stdc++.h>
using namespace std;
#define PMax 100000000
#define GNode 100
using ll= long long;

///vector

int a[7000][7000];

int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll l,r;
        cin>>l>>r;
        double x=floor(r/l);
        if(x==1)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }

    }

}


#include<bits/stdc++.h>
using namespace std;
#define PMax 100000000
#define GNode 100
using ll= long long;

///vector

int a[20000][20000];

int main()
{
    ll tc;
    cin>>tc;
    while(tc--)
    {
        ll l,r;
        cin>>l>>r;
        double x=floor(r/l);
        if(x==1)
        {
            cout<<"YES"<<endl;
        }
        else
        {
            cout<<"NO"<<endl;
        }

    }

}


#include<bits/stdc++.h>
using namespace std;
#define PMax 100000000
#define GNode 100
using ll= long long;

///vector
vector<ll>prime;
vector<int>graph[GNode];

///markers
bool pmark[PMax];
bool Dvis[GNode];
bool Bvis[GNode];

///Sieve
void sieve()
{
    ll i,j;
    pmark[1]=1;
    for(i=4; i<=PMax; i+=2)
    {
        pmark[i]=1;
    }
    prime.push_back(2);
    for(i=3; i<=PMax; i+=2)
    {
        if(!pmark[i])
        {
            prime.push_back(i);
            for(j=i*i; j<=PMax; j+=i*2)
            {
                pmark[j]=1;
            }
        }
    }
}

///BFS
void BFS(int s)
{

    queue<int>Q;
    Q.push(s);
    Bvis[s]=1;
    while(!Q.empty())
    {
        int u=Q.front();
        Q.pop();
        for(int v:graph[u])
        {

            if(Dvis[v]==0)
            {
                int x=graph[u][v];
                Bvis[x]=1;
                Q.push(x);

            }
        }

    }

}
///DFS
void DFS(int u)
{

    Dvis[u]=1;
    for(int v:graph[u])
    {

        if(Dvis[v]==0)
        {

            DFS(v);
        }

    }
}

///DSU
class DSU {
public:
    ll parent[100],rnk[100];

    DSU(int n){
        for(int i=0;i<n;i++){

        parent[i] = i;
        rnk[i] = 0;
        }

    }

    int find_set(int v) {
        if (v == parent[v]){
            return v;
            }
        return parent[v] = find_set(parent[v]);
    }
    void union_set(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (rnk[a] < rnk[b])
                swap(a, b);
            parent[b] = a;
            if (rnk[a] == rnk[b])
                rnk[a]++;
        }
    }
};

int main()
{
    ll tc;
    cin>>tc;
    while(tc--){
    ll l,r;
    cin>>l>>r;
    if(l==1&&r==2){
        cout<<"NO"<<endl;
    }else{
    cout<<"YES"<<endl;
    }

    }

}


#include <iostream>
using namespace std;
int main(){
    int t, l, r, i;
    while(cin >> t){
        for(i = 1; i <= t; i ++){
            cin >> l >> r;
            if((l <= 1 && 1 <= r) || (l <= 2 && 2 <= r))
                cout << "NO\n";
            else
                cout << "YES\n";
        }
    }
}


#include <iostream>
using namespace std;
int main() {
	int t, l, r, i, n, team1, team2, d;
	while(cin >> t){
		for(i = 1; i <= t; i ++){
			cin >> l >> r;
			d = r - l + 1;
			bool Find = false;
			n = d;
			while(true){
				team1 = (l / d) + 1;
				team2 = l + d;
				if((2 * n - 1) * d == l || (2 * n - 1) * d + n == l){
					Find = true;
					break;
				}
				else if(d == 1){
					Find = true;
					break;
				}
				if((2 * n - 1) * d > l){
					if(n == 1)
						break;
					else {
						d ++;
						n = 0;
					}
				}
				n ++;
			}
			if(Find)
				cout << "YES\n";
			else
				cout << "NO\n";
		}
	}
}


#include <iostream>
using namespace std;
int main() {
	int t, l, r, i, n, team1, team2, d;
	while(cin >> t){
		for(i = 1; i <= t; i ++){
			cin >> l >> r;
			d = l;
			bool Find = false;
			while(true){
				team1 = (l / d) + 1;
				team2 = l + d;
				if((l / d + 1) % 2 == 0 && (l / d + 1) / 2 >= 1){
					Find = true;
					break;
				}
				else if((l + d) % (2 * d + 1) == 0 && (l + d) / (2 * d + 1) >= 1){
					Find = true;
					break;
				}
				else if(d == 1){
					Find = true;
					break;
				}
				if(d > l)
					break;
				else
					d ++;
			}
			if(Find)
				cout << "YES\n";
			else
				cout << "NO\n";
		}
	}
}


#include <iostream>
using namespace std;
int main() {
	int t, l, r, i, j;
	while(cin >> t){   // if  x % a >= a/2
		for(i = 1; i <= t; i ++){
			cin >> l >> r;
			if(l >= 3 || r >= 3)
				cout << "YES\n";
			else
				cout << "NO\n";
		}
	}
}


#include <iostream>
using namespace std;
int main() {
	int t, l, r, i, j, team1, team2, d;
	while(cin >> t){
		for(i = 1; i <= t; i ++){
			cin >> l >> r;
			d = r - l + 1;
			team1 = (l / d) + 1;
			team2 = l + d;
			if(team1 % 2 == 0 && team1 / 2 >= 1)
				cout << "YES\n";
			else if(team2 % (2 * d + 1) == 0 && team2 / (2 * d + 1) >= 1)
				cout << "YES\n";
			else if(d == 1)
				cout << "YES\n";
			else
				cout << "NO\n";
		}
	}
}


#include <iostream>
using namespace std;
int main() {
	int t, l, r, i, j, team1, team2, d;
	while(cin >> t){
		for(i = 1; i <= t; i ++){
			cin >> l >> r;
			d = r - l + 1;
			team1 = (l / d) + 1;
			team2 = l + d;
			if(team1 % 2 == 0 && team1 / 2 >= 1)
				cout << "YES\n";
			else if(team2 % (2 * d + 1) == 0 && team2 / (2 * d + 1) >= 1)
				cout << "YES\n";
			else
				cout << "NO\n";
		}
	}
}


#include <iostream>
using namespace std;
int main() {
	int t, l, r, i, n, team1, team2, d;
	while(cin >> t){
		for(i = 1; i <= t; i ++){
			cin >> l >> r;
			d = r - l + 1;
			bool Find = false;
			while(true){
				team1 = (l / d) + 1;
				team2 = l + d;
				if((l / d + 1) % 2 == 0 && (l / d + 1) / 2 >= 1){
					Find = true;
					break;
				}
				else if((l + d) % (2 * d + 1) == 0 && (l + d) / (2 * d + 1) >= 1){
					Find = true;
					break;
				}
				else if(d == 1){
					Find = true;
					break;
				}
				if(d > l)
					break;
				else
					d ++;
			}
			if(Find)
				cout << "YES\n";
			else
				cout << "NO\n";
		}
	}
}


#include <iostream>
using namespace std;
int main() {
	int t, l, r, i, n, team1, team2, d;
	while(cin >> t){
		for(i = 1; i <= t; i ++){
			cin >> l >> r;
			d = max(l, r - l + 1);
			bool Find = false;
			while(true){
				team1 = (l / d) + 1;
				team2 = l + d;
				if((l / d + 1) % 2 == 0 && (l / d + 1) / 2 >= 1){
					Find = true;
					break;
				}
				else if((l + d) % (2 * d + 1) == 0 && (l + d) / (2 * d + 1) >= 1){
					Find = true;
					break;
				}
				else if(r == l){
					Find = true;
					break;
				}
				if(d > l)
					break;
				else
					d ++;
			}
			if(Find)
				cout << "YES\n";
			else
				cout << "NO\n";
		}
	}
}


#include <iostream>
using namespace std;
int main() {
	int t, l, r, i, n, team1, team2, d;
	while(cin >> t){
		for(i = 1; i <= t; i ++){
			cin >> l >> r;
			d = r - l + 1;
			bool Find = false;
			n = 1;
			while(true){
				team1 = (l / d) + 1;
				team2 = l + d;
				if((2 * n - 1) * d == l || (2 * n - 1) * d + n == l){
					Find = true;
					break;
				}
				else if(d == 1){
					Find = true;
					break;
				}
				if((2 * n - 1) * d > l){
					if(n == 1 && d != r - l + 1)
						break;
					else {
						d ++;
						n = 0;
					}
				}
				n ++;
			}
			if(Find)
				cout << "YES\n";
			else
				cout << "NO\n";
		}
	}
}


#include <iostream>
using namespace std;
int main() {
	int t, l, r, i, n, team1, team2, d;
	while(cin >> t){
		for(i = 1; i <= t; i ++){
			cin >> l >> r;
			d = r - l + 1;
			bool Find = false;
			n = 1;
			while(true){
				team1 = (l / d) + 1;
				team2 = l + d;
				if((2 * n - 1) * d == l || (2 * n - 1) * d + n == l){
					Find = true;
					break;
				}
				else if(d == 1){
					Find = true;
					break;
				}
				if((2 * n - 1) * d > l){
					if(n == 2)
						break;
					else {
						d ++;
						n = 1;
					}
				}
				n ++;
			}
			if(Find)
				cout << "YES\n";
			else
				cout << "NO\n";
		}
	}
}


#include <iostream>
using namespace std;
int main() {
	int t, l, r, i, j;
	while(cin >> t){   // if  x % a >= a/2
		for(i = 1; i <= t; i ++){
			cin >> l >> r;
			if(l >= 3)
				cout << "YES\n";
			else
				cout << "NO\n";
		}
	}
}


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

#define int long long int
#define in cin >>
#define out cout <<
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=b;i>=a;i--)
#define sz(a) int(a.size())
#define inarray(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define fast ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
#define vi vector<int>
#define vp vector<pair<int,int>>
#define pb push_back
#define fr first
#define sc second

void solve(){
    int l; in l;
    int r; in r;
    if((l)%(r+1)>=l/2||l/2){
        out "YES"<<endl;
    }else{
        out "NO"<<endl;
    }
}

int32_t main() {
	int t;in t;
	while(t--)
	    solve();
	return 0;
}


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

#define int long long int
#define in cin >>
#define out cout <<
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=b;i>=a;i--)
#define sz(a) int(a.size())
#define inarray(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define fast ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
#define vi vector<int>
#define vp vector<pair<int,int>>
#define pb push_back
#define fr first
#define sc second

void solve(){
    int l; in l;
    int r; in r;
    if(l/2>0&&(l)%(r+1)>=l/2){
        out "YES"<<endl;
    }else{
        out "NO"<<endl;
    }
}

int32_t main() {
	int t;in t;
	while(t--)
	    solve();
	return 0;
}


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

#define int long long int
#define in cin >>
#define out cout <<
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=b;i>=a;i--)
#define sz(a) int(a.size())
#define inarray(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define fast ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
#define vi vector<int>
#define vp vector<pair<int,int>>
#define pb push_back
#define fr first
#define sc second

void solve(){
    int l; in l;
    int r; in r;
    if((l)%(r+1)>=l/2&&l!=1||l/2){
        out "YES"<<endl;
    }else{
        out "NO"<<endl;
    }
}

int32_t main() {
	int t;in t;
	while(t--)
	    solve();
	return 0;
}


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

#define int long long int
#define in cin >>
#define out cout <<
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=b;i>=a;i--)
#define sz(a) int(a.size())
#define inarray(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define fast ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
#define vi vector<int>
#define vp vector<pair<int,int>>
#define pb push_back
#define fr first
#define sc second

void solve(){
    int l; in l;
    int r; in r;
    if(l/2>0&&(l)%(r+1)>=l/2){
        out "YES"<<endl;
    }else if(l/2>0&&(r)%(l/2)>=l/4){
        out "YES"<<endl;
    }else{
        out "NO"<<endl;
    }
}

int32_t main() {
	int t;in t;
	while(t--)
	    solve();
	return 0;
}


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

#define int long long int
#define in cin >>
#define out cout <<
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=b;i>=a;i--)
#define sz(a) int(a.size())
#define inarray(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define fast ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
#define vi vector<int>
#define vp vector<pair<int,int>>
#define pb push_back
#define fr first
#define sc second

void solve(){
    int l; in l;
    int r; in r;
    int h=(r+2-r%2)/2;
    if(l/2&&(l)%(r+1)>=(r+1)/2){
        out "YES"<<endl;
    }else if(l!=1&&l%h>=h/2){
        out "YES"<<endl;
    }else{
        out "NO"<<endl;
    }
}

int32_t main() {
	int t;in t;
	while(t--)
	    solve();
	return 0;
}


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

#define int long long int
#define in cin >>
#define out cout <<
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=b;i>=a;i--)
#define sz(a) int(a.size())
#define inarray(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define fast ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
#define vi vector<int>
#define vp vector<pair<int,int>>
#define pb push_back
#define fr first
#define sc second

void solve(){
    int l; in l;
    int r; in r;
    int h=(r+1)/2;
    if(l/2&&(l)%(r+1)>=(r+1)/2){
        out "YES"<<endl;
    }else if(l!=1&&l%h>=h/2){
        out "YES"<<endl;
    }else{
        out "NO"<<endl;
    }
}

int32_t main() {
	int t;in t;
	while(t--)
	    solve();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

#define int long long int
#define in cin >>
#define out cout <<
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=b;i>=a;i--)
#define sz(a) int(a.size())
#define inarray(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define fast ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
#define vi vector<int>
#define vp vector<pair<int,int>>
#define pb push_back
#define fr first
#define sc second

int32_t main()
{
	fast
	int t;cin>>t;
	while(t-->0){
        int l;
        cin>>l;
        int r;
        in r;
        if(2*l>r){
            out "YES"<<endl;
        }else{
            out "NO"<<endl;
        }

	}

	return 0;
}


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

#define int long long int
#define in cin >>
#define out cout <<
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=b;i>=a;i--)
#define sz(a) int(a.size())
#define inarray(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define fast ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
#define vi vector<int>
#define vp vector<pair<int,int>>
#define pb push_back
#define fr first
#define sc second

void solve(){
    int l; in l;
    int r; in r;
    if(l/2>0&&(l)%(r+1)>=l/2){
        out "YES"<<endl;
    }else if(l/2>0&&l%4==0&&(r)%(l/2)>=l/4){
        out "YES"<<endl;
    }else{
        out "NO"<<endl;
    }
}

int32_t main() {
	int t;in t;
	while(t--)
	    solve();
	return 0;
}


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

#define int long long int
#define in cin >>
#define out cout <<
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=b;i>=a;i--)
#define sz(a) int(a.size())
#define inarray(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define fast ios_base::sync_with_stdio(false); cout.tie(NULL); cin.tie(NULL);
#define vi vector<int>
#define vp vector<pair<int,int>>
#define pb push_back
#define fr first
#define sc second

void solve(){
    int l; in l;
    int r; in r;
    if(l/2&&(l)%(r+1)>=(r+1)/2){
        out "YES"<<endl;
    }else if(l/2>0&&l%4==0&&(r)%(l/2)>=l/4){
        out "YES"<<endl;
    }else{
        out "NO"<<endl;
    }
}

int32_t main() {
	int t;in t;
	while(t--)
	    solve();
	return 0;
}


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

int32_t main()
{

  int t;
  cin>>t;
  while(t--)
  {
    int l,r;
    cin>>l>>r;
    if((l==1 and r==2) or (l==1 and r==1))
    {
      cout<<"NO"<<endl;
    }
    else cout<<"YES"<<endl;

    }

}


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

int32_t main()
{

  int t;
  cin>>t;
  while(t--)
  {
    int l,r;
    cin>>l>>r;
    if(l==1 and r==2)
    {
      cout<<"NO"<<endl;
    }
    else cout<<"YES"<<endl;

    }

}


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

int32_t main()
{

  int t;
  cin>>t;
  while(t--)
  {
    int l,r;
    cin>>l>>r;
    if(l==1 or r==1 )
    {
      cout<<"NO"<<endl;
    }
    else cout<<"YES"<<endl;

    }

}


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

int32_t main()
{

  int t;
  cin>>t;
  while(t--)
  {
    int l,r;
    cin>>l>>r;
    if(l==1 or l==2 or r==1 or r==2)
    {
      cout<<"NO"<<endl;
    }
    else cout<<"YES"<<endl;

    }

}


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

int32_t main()
{

  int t;
  cin>>t;
  while(t--)
  {
    int l,r;
    cin>>l>>r;
    if(ceil((1.0*(r+1))/(1.0*2))<=l)
    {
      cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;

    }

}


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

int32_t main()
{

  int t;
  cin>>t;
  while(t--)
  {
    int l,r;
    cin>>l>>r;
    if((l<=1 and r<=2))
    {
      cout<<"NO"<<endl;
    }
    else cout<<"YES"<<endl;

    }

}


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

int32_t main()
{

  int t;
  cin>>t;
  while(t--)
  {
    int l,r;
    cin>>l>>r;
    if(((r+1)/2)<l)
    {
      cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;

    }

}


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

int32_t main()
{

  int t;
  cin>>t;
  while(t--)
  {
    int l,r;
    cin>>l>>r;
    if(l==1)
    {
      cout<<"NO"<<endl;
    }
    else cout<<"YES"<<endl;

    }

}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main (){
	int t;
	cin>>t;
	while(t--){
		int a,b;
		cin>>a>>b;
		if((a*b/2)%2==0) cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main (){
	int t;
	cin>>t;
	while(t--){
		int a,b;
		cin>>a>>b;
		if(a==1&&b==1) cout<<"NO\n";
		else if(a==2&&b==2) cout<<"NO\n";
		else if(a==1&&b==2) cout<<"NO\n";
		else if(a==b) cout<<"NO\n";
		else cout<<"YES\n";
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main (){
	int t;
	cin>>t;
	while(t--){
		int a,b;
		cin>>a>>b;
		if((a%(2*a))>=(a*2/2)&&b<2*a) cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main (){
	int t;
	cin>>t;
	while(t--){
		int a,b;
		cin>>a>>b;
		int tt=sqrt(a*a+b*b);
		if((a%tt)>tt/2) cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main (){
	int t;
	cin>>t;
	while(t--){
		int a,b;
		cin>>a>>b;
		if(a>=1&&a<=2&&b>=1&&b<=2) cout<<"NO\n";
		else cout<<"YES\n";
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main (){
	int t;
	cin>>t;
	while(t--){
		int a,b;
		cin>>a>>b;
		int tt=sqrt(a*a+b*b);
		int d=b-a+1;
		if((a%tt)>tt/d) cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main (){
	int t;
	cin>>t;
	while(t--){
		int a,b;
		cin>>a>>b;
		int tt=sqrt(a*a+b*b);
		int d=b-a+1;
		if((a%tt)>tt/2||(b%tt)>tt/2) cout<<"YES\n";
		else cout<<"NO\n";
	}
	return 0;
}