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

#define int long long
#define INF LLONG_MAX
#define _INF LLONG_MIN
#define endl '\n'

struct Grafo{
	vector<vector<int>> adj, cost, usable;
	vector<int> low, d, pai;
	vector<bool> vis, vtxValue;
	vector<pair<int, int>> bridges;
	vector<int> cost_bridge;
	int tempo = 0;

	Grafo(int n){
		adj.resize(n);
		usable = vector<vector<int>> (n, vector<int> (n, 0));
		cost.resize(n);
		low.resize(n, INF);
		d.resize(n, INF);
		pai.resize(n, INF);
		vis.resize(n, false);
		vtxValue.resize(n, false);
	}
};

int dfsBridges(int u, Grafo & g){
	g.tempo++;
	g.low[u] = g.tempo;
	g.d[u] = g.tempo;
	g.vis[u] = true;
	for (int i = 0; i < g.adj[u].size(); i++){
		int v = g.adj[u][i];
		if (!g.vis[v]){
			g.pai[v] = u;
			dfsBridges(v, g);
			if (g.low[v] > g.d[u]){
				g.usable[u][v] = 0;
				g.usable[v][u] = 0;
				g.bridges.emplace_back(u, v);
				g.bridges.emplace_back(v, u);
				g.cost_bridge.push_back(g.cost[u][i]);
			}
			g.low[u] = min(g.low[u], g.low[v]);
		}
		else if (g.pai[u] != v){
			g.low[u] = min(g.low[u], g.d[v]);
		}
	}
}

void dfsCompConex(int u, Grafo & g, vector<int> & compConex){
	g.vis[u] = true;
	for (int v : g.adj[u]){
		if (!g.vis[v] && g.usable[u][v]){
			dfsCompConex(v, g, compConex);
		}
	}
	compConex.push_back(u);
}

bool dfs(int a, int b, Grafo & g, bool f){
	g.vis[a] = true;
	if (g.vtxValue[a]) f = true;
	if (a == b){
		// cout << "Chegou\n" << f << endl;
		return f;
	}
	for (int i = 0; i < g.adj[a].size(); i++){
		int v = g.adj[a][i];
		if (!g.vis[v]){
			// cout << a << " " << v << " " << g.cost[a][i] << endl;
			if(dfs(v, b, g, f || g.cost[a][i])){
				return true;
			}
		}
	}
	return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, m, t = 1;
	cin >> n >> m;
	Grafo g = Grafo(n);
	for (int i = 0; i < m; i++){
		int x, y, w;
		cin >> x >> y >> w;
		x--; y--;

		g.usable[x][y] = 1;

		g.adj[x].push_back(y);
		g.adj[y].push_back(x);

		g.cost[x].push_back(w);
		g.cost[y].push_back(w);
	}
	int a, b;
	cin >> a >> b;
	a--; b--;

	for (int i = 0; i < n; i++){
		if (!g.vis[i]){
			dfsBridges(i, g);
		}
	}

	g.vis.assign(n, false);

	vector<int> new_id(n);

	int id = 0;

	for (int i = 0; i < n; i++){
		if (!g.vis[i]){
			vector<int> compConex;
			dfsCompConex(i, g, compConex);
			sort(compConex.begin(), compConex.end());
			for (int u : compConex){
				new_id[u] = id;
				// cout << u << " " << id << endl;
				for (int i = 0; i < g.adj[u].size(); i++){
					if (binary_search(compConex.begin(), compConex.end(), g.adj[u][i])){
						g.vtxValue[id] = g.vtxValue[id] || (g.cost[u][i] > 0);
					}
				}
			}
			id++;
		}
	}

	// cout << g.vtxValue[1] << endl;

	for (int i = 0; i < n; i++){
		g.adj[i].clear();
		g.cost[i].clear();
	}
	g.adj.resize(id);
	g.cost.resize(id);
	g.vis.assign(id, false);

	for (int i = 0; i < g.bridges.size(); i++){
		int u, v;
		tie(u, v) = g.bridges[i];
		// cout << u << "-" << v << "-" << g.cost_bridge[i] << endl;
		u = new_id[u]; v = new_id[v];
		if (u != v){
			g.adj[u].push_back(v);
			g.cost[u].push_back(g.cost_bridge[i]);
		}
	}

	a = new_id[a]; b = new_id[b];

	if (dfs(a, b, g, false)){
		cout << "YES\n";
		return 0;
	}
	g.vis.assign(id, false);
	if (dfs(b, a, g, false)){
		cout << "YES\n";
		return 0;
	}
	else cout << "NO\n";

}


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

#define int long long
#define INF LLONG_MAX
#define _INF LLONG_MIN
#define endl '\n'

struct Grafo{
	vector<vector<int>> adj, cost;
	vector<int> low, d, pai;
	vector<bool> vis, vtxValue;
	vector<pair<int, int>> bridges;
	vector<int> cost_bridge;
	int tempo = 0;

	map<pair<int, int>, bool> unusable;

	Grafo(int n){
		adj.resize(n);
		cost.resize(n);
		low.resize(n, INF);
		d.resize(n, INF);
		pai.resize(n, INF);
		vis.resize(n, false);
		vtxValue.resize(n, false);
	}
};

int dfsBridges(int u, Grafo & g){
	g.tempo++;
	g.low[u] = g.tempo;
	g.d[u] = g.tempo;
	g.vis[u] = true;
	for (int i = 0; i < g.adj[u].size(); i++){
		int v = g.adj[u][i];
		if (!g.vis[v]){
			g.pai[v] = u;
			dfsBridges(v, g);
			if (g.low[v] > g.d[u]){
				g.unusable[make_pair(u, v)] = true;
				g.unusable[make_pair(v, u)] = true;
				g.bridges.emplace_back(u, v);
				g.bridges.emplace_back(v, u);
				g.cost_bridge.push_back(g.cost[u][i]);
				g.cost_bridge.push_back(g.cost[u][i]);
			}
			g.low[u] = min(g.low[u], g.low[v]);
		}
		else if (g.pai[u] != v){
			g.low[u] = min(g.low[u], g.d[v]);
		}
	}
}

void dfsCompConex(int u, Grafo & g, vector<int> & compConex){
	g.vis[u] = true;
	for (int v : g.adj[u]){
		if (!g.vis[v] && !g.unusable[make_pair(u,v)]){
			dfsCompConex(v, g, compConex);
		}
	}
	compConex.push_back(u);
}

bool dfs(int a, int b, Grafo & g, bool f){
	g.vis[a] = true;
	if (g.vtxValue[a]) f = true;
	if (a == b){
		// cout << "Chegou\n" << f << endl;
		return f;
	}
	for (int i = 0; i < g.adj[a].size(); i++){
		int v = g.adj[a][i];
		if (!g.vis[v]){
			// cout << a << " " << v << " " << g.cost[a][i] << endl;
			if(dfs(v, b, g, f || g.cost[a][i])){
				return true;
			}
		}
	}
	return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, m, t = 1;
	cin >> n >> m;
	Grafo g = Grafo(n);
	for (int i = 0; i < m; i++){
		int x, y, w;
		cin >> x >> y >> w;
		x--; y--;

		g.adj[x].push_back(y);
		g.adj[y].push_back(x);

		g.cost[x].push_back(w);
		g.cost[y].push_back(w);
	}
	int a, b;
	cin >> a >> b;
	a--; b--;

	for (int i = 0; i < n; i++){
		if (!g.vis[i]){
			dfsBridges(i, g);
		}
	}

	g.vis.assign(n, false);

	vector<int> new_id(n);

	int id = 0;

	for (int i = 0; i < n; i++){
		if (!g.vis[i]){
			vector<int> compConex;
			dfsCompConex(i, g, compConex);
			sort(compConex.begin(), compConex.end());
			for (int u : compConex){
				new_id[u] = id;
				// cout << u << " " << id << endl;
				for (int i = 0; i < g.adj[u].size(); i++){
					if (binary_search(compConex.begin(), compConex.end(), g.adj[u][i])){
						g.vtxValue[id] = g.vtxValue[id] || (g.cost[u][i] > 0);
					}
				}
			}
			id++;
		}
	}

	// cout << g.vtxValue[1] << endl;

	for (int i = 0; i < n; i++){
		g.adj[i].clear();
		g.cost[i].clear();
	}
	g.adj.resize(id);
	g.cost.resize(id);
	g.vis.assign(id, false);

	for (int i = 0; i < g.bridges.size(); i++){
		int u, v;
		tie(u, v) = g.bridges[i];
		// cout << u << "-" << v << "-" << g.cost_bridge[i] << endl;
		u = new_id[u]; v = new_id[v];
		if (u != v){
			g.adj[u].push_back(v);
			g.cost[u].push_back(g.cost_bridge[i]);
		}
	}

	a = new_id[a]; b = new_id[b];

	if (dfs(a, b, g, false)){
		cout << "YES\n";
		return 0;
	}
	// g.vis.assign(id, false);
	// if (dfs(b, a, g, false)){
	// 	cout << "YES\n";
	// 	return 0;
	// }
	else cout << "NO\n";

}


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

#define int long long
#define INF LLONG_MAX
#define _INF LLONG_MIN
#define endl '\n'

struct Grafo{
	vector<vector<int>> adj, adjDir, sccs;
	vector<int> low, d, pai, sccCost;
	vector<bool> vis;
	map<pair<int, int>, bool> is_used;
	map<pair<int, int>, int> cost, costDir;
	set<pair<int, int>> bridges;
	int tempo = 0;

	Grafo(int n){
		adj.resize(n);
		adjDir.resize(n);
		low.resize(n, INF);
		d.resize(n, INF);
		pai.resize(n, INF);
		vis.resize(n, false);
	}
};

void dfsBridges(int u, Grafo & grafo, vector<int> & ordem_vis){
	grafo.tempo++;
	grafo.d[u] = grafo.tempo;
	grafo.low[u] = grafo.tempo;
	grafo.vis[u] = true;
	for (int v : grafo.adj[u]){
		if (!grafo.is_used[make_pair(u, v)]){
			// monta grafo direcionado para calcular sccs
			grafo.adjDir[u].push_back(v);
			grafo.costDir[make_pair(u, v)] = grafo.cost[make_pair(u, v)];

			grafo.is_used[make_pair(u, v)] = true;
			grafo.is_used[make_pair(v, u)] = true;
		}
		if (!grafo.vis[v]){
			grafo.pai[v] = u;
			dfsBridges(v, grafo, ordem_vis);
			if(grafo.low[v] > grafo.d[u]){
				grafo.bridges.emplace(u, v);
			}
			grafo.low[u] = min(grafo.low[u], grafo.low[v]);
		}
		else if (grafo.pai[u] != v){
			grafo.low[u] = min(grafo.low[u], grafo.d[v]);
		}
	}
	ordem_vis.push_back(u);
}

void dfsSCC(int u, Grafo & grafo){
	grafo.vis[u] = true;
	for(int v : grafo.adjDir[u]){
		if (!grafo.vis[v]){
			dfsSCC(v, grafo);
		}
	}
	grafo.sccs[grafo.sccs.size() - 1].push_back(u);
}

bool dfs(int a, int b, vector<vector<int>> & adj, map<pair<int,int>, int> & costE, vector<int> & costV, vector<bool> & vis, bool f){
	vis[a] = true;
	if (a == b){
		if (costV[a]) f = true;
		return f;
	}
	// cout << "A = " << a << " " << adj[a].size() << endl;
	for (int i = 0; i < adj[a].size(); i++){
		int v = adj[a][i];
		if (!vis[v]){
	    	// cout << a << " " << v << " " << costE[make_pair(a, v)] << endl;
			f = costV[a] || costE[make_pair(a, v)];
			if(dfs(v, b, adj, costE, costV, vis, f)){
				return true;
			}
		}
	}
	return false;
}

signed main(){
	int n, m, t = 1;
	cin >> n >> m;
	Grafo grafo = Grafo(n);
	for (int i = 0; i < m; i++){
		int x, y, w;
		cin >> x >> y >> w;
		x--; y--;

		grafo.adj[x].push_back(y);
		grafo.adj[y].push_back(x);

		grafo.cost[make_pair(x, y)] = w;
		grafo.cost[make_pair(y, x)] = w;
	}

	int a, b;
	cin >> a >> b;
	a--; b--;

	vector<int> ordem_vis;

	for (int i = 0; i < n; i++){
		if (!grafo.vis[i]){
			dfsBridges(i, grafo, ordem_vis);
		}
	}

	grafo.vis.assign(n, false);

	map<int, int> new_id;

	for (int i = n - 1; i >= 0; i--){
		if (!grafo.vis[i]){
			grafo.sccs.push_back(vector<int> ());
			grafo.sccCost.push_back(0);
			dfsSCC(i, grafo);
			for (int v : grafo.sccs[grafo.sccs.size() - 1]){
				new_id[v] = grafo.sccs.size() - 1;
				// cout << v << " " << new_id[v] << endl;
			}
			for (int u : grafo.sccs[grafo.sccs.size() - 1]){
				for (int v : grafo.sccs[grafo.sccs.size() - 1]){
					grafo.sccCost[grafo.sccCost.size() - 1] += grafo.cost[make_pair(u, v)];
				}
			}
			// cout << endl;
		}
	}

	vector<vector<int>> adj_tree(n), adj_treeT(n);
	map<pair<int,int>, int> cost_tree, cost_treeT;
	vector<bool> vis(n, false);

	// cout << grafo.sccCost[0] << endl;

	for (pair<int, int> p : grafo.bridges){
		int u, v;
		tie(u, v) = p;
		int cost_edge = grafo.costDir[make_pair(u, v)];
		// cout << "old: " << u << " " << v << " ";
		u = new_id[u]; v = new_id[v];
        // cout << "new: " << u << " " << v << endl;
		if (u != v){
			// cout << u << "-" << v << endl;
		    // cout << cost_edge << endl;
			adj_tree[u].push_back(v);
			adj_tree[v].push_back(u);
			cost_tree[make_pair(u, v)] = cost_edge;
			cost_tree[make_pair(v, u)] = cost_edge;
		}
	}

	a = new_id[a]; b = new_id[b];

	if (dfs(a, b, adj_tree, cost_tree, grafo.sccCost, vis, false)){
		cout << "YES\n";
	}
	else cout << "NO\n";

}


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

// #define int long long
#define INF LLONG_MAX
#define _INF LLONG_MIN
#define endl '\n'

struct Grafo{
	vector<vector<int>> adj, adjDir, sccs;
	vector<int> low, d, pai, sccCost;
	vector<bool> vis;
	map<pair<int, int>, bool> is_used;
	map<pair<int, int>, int> cost, costDir;
	set<pair<int, int>> bridges;
	int tempo = 0;

	Grafo(int n){
		adj.resize(n);
		adjDir.resize(n);
		low.resize(n, INF);
		d.resize(n, INF);
		pai.resize(n, INF);
		vis.resize(n, false);
	}
};

void dfsBridges(int u, Grafo & grafo, vector<int> & ordem_vis){
	grafo.tempo++;
	grafo.d[u] = grafo.tempo;
	grafo.low[u] = grafo.tempo;
	grafo.vis[u] = true;
	for (int v : grafo.adj[u]){
		if (!grafo.is_used[make_pair(u, v)]){
			// monta grafo direcionado para calcular sccs
			grafo.adjDir[u].push_back(v);
			grafo.costDir[make_pair(u, v)] = grafo.cost[make_pair(u, v)];

			grafo.is_used[make_pair(u, v)] = true;
			grafo.is_used[make_pair(v, u)] = true;
		}
		if (!grafo.vis[v]){
			grafo.pai[v] = u;
			dfsBridges(v, grafo, ordem_vis);
			if(grafo.low[v] > grafo.d[u]){
				grafo.bridges.emplace(u, v);
			}
			grafo.low[u] = min(grafo.low[u], grafo.low[v]);
		}
		else if (grafo.pai[u] != v){
			grafo.low[u] = min(grafo.low[u], grafo.d[v]);
		}
	}
	ordem_vis.push_back(u);
}

void dfsSCC(int u, Grafo & grafo){
	grafo.vis[u] = true;
	for(int v : grafo.adjDir[u]){
		if (!grafo.vis[v]){
			dfsSCC(v, grafo);
		}
	}
	grafo.sccs[grafo.sccs.size() - 1].push_back(u);
}

bool dfs(int a, int b, vector<vector<int>> & adj, map<pair<int,int>, int> & costE, vector<int> & costV, vector<bool> & vis, bool f){
	vis[a] = true;
	if (costV[a]) f = true;
	if (a == b){
		// cout << "Chegou\n" << f << endl;
		return f;
	}
	// cout << "A = " << a << " " << adj[a].size() << endl;
	for (int i = 0; i < adj[a].size(); i++){
		int v = adj[a][i];
		if (!vis[v]){
			if(dfs(v, b, adj, costE, costV, vis, f || costE[make_pair(a, v)])){
				return true;
			}
		}
	}
	return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, m, t = 1;
	cin >> n >> m;
	Grafo grafo = Grafo(n);
	for (int i = 0; i < m; i++){
		int x, y, w;
		cin >> x >> y >> w;
		x--; y--;

		grafo.adj[x].push_back(y);
		grafo.adj[y].push_back(x);

		grafo.cost[make_pair(x, y)] = w;
		grafo.cost[make_pair(y, x)] = w;
	}

	int a, b;
	cin >> a >> b;
	a--; b--;

	vector<int> ordem_vis;

	for (int i = 0; i < n; i++){
		if (!grafo.vis[i]){
			dfsBridges(i, grafo, ordem_vis);
		}
	}

	grafo.vis.assign(n, false);

	map<int, int> new_id;

	for (int i = n - 1; i >= 0; i--){
		if (!grafo.vis[i]){
			grafo.sccs.push_back(vector<int> ());
			grafo.sccCost.push_back(0);
			dfsSCC(i, grafo);
			for (int v : grafo.sccs[grafo.sccs.size() - 1]){
				new_id[v] = grafo.sccs.size() - 1;
				// cout << v << " " << new_id[v] << endl;
			}
			for (int u : grafo.sccs[grafo.sccs.size() - 1]){
				for (int v : grafo.sccs[grafo.sccs.size() - 1]){
					// cout << u << " " << v << " " << grafo.cost[make_pair(u, v)] << endl;
					grafo.sccCost[grafo.sccCost.size() - 1] += grafo.cost[make_pair(u, v)];
					grafo.sccCost[grafo.sccCost.size() - 1] += grafo.cost[make_pair(v, u)];
				}
			}
			// cout << endl;
		}
	}

	vector<vector<int>> adj_tree(grafo.sccs.size()), adj_treeT(grafo.sccs.size());
	map<pair<int,int>, int> cost_tree, cost_treeT;
	vector<bool> vis(n, false);

	// cout << grafo.sccCost[1] << endl;

	for (pair<int, int> p : grafo.bridges){
		int u, v;
		tie(u, v) = p;
		int cost_edge = grafo.costDir[make_pair(u, v)];
		// cout << "old: " << u << " " << v << " ";
		u = new_id[u]; v = new_id[v];
        // cout << "new: " << u << " " << v << endl;
		if (u != v){
			// cout << u << "-" << v << endl;
		    // cout << cost_edge << endl;
			adj_tree[u].push_back(v);
			adj_tree[v].push_back(u);
			cost_tree[make_pair(u, v)] = cost_edge;
			cost_tree[make_pair(v, u)] = cost_edge;
		}
	}

	a = new_id[a]; b = new_id[b];

	if (dfs(a, b, adj_tree, cost_tree, grafo.sccCost, vis, false)){
		cout << "YES\n";
	}
	else cout << "NO\n";

}


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

#define int long long
#define INF LLONG_MAX
#define _INF LLONG_MIN
#define endl '\n'

struct Grafo{
	vector<vector<int>> adj, cost, usable;
	vector<int> low, d, pai;
	vector<bool> vis, vtxValue;
	vector<pair<int, int>> bridges;
	vector<int> cost_bridge;
	int tempo = 0;

	Grafo(int n){
		adj.resize(n);
		usable = vector<vector<int>> (n, vector<int> (n, 0));
		cost.resize(n);
		low.resize(n, INF);
		d.resize(n, INF);
		pai.resize(n, INF);
		vis.resize(n, false);
		vtxValue.resize(n, false);
	}
};

int dfsBridges(int u, Grafo & g){
	g.tempo++;
	g.low[u] = g.tempo;
	g.d[u] = g.tempo;
	g.vis[u] = true;
	for (int i = 0; i < g.adj[u].size(); i++){
		int v = g.adj[u][i];
		if (!g.vis[v]){
			g.pai[v] = u;
			dfsBridges(v, g);
			if (g.low[v] > g.d[u]){
				g.usable[u][v] = 0;
				g.usable[v][u] = 0;
				g.bridges.emplace_back(min(u, v), max(u, v));
				g.cost_bridge.push_back(g.cost[u][i]);
			}
			g.low[u] = min(g.low[u], g.low[v]);
		}
		else if (g.pai[u] != v){
			g.low[u] = min(g.low[u], g.d[v]);
		}
	}
}

void dfsCompConex(int u, Grafo & g, vector<int> & compConex){
	g.vis[u] = true;
	for (int v : g.adj[u]){
		if (!g.vis[v] && g.usable[u][v]){
			dfsCompConex(v, g, compConex);
		}
	}
	compConex.push_back(u);
}

bool dfs(int a, int b, Grafo & g, bool f){
	g.vis[a] = true;
	if (g.vtxValue[a]) f = true;
	if (a == b){
		// cout << "Chegou\n" << f << endl;
		return f;
	}
	for (int i = 0; i < g.adj[a].size(); i++){
		int v = g.adj[a][i];
		if (!g.vis[v]){
			if(dfs(v, b, g, f || g.cost[a][i])){
				return true;
			}
		}
	}
	return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	int n, m, t = 1;
	cin >> n >> m;
	Grafo g = Grafo(n);
	for (int i = 0; i < m; i++){
		int x, y, w;
		cin >> x >> y >> w;
		x--; y--;

		g.usable[x][y] = 1;

		g.adj[x].push_back(y);
		g.adj[y].push_back(x);

		g.cost[x].push_back(w);
		g.cost[y].push_back(w);
	}
	int a, b;
	cin >> a >> b;
	a--; b--;

	for (int i = 0; i < n; i++){
		if (!g.vis[i]){
			dfsBridges(i, g);
		}
	}

	g.vis.assign(n, false);

	vector<int> new_id(n);

	int id = 0;

	for (int i = 0; i < n; i++){
		if (!g.vis[i]){
			vector<int> compConex;
			dfsCompConex(i, g, compConex);
			sort(compConex.begin(), compConex.end());
			for (int u : compConex){
				new_id[u] = id;
				// cout << u << " " << id << endl;
				for (int i = 0; i < g.adj[u].size(); i++){
					if (binary_search(compConex.begin(), compConex.end(), g.adj[u][i])){
						g.vtxValue[id] = g.vtxValue[id] || (g.cost[u][i] > 0);
					}
				}
			}
			id++;
		}
	}

	// cout << g.vtxValue[1] << endl;

	for (int i = 0; i < n; i++){
		g.adj[i].clear();
		g.cost[i].clear();
	}
	g.adj.resize(id);
	g.cost.resize(id);
	g.vis.assign(id, false);

	for (int i = 0; i < g.bridges.size(); i++){
		int u, v;
		tie(u, v) = g.bridges[i];
		u = new_id[u]; v = new_id[v];
		if (u != v){
			g.adj[u].push_back(v);
			g.cost[u].push_back(g.cost_bridge[i]);
		}
	}

	a = new_id[a]; b = new_id[b];

	if (dfs(a, b, g, false)){
		cout << "YES\n";
		return 0;
	}
	g.vis.assign(id, false);
	if (dfs(b, a, g, false)){
		cout << "YES\n";
		return 0;
	}
	else cout << "NO\n";

}


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

#define int long long
#define INF LLONG_MAX
#define _INF LLONG_MIN
#define endl '\n'

struct Grafo{
	vector<vector<int>> adj, adjDir, sccs, cost;
	vector<int> low, d, pai, sccCost;
	vector<bool> vis;
	map<pair<int, int>, bool> is_used;
	set<pair<pair<int, int>, int>> bridges;
	int tempo = 0;

	Grafo(int n){
		adj.resize(n);
		cost.resize(n);
		adjDir.resize(n);
		low.resize(n, INF);
		d.resize(n, INF);
		pai.resize(n, INF);
		vis.resize(n, false);
	}
};

void dfsBridges(int u, Grafo & grafo, vector<int> & ordem_vis){
	grafo.tempo++;
	grafo.d[u] = grafo.tempo;
	grafo.low[u] = grafo.tempo;
	grafo.vis[u] = true;
	for (int i = 0; i < grafo.adj[u].size(); i++){
		int v = grafo.adj[u][i];
		if (!grafo.is_used[make_pair(u, v)]){
			// monta grafo direcionado para calcular sccs
			grafo.adjDir[u].push_back(v);

			grafo.is_used[make_pair(u, v)] = true;
			grafo.is_used[make_pair(v, u)] = true;
		}
		if (!grafo.vis[v]){
			grafo.pai[v] = u;
			dfsBridges(v, grafo, ordem_vis);
			if(grafo.low[v] > grafo.d[u]){
				grafo.bridges.insert(make_pair(make_pair(u, v), grafo.cost[u][i]));
			}
			grafo.low[u] = min(grafo.low[u], grafo.low[v]);
		}
		else if (grafo.pai[u] != v){
			grafo.low[u] = min(grafo.low[u], grafo.d[v]);
		}
	}
	ordem_vis.push_back(u);
}

void dfsSCC(int u, Grafo & grafo){
	grafo.vis[u] = true;
	for(int i = 0; i < grafo.adjDir[u].size(); i++){
		int v = grafo.adjDir[u][i];
		if (!grafo.vis[v]){
			dfsSCC(v, grafo);
		}
	}
	grafo.sccs.back().push_back(u);
}

bool dfs(int a, int b, Grafo & grafo, bool f){
	grafo.vis[a] = true;
	if (grafo.sccCost[a]) f = true;
	if (a == b){
		// cout << "Chegou\n" << f << endl;
		return f;
	}
	// cout << "A = " << a << " " << grafo.adj[a].size() << endl;
	for (int i = 0; i < grafo.adj[a].size(); i++){
		int v = grafo.adj[a][i];
		// cout << v << endl;
		if (!grafo.vis[v]){
			if(dfs(v, b, grafo, f || grafo.cost[a][i])){
				return true;
			}
		}
	}
	return false;
}

signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
	int n, m, t = 1;
	cin >> n >> m;
	Grafo grafo = Grafo(n);
	for (int i = 0; i < m; i++){
		int x, y, w;
		cin >> x >> y >> w;
		x--; y--;

		grafo.adj[x].push_back(y);
		grafo.adj[y].push_back(x);

		grafo.cost[x].push_back(w);
		grafo.cost[y].push_back(w);
	}
	int a, b;
	cin >> a >> b;
	a--; b--;

	vector<int> ordem_vis;

	for (int i = 0; i < n; i++){
		if (!grafo.vis[i]){
			dfsBridges(i, grafo, ordem_vis);
		}
	}

	grafo.vis.assign(n, false);

	vector<int> new_id(n);

	for (int i = n - 1; i >= 0; i--){
		if (!grafo.vis[i]){
			grafo.sccs.push_back(vector<int> ());
			grafo.sccCost.push_back(0);
			dfsSCC(i, grafo);
			sort(grafo.sccs.back().begin(), grafo.sccs.back().end());
			for (int u : grafo.sccs.back()){
				new_id[u] = grafo.sccs.size() - 1;
				// cout << u << " " << new_id[u] << endl;
				for (int i = 0; i < grafo.adj[u].size(); i++){
					if (binary_search(grafo.sccs.back().begin(), grafo.sccs.back().end(), grafo.adj[u][i])){
						grafo.sccCost.back() += grafo.cost[u][i];
					}
				}
			}
			// cout << endl;
		}
	}

	for (int i = 0; i < n; i++){
		grafo.adj[i].clear();
		grafo.cost[i].clear();
	}
	grafo.adj.resize(grafo.sccs.size());
	grafo.cost.resize(grafo.sccs.size());
	grafo.vis.assign(grafo.sccs.size(), false);

	for (pair<pair<int, int>, int> p : grafo.bridges){
		int u, v;
		tie(u, v) = p.first;
		int cost_edge = p.second;
		// cout << "old: " << u << " " << v << " ";
		u = new_id[u]; v = new_id[v];
        // cout << "new: " << u << " " << v << endl;
		if (u != v){
			// cout << u << "-" << v << endl;
		    // cout << cost_edge << endl;
			grafo.adj[u].push_back(v);
			grafo.adj[v].push_back(u);
			grafo.cost[u].push_back(cost_edge);
			grafo.cost[v].push_back(cost_edge);
		}
	}

	a = new_id[a]; b = new_id[b];

	if (dfs(a, b, grafo, false)){
		cout << "YES\n";
	}
	else cout << "NO\n";

}


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

#define int long long
#define INF LLONG_MAX
#define _INF LLONG_MIN
#define endl '\n'

struct Grafo{
	vector<vector<int>> adj, adjDir, sccs, cost;
	vector<int> low, d, pai, sccCost;
	vector<bool> vis;
	map<pair<int, int>, bool> is_used;
	set<pair<pair<int, int>, int>> bridges;
	int tempo = 0;

	Grafo(int n){
		adj.resize(n);
		cost.resize(n);
		adjDir.resize(n);
		low.resize(n, INF);
		d.resize(n, INF);
		pai.resize(n, INF);
		vis.resize(n, false);
	}
};

void dfsBridges(int u, Grafo & grafo, vector<int> & ordem_vis){
	grafo.tempo++;
	grafo.d[u] = grafo.tempo;
	grafo.low[u] = grafo.tempo;
	grafo.vis[u] = true;
	for (int i = 0; i < grafo.adj[u].size(); i++){
		int v = grafo.adj[u][i];
		if (!grafo.is_used[make_pair(u, v)]){
			// monta grafo direcionado para calcular sccs
			grafo.adjDir[u].push_back(v);

			grafo.is_used[make_pair(u, v)] = true;
			grafo.is_used[make_pair(v, u)] = true;
		}
		if (!grafo.vis[v]){
			grafo.pai[v] = u;
			dfsBridges(v, grafo, ordem_vis);
			if(grafo.low[v] > grafo.d[u]){
				grafo.bridges.insert(make_pair(make_pair(u, v), grafo.cost[u][i]));
			}
			grafo.low[u] = min(grafo.low[u], grafo.low[v]);
		}
		else if (grafo.pai[u] != v){
			grafo.low[u] = min(grafo.low[u], grafo.d[v]);
		}
	}
	ordem_vis.push_back(u);
}

void dfsSCC(int u, Grafo & grafo){
	grafo.vis[u] = true;
	for(int i = 0; i < grafo.adjDir[u].size(); i++){
		int v = grafo.adjDir[u][i];
		if (!grafo.vis[v]){
			dfsSCC(v, grafo);
		}
	}
	grafo.sccs.back().push_back(u);
}

bool dfs(int a, int b, Grafo & grafo, bool f){
	grafo.vis[a] = true;
	if (grafo.sccCost[a]) f = true;
	if (a == b){
		// cout << "Chegou\n" << f << endl;
		return f;
	}
	// cout << "A = " << a << " " << grafo.adj[a].size() << endl;
	for (int i = 0; i < grafo.adj[a].size(); i++){
		int v = grafo.adj[a][i];
		// cout << v << endl;
		if (!grafo.vis[v]){
			if(dfs(v, b, grafo, f || grafo.cost[a][i])){
				return true;
			}
		}
	}
	return false;
}

signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
	int n, m, t = 1;
	cin >> n >> m;
	Grafo grafo = Grafo(n);
	for (int i = 0; i < m; i++){
		int x, y, w;
		cin >> x >> y >> w;
		x--; y--;

		grafo.adj[x].push_back(y);
		grafo.adj[y].push_back(x);

		grafo.cost[x].push_back(w);
		grafo.cost[y].push_back(w);
	}
	int a, b;
	cin >> a >> b;
	a--; b--;

	vector<int> ordem_vis;

	for (int i = 0; i < n; i++){
		if (!grafo.vis[i]){
			dfsBridges(i, grafo, ordem_vis);
		}
	}

	grafo.vis.assign(n, false);

	vector<int> new_id(n);

	for (int i = n - 1; i >= 0; i--){
		if (!grafo.vis[i]){
			grafo.sccs.push_back(vector<int> ());
			grafo.sccCost.push_back(0);
			dfsSCC(i, grafo);
			sort(grafo.sccs.back().begin(), grafo.sccs.back().end());
			for (int u : grafo.sccs.back()){
				new_id[u] = grafo.sccs.size() - 1;
				// cout << u << " " << new_id[u] << endl;
				for (int i = 0; i < grafo.adj[u].size(); i++){
					if (binary_search(grafo.sccs.back().begin(), grafo.sccs.back().end(), grafo.adj[u][i])){
						grafo.sccCost.back() += grafo.cost[u][i];
					}
				}
			}
			// cout << endl;
		}
	}

	for (int i = 0; i < n; i++){
		grafo.adj[i].clear();
		grafo.cost[i].clear();
	}
	grafo.adj.resize(grafo.sccs.size());
	grafo.cost.resize(grafo.sccs.size());
	grafo.vis.assign(grafo.sccs.size(), false);

	for (pair<pair<int, int>, int> p : grafo.bridges){
		int u, v;
		tie(u, v) = p.first;
		int cost_edge = p.second;
		// cout << "old: " << u << " " << v << " ";
		u = new_id[u]; v = new_id[v];
        // cout << "new: " << u << " " << v << endl;
		if (u != v){
			// cout << u << "-" << v << endl;
		    // cout << cost_edge << endl;
			grafo.adj[u].push_back(v);

			grafo.cost[u].push_back(cost_edge);

		}
	}

	a = new_id[a]; b = new_id[b];

	if (dfs(a, b, grafo, false)){
		cout << "YES\n";
		return 0;
	}
	grafo.vis.assign(grafo.sccs.size(), false);
	if (dfs(b, a, grafo, false)){
		cout << "YES\n";
		return 0;
	}
	else cout << "NO\n";

}


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

#define int long long
#define INF LLONG_MAX
#define _INF LLONG_MIN
#define endl '\n'

struct Grafo{
	vector<vector<int>> adj, adjDir, sccs, cost, costDir;
	vector<int> low, d, pai, sccCost;
	vector<bool> vis;
	map<pair<int, int>, bool> is_used;
	set<pair<pair<int, int>, int>> bridges;
	int tempo = 0;

	Grafo(int n){
		adj.resize(n);
		cost.resize(n);
		adjDir.resize(n);
		costDir.resize(n);
		low.resize(n, INF);
		d.resize(n, INF);
		pai.resize(n, INF);
		vis.resize(n, false);
	}
};

void dfsBridges(int u, Grafo & grafo, vector<int> & ordem_vis){
	grafo.tempo++;
	grafo.d[u] = grafo.tempo;
	grafo.low[u] = grafo.tempo;
	grafo.vis[u] = true;
	for (int i = 0; i < grafo.adj[u].size(); i++){
		int v = grafo.adj[u][i];
		if (!grafo.is_used[make_pair(u, v)]){
			// monta grafo direcionado para calcular sccs
			grafo.adjDir[u].push_back(v);
			grafo.costDir[u].push_back(grafo.cost[u][i]);

			grafo.is_used[make_pair(u, v)] = true;
			grafo.is_used[make_pair(v, u)] = true;
		}
		if (!grafo.vis[v]){
			grafo.pai[v] = u;
			dfsBridges(v, grafo, ordem_vis);
			if(grafo.low[v] > grafo.d[u]){
				grafo.bridges.insert(make_pair(make_pair(u, v), grafo.costDir[u][i]));
			}
			grafo.low[u] = min(grafo.low[u], grafo.low[v]);
		}
		else if (grafo.pai[u] != v){
			grafo.low[u] = min(grafo.low[u], grafo.d[v]);
		}
	}
	ordem_vis.push_back(u);
}

void dfsSCC(int u, Grafo & grafo){
	grafo.vis[u] = true;
	for(int i = 0; i < grafo.adjDir[u].size(); i++){
		int v = grafo.adjDir[u][i];
		if (!grafo.vis[v]){
			dfsSCC(v, grafo);
		}
	}
	grafo.sccs.back().push_back(u);
}

bool dfs(int a, int b, Grafo & grafo, bool f){
	grafo.vis[a] = true;
	if (grafo.sccCost[a]) f = true;
	if (a == b){
		// cout << "Chegou\n" << f << endl;
		return f;
	}
	// cout << "A = " << a << " " << grafo.adj[a].size() << endl;
	for (int i = 0; i < grafo.adj[a].size(); i++){
		int v = grafo.adj[a][i];
		// cout << v << endl;
		if (!grafo.vis[v]){
			if(dfs(v, b, grafo, f || grafo.cost[a][i])){
				return true;
			}
		}
	}
	return false;
}

signed main(){
    // ios::sync_with_stdio(false);
    // cin.tie(0);
    // cout.tie(0);
	int n, m, t = 1;
	cin >> n >> m;
	Grafo grafo = Grafo(n);
	for (int i = 0; i < m; i++){
		int x, y, w;
		cin >> x >> y >> w;
		x--; y--;

		grafo.adj[x].push_back(y);
		grafo.adj[y].push_back(x);

		grafo.cost[x].push_back(w);
		grafo.cost[y].push_back(w);
	}
	int a, b;
	cin >> a >> b;
	a--; b--;

	vector<int> ordem_vis;

	for (int i = 0; i < n; i++){
		if (!grafo.vis[i]){
			dfsBridges(i, grafo, ordem_vis);
		}
	}

	grafo.vis.assign(n, false);

	vector<int> new_id(n);

	for (int i = n - 1; i >= 0; i--){
		if (!grafo.vis[i]){
			grafo.sccs.push_back(vector<int> ());
			grafo.sccCost.push_back(0);
			dfsSCC(i, grafo);
			sort(grafo.sccs.back().begin(), grafo.sccs.back().end());
			for (int u : grafo.sccs.back()){
				new_id[u] = grafo.sccs.size() - 1;
				// cout << u << " " << new_id[u] << endl;
				for (int i = 0; i < grafo.adj[u].size(); i++){
					if (binary_search(grafo.sccs.back().begin(), grafo.sccs.back().end(), grafo.adj[u][i])){
						grafo.sccCost.back() += grafo.cost[u][i];
					}
				}
			}
			// cout << endl;
		}
	}

	for (int i = 0; i < n; i++){
		grafo.adj[i].clear();
		grafo.cost[i].clear();
	}
	grafo.adj.resize(grafo.sccs.size());
	grafo.cost.resize(grafo.sccs.size());
	grafo.vis.assign(grafo.sccs.size(), false);

	for (pair<pair<int, int>, int> p : grafo.bridges){
		int u, v;
		tie(u, v) = p.first;
		int cost_edge = p.second;
		// cout << "old: " << u << " " << v << " ";
		u = new_id[u]; v = new_id[v];
        // cout << "new: " << u << " " << v << endl;
		if (u != v){
			// cout << u << "-" << v << endl;
		    // cout << cost_edge << endl;
			grafo.adj[u].push_back(v);
			grafo.adj[v].push_back(u);
			grafo.cost[u].push_back(cost_edge);
			grafo.cost[v].push_back(cost_edge);
		}
	}

	a = new_id[a]; b = new_id[b];

	if (dfs(a, b, grafo, false)){
		cout << "YES\n";
	}
	else cout << "NO\n";

}


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

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MAX_N = 3e5 + 47;

int n, m, comp[MAX_N], start, finish, used[MAX_N], wow[MAX_N];

map<pair<int, int>, int> used_edge;

struct edge
{
    int to, ok;
    edge(){};
    edge(int _to, int _ok)
    {
        to = _to;
        ok = _ok;
    };
};

vector<edge> g[MAX_N], or_g[MAX_N], or_rg[MAX_N];

vector<int> topsort;

void dfs1(int u)
{
    used[u] = 1;
    for (auto [to, ok] : g[u])
    {
        int u1 = u, u2 = to;
        if (u1 > u2) swap(u1, u2);
        if (!used_edge[{u1, u2}])
        {
            or_g[u].push_back(edge(to, ok));
            or_rg[to].push_back(edge(u, ok));
        }
        used_edge[{u1, u2}] = 1;
        if (!used[to]) dfs1(to);
    }
    topsort.push_back(u);
}

void dfs2(int u, int color)
{
    comp[u] = color;
    used[u] = 1;
    for (auto [to, ok] : or_rg[u])
    {
        if (!used[to]) dfs2(to, color);
        if (ok && comp[u] == comp[to]) wow[color] = 1;
    }
}

void rebuild()
{
    vector<edge> new_g[MAX_N];
    for (int i = 1; i <= n; i++)
    {
        for (auto [to, ok] : g[i])
        {
            if (comp[i] != comp[to])
            {
                new_g[comp[i]].push_back(edge(comp[to], ok));
            }
        }
    }
    swap(g, new_g);
}

void dfs3(int u, int gg)
{
    if (u == comp[finish] && gg)
    {
        cout << "YES";
        exit(0);
    }
    used[u] = 1;
    for (auto [to, ok] : g[u]) if (!used[to]) dfs3(to, ok | gg | wow[u]);
}

signed main()
{
    anime_sila_sport_mogila();
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        int a, b, ok;
        cin >> a >> b >> ok;
        g[a].push_back(edge(b, ok));
        g[b].push_back(edge(a, ok));
    }
    cin >> start >> finish;
    fill(used, used + MAX_N, 0);
    dfs1(start);
    reverse(topsort.begin(), topsort.end());
    fill(used, used + MAX_N, 0);
    int now_comp = 1;
    for (auto u : topsort) if (!used[u]) dfs2(u, now_comp++);
    rebuild();
    if (wow[comp[start]] || wow[comp[finish]]) cout << "YES\n";
    else
    {
        fill(used, used + MAX_N, 0);
        dfs3(comp[start], 0);
        cout << "NO";
    }
    return 0;
}


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

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MAX_N = 3e5 + 47;

int n, m, comp[MAX_N], start, finish, used[MAX_N], wow[MAX_N];

struct edge
{
    int to, ok;
    edge(){};
    edge(int _to, int _ok)
    {
        to = _to;
        ok = _ok;
    };
};

vector<edge> g[MAX_N], or_g[MAX_N], or_rg[MAX_N];

vector<int> topsort;

void dfs1(int u)
{
    used[u] = 1;
    for (auto [to, ok] : g[u]) if (!used[to])
    {
        or_g[u].push_back(edge(to, ok));
        or_rg[to].push_back(edge(u, ok));
        dfs1(to);
    }
    topsort.push_back(u);
}

void dfs2(int u, int color)
{
    comp[u] = color;
    used[u] = 1;
    for (auto [to, ok] : or_rg[u]) if (!used[to])
    {
        if (ok) wow[color] = 1;
        dfs2(to, color);
    }
}

void rebuild()
{
    vector<edge> new_g[MAX_N];
    for (int i = 1; i <= n; i++)
    {
        for (auto [to, ok] : g[i])
        {
            if (comp[i] != comp[to])
            {
                new_g[comp[i]].push_back(edge(comp[to], ok));
            }
        }
    }
    swap(g, new_g);
}

void dfs3(int u, int gg)
{
    if (u == comp[finish] && gg)
    {
        cout << "YES";
        exit(0);
    }
    used[u] = 1;
    for (auto [to, ok] : g[u]) if (!used[to]) dfs3(to, ok | gg);
}

signed main()
{
    anime_sila_sport_mogila();
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        int a, b, ok;
        cin >> a >> b >> ok;
        g[a].push_back(edge(b, ok));
        g[b].push_back(edge(a, ok));
    }
    cin >> start >> finish;
    fill(used, used + MAX_N, 0);
    dfs1(start);
    //reverse(topsort.begin(), topsort.end());
    fill(used, used + MAX_N, 0);
    int now_comp = 1;
    for (auto u : topsort) if (!used[u]) dfs2(u, now_comp++);
    rebuild();
    if (wow[comp[start]] || wow[comp[finish]]) cout << "YES\n";
    else
    {
        fill(used, used + MAX_N, 0);
        dfs3(comp[start], 0);
        cout << "NO";
    }
    return 0;
}


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

void anime_sila_sport_mogila()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef _47
        freopen("in.cpp", "r", stdin), freopen("out.cpp", "w", stdout);
    #endif
}

const int MAX_N = 3e5 + 47;

int n, m, comp[MAX_N], start, finish, used[MAX_N], wow[MAX_N];

map<pair<int, int>, int> used_edge;

struct edge
{
    int to, ok;
    edge(){};
    edge(int _to, int _ok)
    {
        to = _to;
        ok = _ok;
    };
};

vector<edge> g[MAX_N], or_g[MAX_N], or_rg[MAX_N];

vector<int> topsort;

void dfs1(int u)
{
    used[u] = 1;
    for (auto [to, ok] : g[u])
    {
        int u1 = u, u2 = to;
        if (u1 > u2) swap(u1, u2);
        if (!used_edge[{u1, u2}])
        {
            or_g[u].push_back(edge(to, ok));
            or_rg[to].push_back(edge(u, ok));
        }
        used_edge[{u1, u2}] = 1;
        if (!used[to]) dfs1(to);
    }
    topsort.push_back(u);
}

void dfs2(int u, int color)
{
    comp[u] = color;
    used[u] = 1;
    for (auto [to, ok] : or_rg[u]) if (!used[to])
    {
        if (ok) wow[color] = 1;
        dfs2(to, color);
    }
}

void rebuild()
{
    vector<edge> new_g[MAX_N];
    for (int i = 1; i <= n; i++)
    {
        for (auto [to, ok] : g[i])
        {
            if (comp[i] != comp[to])
            {
                new_g[comp[i]].push_back(edge(comp[to], ok));
            }
        }
    }
    swap(g, new_g);
}

void dfs3(int u, int gg)
{
    if (u == comp[finish] && gg)
    {
        cout << "YES";
        exit(0);
    }
    used[u] = 1;
    for (auto [to, ok] : g[u]) if (!used[to]) dfs3(to, ok | gg);
}

signed main()
{
    anime_sila_sport_mogila();
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        int a, b, ok;
        cin >> a >> b >> ok;
        g[a].push_back(edge(b, ok));
        g[b].push_back(edge(a, ok));
    }
    cin >> start >> finish;
    fill(used, used + MAX_N, 0);
    dfs1(start);
    reverse(topsort.begin(), topsort.end());
    fill(used, used + MAX_N, 0);;
    int now_comp = 1;
    for (auto u : topsort) if (!used[u]) dfs2(u, now_comp++);
    rebuild();
    if (wow[comp[start]] || wow[comp[finish]]) cout << "YES\n";
    else
    {
        fill(used, used + MAX_N, 0);
        dfs3(comp[start], 0);
        cout << "NO";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 666666666

int n,m,tt=0;
int artifacts[300005];
int disc[300005];
int low[300005];
int P[300005];
int visited[300005];
vector<array<int,2>>G[300005];
vector<array<int,2>>g[300005]; //bridge tree
vector<array<int,3>>bridges;

int Find(int c)
{
    return P[c]<0 ? c : P[c]=Find(P[c]);
}

int Union(int u, int v)
{
    u = Find(u);
    v = Find(v);
    if(u==v)return u;
    artifacts[u]+=artifacts[v];
    P[v]=u;
    return u;
}

void dfs(int c, int p = -1)
{
    disc[c]=low[c]=++tt;

    for(auto&u:G[c])
        if(disc[u[0]]==0)
    {
        dfs(u[0],c);
        low[c]=min(low[c],low[u[0]]);
        if(low[u[0]] > disc[c])bridges.push_back({c,u[0],u[1]});
        else artifacts[Union(c,u[0])]+=u[1];
    }else if(u[0]!=p)low[c]=min(low[c],disc[u[0]]);
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int u,v,a;
        cin>>u>>v>>a;
        G[u].push_back({v,a});
        G[v].push_back({u,a});
    }
    for(int i=1; i<=n; i++)
        P[i]=-1;

    dfs(1);

    for(auto&e : bridges)
    {
        int u = e[0];
        int v = e[1];
        int a = e[2];
        u=Find(u);
        v=Find(v);
        if(u==v)continue;
        g[u].push_back({v,a});
        g[v].push_back({u,a});
    }

    int st,en;
    cin>>st>>en;
    st=Find(st);
    en=Find(en);
    queue<int>q;
    q.push(st);
    visited[st]=1;

    while(!q.empty())
    {
        int c = q.front();
        q.pop();

        for(auto&e:g[c])
        {
            int u = e[0];
            int a = e[1];
            if(!visited[u])
            {
                visited[u]=1;
                artifacts[u]=artifacts[c]+a;
                q.push(u);
            }
        }
    }

    cout<<(artifacts[en] > 0 ? "YES" : "NO");
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 666666666

int n,m,tt=0;
int artifacts[300005];
int disc[300005];
int low[300005];
int P[300005];
int visited[300005];
vector<array<int,2>>G[300005];
vector<array<int,2>>g[300005]; //bridge tree
vector<array<int,3>>bridges;

int Find(int c)
{
    return P[c]<0 ? c : P[c]=Find(P[c]);
}

int Union(int u, int v)
{
    u = Find(u);
    v = Find(v);
    artifacts[u]+=artifacts[v];
    if(u==v)return u;
    P[v]=u;
    return u;
}

void dfs(int c, int p = -1)
{
    disc[c]=low[c]=++tt;

    for(auto&u:G[c])
        if(disc[u[0]]==0)
    {
        dfs(u[0],c);
        low[c]=min(low[c],low[u[0]]);
        if(low[u[0]] > disc[c])bridges.push_back({c,u[0],u[1]});
        else artifacts[Union(c,u[0])]+=u[1];
    }else if(u[0]!=p)low[c]=min(low[c],disc[u[0]]);
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int u,v,a;
        cin>>u>>v>>a;
        G[u].push_back({v,a});
        G[v].push_back({u,a});
    }
    for(int i=1; i<=n; i++)
        P[i]=-1;

    dfs(1);

    for(int i=1; i<=n; i++)
        for(auto&e:G[i])
        if(Find(i)==Find(e[0]))
        artifacts[Find(i)]+=e[1];

    for(auto&e : bridges)
    {
        int u = e[0];
        int v = e[1];
        int a = e[2];
        u=Find(u);
        v=Find(v);
        if(u==v)continue;
        g[u].push_back({v,a});
        g[v].push_back({u,a});
    }

    int st,en;
    cin>>st>>en;
    st=Find(st);
    en=Find(en);
    queue<int>q;
    q.push(st);
    visited[st]=1;

    while(!q.empty())
    {
        int c = q.front();
        q.pop();

        for(auto&e:g[c])
        {
            int u = e[0];
            int a = e[1];
            if(!visited[u])
            {
                visited[u]=1;
                artifacts[u]+=artifacts[c]+a;
                q.push(u);
            }
        }
    }

    cout<<(artifacts[en] > 0 ? "YES" : "NO");
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo 666666666

int n,m,tt=0;
int artifacts[300005];
int disc[300005];
int low[300005];
int P[300005];
int visited[300005];
vector<array<int,2>>G[300005];
vector<array<int,2>>g[300005]; //bridge tree
vector<array<int,3>>bridges;

int Find(int c)
{
    return P[c]<0 ? c : P[c]=Find(P[c]);
}

int Union(int u, int v)
{
    u = Find(u);
    v = Find(v);
    artifacts[u]+=artifacts[v];
    if(u==v)return u;
    P[v]=u;
    return u;
}

void dfs(int c, int p = -1)
{
    disc[c]=low[c]=++tt;

    for(auto&u:G[c])
        if(disc[u[0]]==0)
    {
        dfs(u[0],c);
        low[c]=min(low[c],low[u[0]]);
        if(low[u[0]] > disc[c])bridges.push_back({c,u[0],u[1]});
        else artifacts[Union(c,u[0])]+=u[1];
    }else if(u[0]!=p)low[c]=min(low[c],disc[u[0]]);
}

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        int u,v,a;
        cin>>u>>v>>a;
        G[u].push_back({v,a});
        G[v].push_back({u,a});
    }
    for(int i=1; i<=n; i++)
        P[i]=-1;

    dfs(1);

    for(int i=1; i<=n; i++)
        for(auto&e:G[i])
        if(Find(i)==Find(e[0]))
        artifacts[Find(i)]+=e[1];

    for(auto&e : bridges)
    {
        int u = e[0];
        int v = e[1];
        int a = e[2];
        u=Find(u);
        v=Find(v);
        if(u==v)continue;
        g[u].push_back({v,a});
        g[v].push_back({u,a});
    }

    int st,en;
    cin>>st>>en;
    st=Find(st);
    en=Find(en);
    queue<int>q;
    q.push(st);
    visited[st]=1;

    while(!q.empty())
    {
        int c = q.front();
        q.pop();

        for(auto&e:g[c])
        {
            int u = e[0];
            int a = e[1];
            if(!visited[u])
            {
                visited[u]=1;
                artifacts[u]=artifacts[c]+a;
                q.push(u);
            }
        }
    }

    cout<<(artifacts[en] > 0 ? "YES" : "NO");
}


// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 3*(int)1e5 + 3;

int n, m, t = 1, id, pre[N], low[N], nr[N], good[N];
VII child[N], drz[N];
vector<pair<PII, int>> todo;
bool ok[N], vis[N];
VII cur;

void dfs1(int v, int p, int kr) {
  vis[v] = true;
  pre[v] = low[v] = t++;
  cur.PB({v, kr});
  for (auto x: child[v]) {
    if (x.ST == p)
      continue;
    if (vis[x.ST])
      low[v] = min(low[v], pre[x.ST]);
    else {
      dfs1(x.ST, v, x.ND);
      low[v] = min(low[v], low[x.ST]);
    }
  }
  int is = 0;
  VI wie;
  if (pre[v] == low[v]) {
    ++id;
    while (cur.back().ST != v) {
      nr[cur.back().ST] = id;
      wie.PB(cur.back().ST);
      cur.pop_back();
    }
    wie.PB(v);
    for (int w: wie)
      ok[w] = true;
    for (int w: wie)
      for (auto x: child[w])
        if (ok[x.ST])
          is |= x.ND;
    for (int w: wie)
      ok[w] = false;
    nr[v] = id;
    cur.pop_back();
    good[id] = is;
    if (p)
      todo.PB({{p, v}, kr});
  }
}

bool wyn;

void dfs2(int v, int tar, int was) {
  was |= good[v];
  if (v == tar) {
    wyn = (was == 1);
    return;
  }
  vis[v] = true;
  for (auto p: drz[v])
    if (!vis[p.ST])
      dfs2(p.ST, tar, was|p.ND);
}

int main() {
  init_ios();
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    child[x].PB({y, z});
    child[y].PB({x, z});
  }
  dfs1(1, 0, 0);
  for (auto el: todo) {
    drz[nr[el.ST.ST]].PB({nr[el.ST.ND], el.ND});
    drz[nr[el.ST.ND]].PB({nr[el.ST.ST], el.ND});
  }
  for (int i = 1; i <= n; ++i)
    vis[i] = false;
  int a, b;
  cin >> a >> b;
  a = nr[a];
  b = nr[b];
  dfs2(a, b, 0);
  if (wyn)
    cout<<"YES\n";
  else
    cout<<"NO\n";
}


// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 3*(int)1e5 + 3;

int n, m, t = 1, id, pre[N], low[N], nr[N], good[N];
VII child[N], drz[N];
vector<pair<PII, int>> todo;
bool vis[N];
VII cur;

void dfs1(int v, int p, int kr) {
  vis[v] = true;
  pre[v] = low[v] = t++;
  cur.PB({v, kr});
  for (auto x: child[v]) {
    if (x.ST == p)
      continue;
    if (vis[x.ST])
      low[v] = min(low[v], pre[x.ST]);
    else {
      dfs1(x.ST, v, x.ND);
      low[v] = min(low[v], low[x.ST]);
    }
  }
  int is = 0;
  set<int> qwe;
  if (pre[v] == low[v]) {
    ++id;
    while (cur.back().ST != v) {
      nr[cur.back().ST] = id;
      qwe.insert(cur.back().ST);
      for (auto x: child[cur.back().ST])
        is |= x.ND;
      cur.pop_back();
    }
    nr[v] = id;
    for (auto x: child[v])
      if (qwe.find(x.ST) != qwe.end())
        is |= x.ND;
    cur.pop_back();
    good[id] = is;
    if (p)
      todo.PB({{p, v}, kr});
  }
}

bool wyn;

void dfs2(int v, int tar, int was) {
  was |= good[v];
  if (v == tar) {
    wyn = (was == 1);
    return;
  }
  vis[v] = true;
  for (auto p: drz[v])
    if (!vis[p.ST])
      dfs2(p.ST, tar, was|p.ND);
}

int main() {
  init_ios();
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    child[x].PB({y, z});
    child[y].PB({x, z});
  }
  dfs1(1, 0, 0);
  for (auto el: todo) {
    drz[nr[el.ST.ST]].PB({nr[el.ST.ND], el.ND});
    drz[nr[el.ST.ND]].PB({nr[el.ST.ST], el.ND});
  }
  for (int i = 1; i <= id; ++i)
    vis[i] = false;
  int a, b;
  cin >> a >> b;
  a = nr[a];
  b = nr[b];
  dfs2(a, b, 0);
  if (wyn)
    cout<<"YES\n";
  else
    cout<<"NO\n";
}


// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 3*(int)1e5 + 3;

int n, m, t = 1, id, pre[N], low[N], nr[N], good[N];
VII child[N], drz[N];
vector<pair<PII, int>> todo;
bool vis[N];
VII cur;

void dfs1(int v, int p, int kr) {
  vis[v] = true;
  pre[v] = low[v] = t++;
  cur.PB({v, kr});
  for (auto x: child[v]) {
    if (x.ST == p)
      continue;
    if (vis[x.ST])
      low[v] = min(low[v], pre[x.ST]);
    else {
      dfs1(x.ST, v, x.ND);
      low[v] = min(low[v], low[x.ST]);
    }
  }
  int is = 0;
  if (pre[v] == low[v]) {
    ++id;
    while (cur.back().ST != v) {
      nr[cur.back().ST] = id;
      is |= cur.back().ND;
      cur.pop_back();
    }
    nr[v] = id;
    cur.pop_back();
    good[id] = is;
    if (p)
      todo.PB({{p, v}, kr});
  }
}

bool wyn;

void dfs2(int v, int tar, int was) {
  if (v == tar) {
    wyn = (was == 1);
    return;
  }
  vis[v] = true;
  for (auto p: drz[v])
    if (!vis[p.ST])
      dfs2(p.ST, tar, was|p.ND);
}

int main() {
  init_ios();
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    child[x].PB({y, z});
    child[y].PB({x, z});
  }
  dfs1(1, 0, 0);
  for (auto el: todo) {
    drz[nr[el.ST.ST]].PB({nr[el.ST.ND], el.ND});
    drz[nr[el.ST.ND]].PB({nr[el.ST.ST], el.ND});
  }
  for (int i = 1; i <= id; ++i)
    vis[i] = false;
  int a, b;
  cin >> a >> b;
  a = nr[a];
  b = nr[b];
  dfs2(a, b, good[a]);
  if (wyn)
    cout<<"YES\n";
  else
    cout<<"NO\n";
}


// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 3*(int)1e5 + 3;

int n, m, t = 1, id, pre[N], low[N], nr[N], good[N];
VII child[N], drz[N];
vector<pair<PII, int>> todo;
bool vis[N];
VII cur;

void dfs1(int v, int p, int kr) {
  vis[v] = true;
  pre[v] = low[v] = t++;
  cur.PB({v, kr});
  for (auto x: child[v]) {
    if (x.ST == p)
      continue;
    if (vis[x.ST])
      low[v] = min(low[v], pre[x.ST]);
    else {
      dfs1(x.ST, v, x.ND);
      low[v] = min(low[v], low[x.ST]);
    }
  }
  int is = 0;
  set<int> qwe;
  if (pre[v] == low[v]) {
    ++id;
    while (cur.back().ST != v) {
      nr[cur.back().ST] = id;
      qwe.insert(cur.back().ST);
      for (auto x: child[cur.back().ST])
        is |= x.ND;
      cur.pop_back();
    }
    nr[v] = id;
    for (auto x: child[v])
      if (qwe.find(x.ST) != qwe.end())
        is |= x.ND;
    cur.pop_back();
    good[id] = is;
    if (p)
      todo.PB({{p, v}, kr});
  }
}

bool wyn;

void dfs2(int v, int tar, int was) {
  if (v == tar) {
    wyn = (was == 1);
    return;
  }
  vis[v] = true;
  for (auto p: drz[v])
    if (!vis[p.ST])
      dfs2(p.ST, tar, was|p.ND);
}

int main() {
  init_ios();
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    child[x].PB({y, z});
    child[y].PB({x, z});
  }
  dfs1(1, 0, 0);
  for (auto el: todo) {
    drz[nr[el.ST.ST]].PB({nr[el.ST.ND], el.ND});
    drz[nr[el.ST.ND]].PB({nr[el.ST.ST], el.ND});
  }
  for (int i = 1; i <= id; ++i)
    vis[i] = false;
  int a, b;
  cin >> a >> b;
  a = nr[a];
  b = nr[b];
  dfs2(a, b, good[a]);
  if (wyn)
    cout<<"YES\n";
  else
    cout<<"NO\n";
}


// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 3*(int)1e5 + 3;

int n, m, t = 1, id, pre[N], low[N], nr[N], good[N];
VII child[N], drz[N];
vector<pair<PII, int>> todo;
bool vis[N];
VII cur;

void dfs1(int v, int p, int kr) {
  vis[v] = true;
  pre[v] = low[v] = t++;
  cur.PB({v, kr});
  for (auto x: child[v]) {
    if (x.ST == p)
      continue;
    if (vis[x.ST])
      low[v] = min(low[v], pre[x.ST]);
    else {
      dfs1(x.ST, v, x.ND);
      low[v] = min(low[v], low[x.ST]);
    }
  }
  int is = 0;
  if (pre[v] == low[v]) {
    ++id;
    while (cur.back().ST != v) {
      nr[cur.back().ST] = id;
      is |= cur.back().ND;
      cur.pop_back();
    }
    nr[v] = id;
    cur.pop_back();
    good[id] = is;
    todo.PB({{p, v}, kr});
  }
}

bool wyn;

void dfs2(int v, int tar, int was) {
  if (v == tar) {
    wyn = (was == 1);
    return;
  }
  vis[v] = true;
  for (auto p: drz[v])
    if (!vis[p.ST])
      dfs2(p.ST, tar, was|p.ND);
}

int main() {
  init_ios();
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    child[x].PB({y, z});
    child[y].PB({x, z});
  }
  dfs1(1, 0, 0);
  for (auto el: todo) {
    drz[nr[el.ST.ST]].PB({nr[el.ST.ND], el.ND});
    drz[nr[el.ST.ND]].PB({nr[el.ST.ND], el.ND});
  }
  for (int i = 1; i <= id; ++i)
    vis[i] = false;
  int a, b;
  cin >> a >> b;
  a = nr[a];
  b = nr[b];
  dfs2(a, b, good[a]);
  if (wyn)
    cout<<"YES\n";
  else
    cout<<"NO\n";
}


// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = 3*(int)1e5 + 3;

int n, m, t = 1, id, pre[N], low[N], nr[N], good[N];
VII child[N], drz[N];
vector<pair<PII, int>> todo;
bool vis[N];
VII cur;

void dfs1(int v, int p, int kr) {
  vis[v] = true;
  pre[v] = low[v] = t++;
  cur.PB({v, kr});
  for (auto x: child[v]) {
    if (x.ST == p)
      continue;
    if (vis[x.ST])
      low[v] = min(low[v], pre[x.ST]);
    else {
      dfs1(x.ST, v, x.ND);
      low[v] = min(low[v], low[x.ST]);
    }
  }
  int is = 0;
  if (pre[v] == low[v]) {
    ++id;
    while (cur.back().ST != v) {
      nr[cur.back().ST] = id;
      for (auto x: child[cur.back().ST])
        is |= x.ND;
      cur.pop_back();
    }
    nr[v] = id;
    for (auto x: child[v])
      if (x.ST != p)
        is |= x.ND;
    cur.pop_back();
    good[id] = is;
    if (p)
      todo.PB({{p, v}, kr});
  }
}

bool wyn;

void dfs2(int v, int tar, int was) {
  if (v == tar) {
    wyn = (was == 1);
    return;
  }
  vis[v] = true;
  for (auto p: drz[v])
    if (!vis[p.ST])
      dfs2(p.ST, tar, was|p.ND);
}

int main() {
  init_ios();
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    child[x].PB({y, z});
    child[y].PB({x, z});
  }
  dfs1(1, 0, 0);
  for (auto el: todo) {
    drz[nr[el.ST.ST]].PB({nr[el.ST.ND], el.ND});
    drz[nr[el.ST.ND]].PB({nr[el.ST.ST], el.ND});
  }
  for (int i = 1; i <= id; ++i)
    vis[i] = false;
  int a, b;
  cin >> a >> b;
  a = nr[a];
  b = nr[b];
  dfs2(a, b, good[a]);
  if (wyn)
    cout<<"YES\n";
  else
    cout<<"NO\n";
}


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

mt19937_64 llrand(random_device{}());

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#define gcd(x, y) __gcd((x), (y))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;

set <pii> adjd[N], adj[N], adjt[N], adjs[N];
int ok[N], ord[N], ordn, scc[N], sccn, sz[N], vis[N], yes;
int n, m, a, b, k, visCnt;

void direct (int u, int par) {
    vis[u] = ++visCnt;
    for (auto p : adjd[u]) {
        int v = p.st;
        int w = p.nd;
        if (v != par and !adjt[u].count({v, w})) {
            adj[u].insert({v, w});
            adjt[v].insert({u, w});
            if (!vis[v]) direct(v, u);
        }
    }
}

void dfs (int u) {
    vis[u] = 1;
    for (auto p : adj[u]) {
        int v = p.st;
        int w = p.nd;
        if (!vis[v]) dfs(v);
    }
    ord[ordn++] = u;
}

void dfst (int u) {
    vis[u] = 0;
    scc[u] = sccn;
    sz[sccn]++;
    for (auto p : adjt[u]) {
        int v = p.st;
        int w = p.nd;
        if (vis[v]) dfst(v);
    }
}

void dfss (int u, int ans, int dest) {
    ans |= ok[u];
    vis[u] = 1;

    if (u == dest and ans) yes = 1;
    for (auto p : adjs[u]) {
        int v = p.st;
        int w = p.nd;
        if (!vis[v]) dfss(v, ans|w, dest);
    }
}

int main () {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
        scanf("%d%d%d", &a, &b, &k);
        adjd[a].insert({b, k});
        adjd[b].insert({a, k});
    }

    direct(1, 1);

    cl(vis, 0);
    sccn = ordn = 1;
    dfs(1);
    for (int i = ordn; i >= 1; i--) if (vis[ord[i]]) dfst(ord[i]), sccn++; sccn--;

    for (int i = 1; i <= n; i++) {
        for (auto p : adj[i]) {
            int v = p.st;
            int w = p.nd;
            if (scc[i] != scc[v]) {
                adjs[scc[i]].insert({scc[v], w});
            } else {
                ok[scc[i]] |= w;
            }
        }
    }

    scanf("%d%d", &a, &b);
    cl(vis, 0); dfss(scc[a], ok[scc[a]], scc[b]);
    cl(vis, 0); dfss(scc[b], ok[scc[b]], scc[a]);

    printf("%s\n", yes ? "YES" : "NO");

    return 0;
}


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

mt19937_64 llrand(random_device{}());

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#define gcd(x, y) __gcd((x), (y))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 1e5+5;

set <pii> adjd[N], adj[N], adjt[N], adjs[N];
int ok[N], ord[N], ordn, scc[N], sccn, sz[N], vis[N], yes;
int n, m, a, b, k, visCnt;

void direct (int u, int par) {
    vis[u] = ++visCnt;
    for (auto p : adjd[u]) {
        int v = p.st;
        int w = p.nd;
        if (v != par and !adjt[u].count({v, w})) {
            adj[u].insert({v, w});
            adjt[v].insert({u, w});
            if (!vis[v]) direct(v, u);
        }
    }
}

void dfs (int u) {
    vis[u] = 1;
    for (auto p : adj[u]) {
        int v = p.st;
        int w = p.nd;
        if (!vis[v]) dfs(v);
    }
    ord[ordn++] = u;
}

void dfst (int u) {
    vis[u] = 0;
    scc[u] = sccn;
    sz[sccn]++;
    for (auto p : adjt[u]) {
        int v = p.st;
        int w = p.nd;
        if (vis[v]) dfst(v);
    }
}

void dfss (int u, int ans) {
    ans |= ok[u];
    vis[u] = 1;

    if (u == scc[b] and ans) yes = 1;
    for (auto p : adjs[u]) {
        int v = p.st;
        int w = p.nd;
        if (!vis[v]) dfss(v, ans|w);
    }
}

int main () {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
        scanf("%d%d%d", &a, &b, &k);
        adjd[a].insert({b, k});
        adjd[b].insert({a, k});
    }

    direct(1, 1);

    cl(vis, 0);
    sccn = ordn = 1;
    dfs(1);
    for (int i = ordn; i >= 1; i--) if (vis[ord[i]]) dfst(ord[i]), sccn++; sccn--;

    for (int i = 1; i <= n; i++) {
        for (auto p : adj[i]) {
            int v = p.st;
            int w = p.nd;
            if (scc[i] != scc[v]) {
                adjs[scc[i]].insert({scc[v], w});
            } else {
                ok[scc[i]] |= w;
            }
        }
    }

    scanf("%d%d", &a, &b);
    dfss(scc[a], ok[scc[a]]);

    printf("%s\n", yes ? "YES" : "NO");

    return 0;
}


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

mt19937_64 llrand(random_device{}());

#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define cl(x, v) memset((x), (v), sizeof(x))
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define _ << ", " <<
#define gcd(x, y) __gcd((x), (y))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;

const ld EPS = 1e-9, PI = acos(-1.);
const ll LINF = 0x3f3f3f3f3f3f3f3f, LMOD = 1011112131415161719ll;
const int INF = 0x3f3f3f3f, MOD = 1e9+7;
const int N = 3e5+5;

set <pii> adjd[N], adj[N], adjt[N], adjs[N];
int ok[N], ord[N], ordn, scc[N], sccn, sz[N], vis[N], yes;
int n, m, a, b, k, visCnt;

void direct (int u, int par) {
    vis[u] = ++visCnt;
    for (auto p : adjd[u]) {
        int v = p.st;
        int w = p.nd;
        if (v != par and !adjt[u].count({v, w})) {
            adj[u].insert({v, w});
            adjt[v].insert({u, w});
            if (!vis[v]) direct(v, u);
        }
    }
}

void dfs (int u) {
    vis[u] = 1;
    for (auto p : adj[u]) {
        int v = p.st;
        int w = p.nd;
        if (!vis[v]) dfs(v);
    }
    ord[ordn++] = u;
}

void dfst (int u) {
    vis[u] = 0;
    scc[u] = sccn;
    sz[sccn]++;
    for (auto p : adjt[u]) {
        int v = p.st;
        int w = p.nd;
        if (vis[v]) dfst(v);
    }
}

void dfss (int u, int ans, int dest) {
    ans |= ok[u];
    vis[u] = 1;

    if (u == dest and ans) yes = 1;
    for (auto p : adjs[u]) {
        int v = p.st;
        int w = p.nd;
        if (!vis[v]) dfss(v, ans|w, dest);
    }
}

int main () {
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= m; i++) {
        scanf("%d%d%d", &a, &b, &k);
        adjd[a].insert({b, k});
        adjd[b].insert({a, k});
    }

    direct(1, 1);

    cl(vis, 0);
    sccn = ordn = 1;
    dfs(1);
    for (int i = ordn; i >= 1; i--) if (vis[ord[i]]) dfst(ord[i]), sccn++; sccn--;

    for (int i = 1; i <= n; i++) {
        for (auto p : adj[i]) {
            int v = p.st;
            int w = p.nd;
            if (scc[i] != scc[v]) {
                adjs[scc[i]].insert({scc[v], w});
                adjs[scc[v]].insert({scc[i], w});
            } else {
                ok[scc[i]] |= w;
            }
        }
    }

    scanf("%d%d", &a, &b);
    dfss(scc[a], ok[scc[a]], scc[b]);

    printf("%s\n", yes ? "YES" : "NO");

    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>

// defines
#define KhaledAshraf ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define modulo 1000000007
#define pi 3.1415926535897932384

typedef long long int lln;

//to be able to use to_string  patch::to_string("char or string")

namespace patch
{
    template < typename T > std::string to_string( const T& n )
    {
        std::ostringstream stm ;
        stm << n ;
        return stm.str() ;
    }
}

using namespace std;

int main(){
    string S,tmp="";
    cin>>S;
    vector<string>V;
    bool flag=false;
    for(int i=0;i<S.size();i++){
        tmp+=S[i];
        if(flag){V.push_back(tmp);tmp="";flag=false;}
        if(S[i]=='@'){flag=true;}
    }

    if(!flag && tmp.size()){
        V.back()+=tmp;
    }
    bool chk1,chk2,chk3;
    flag=true;
    for(int i=0;i<V.size();i++){
        chk1=chk2=chk3=false;
        for(int j=0;j<V[i].size();j++){
            if(V[i][j]!='@' && !chk2){
                chk1=true;
            }
            else if(V[i][j]=='@'){
                chk2=true;
            }
            else if(V[i][j]!='@' && chk2){
                chk3=true;
            }
        }
        flag=(flag&chk1&chk2&chk3);
    }
    if(!flag){
        cout<<"No solution";
    }
    else{
        for(int i=0;i<V.size();i++){
            if(i){cout<<',';}
            cout<<V[i];
        }
    }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>

// defines
#define KhaledAshraf ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define modulo 1000000007
#define pi 3.1415926535897932384

typedef long long int lln;

//to be able to use to_string  patch::to_string("char or string")

namespace patch
{
    template < typename T > std::string to_string( const T& n )
    {
        std::ostringstream stm ;
        stm << n ;
        return stm.str() ;
    }
}

using namespace std;

int main(){
    string S,tmp="";
    cin>>S;
    vector<string>V;
    bool flag=false;
    for(int i=0;i<S.size();i++){
        tmp+=S[i];
        if(flag){V.push_back(tmp);tmp="";flag=false;}
        if(S[i]=='@'){flag=true;}
    }

    if(!flag && tmp.size()){
        V.back()+=tmp;
    }
    bool chk1,chk2,chk3;
    flag=true;
    for(int i=0;i<V.size();i++){
        chk1=chk2=chk3=false;
        for(int j=0;j<V[i].size();j++){
            if(V[i][j]!='@' && !chk2){
                chk1=true;
            }
            else if(V[i][j]=='@'){
                chk2=true;
            }
            else if(V[i][j]!='@' && chk2){
                chk3=true;
            }
        }
        flag=(flag&chk1&chk2&chk3);
    }
    if(!flag || tmp.size()){
        cout<<"No solution";
    }
    else{
        for(int i=0;i<V.size();i++){
            if(i){cout<<',';}
            cout<<V[i];
        }
    }
    return 0;
}


//64
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int flag=0,flag2=0,i,m;
	int l=s.size();

	if( s[0]==64 || s[l-1]==64 ) flag=1;

	for(i=0;i<l;i++)
	{
		if(s[i]!=64 && (s[i]<97||s[i]>122))
		flag=1;break;
	}
	for(i=0;i<l;i++)
	{
		if(s[i]==64)
		{
			flag2=1;
			m=i;
		}
	}

	for(i=1;i<l-2;i++)
	{
		if(s[i]==64 && s[i+2]==64)
		{
			flag=1;break;
		}
		else if(s[i]==64 && s[i+1]==64)
		{
			flag=1;break;
		}
	}

	if(flag==1 || flag2==0 ) cout<<"No solution"<<endl;
	else
	{
		cout<<s[0];
		for(i=1;i<m;i++)
	{
		if(s[i-1]!=64) cout<<s[i];
		else if(s[i-1]==64) cout<<s[i]<<",";
	}
	for(i=m;i<l-1;i++)
	{
		cout<<s[i];
	}
	cout<<s[l-1]<<endl;

}
return 0;
}


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

string s;
int a[205], n=0, kt=1;

void input(){
	cin>>s;
}

void output(){

}

void solve(){
	a[0]=-2;
	if (s[s.length()-1]!='@') for (int i=0; i<s.length(); i++){
		if (s[i]=='@') {
			n++;
			a[n]=i;
			if (a[n]-a[n-1]<3) {
				kt=0;
				break;
			}
		}
	}
	if (kt==0 || n==0 ||s[s.length()-1]=='@') cout<<"No solution";
	if (kt!=0 && n>1){
		cout<<s.substr(0, a[1]+2);
		for (int i=2; i<n; i++){
			cout<<",";
			cout<<s.substr(a[i-1]+2, a[i]-a[i-1]);
		}
		cout<<",";
		cout<<s.substr(a[n-1]+2, s.length()-a[n-1]-2);
	}
	if (kt!=0 && n==1) cout<<s;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	input();
	solve();
	output();
}


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

string s;
int a[205], n=0, kt=1;

void input(){
	cin>>s;
}

void output(){

}

void solve(){
	a[0]=-2;
	for (int i=0; i<s.length(); i++){
		if (s[i]=='@') {
			n++;
			a[n]=i;
			if (a[n]-a[n-1]<3) {
				kt=0;
				break;
			}
		}
	}
	if (kt==0) cout<<"No solution";
	if (kt!=0 && n>1){
		cout<<s.substr(0, a[1]+2);
		for (int i=2; i<n; i++){
			cout<<",";
			cout<<s.substr(a[i-1]+2, a[i]-a[i-1]);
		}
		cout<<",";
		cout<<s.substr(a[n-1]+2, s.length()-a[n-1]-2);
	}
	if (kt!=0 && n==1) cout<<s;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	input();
	solve();
	output();
}


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

string s;
int a[205], n=0, kt=1;

void input(){
	cin>>s;
}

void output(){

}

void solve(){
	a[0]=-1;
	for (int i=0; i<s.length(); i++){
		if (s[i]=='@') {
			n++;
			a[n]=i;
			if (a[n]-a[n-1]<2) {
				kt=0;
				break;
			}
		}
	}
	cout<<endl;
	if (kt==0) cout<<"No solution";
	if (kt!=0){
		cout<<s.substr(0, a[1]+2);
		for (int i=2; i<n; i++){
			cout<<",";
			cout<<s.substr(a[i-1]+2, a[i]-a[i-1]);
		}
		cout<<",";
		cout<<s.substr(a[n-1]+2, s.length()-a[n-1]-2);
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	input();
	solve();
	output();
}


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

string s;
int a[205], n=0, kt=1;

void input(){
	cin>>s;
}

void output(){

}

void solve(){
	a[0]=-2;
	for (int i=0; i<s.length(); i++){
		if (s[i]=='@') {
			n++;
			a[n]=i;
			if (a[n]-a[n-1]<3) {
				kt=0;
				break;
			}
		}
	}
	if (kt==0 || n==0) cout<<"No solution";
	if (kt!=0 && n>1){
		cout<<s.substr(0, a[1]+2);
		for (int i=2; i<n; i++){
			cout<<",";
			cout<<s.substr(a[i-1]+2, a[i]-a[i-1]);
		}
		cout<<",";
		cout<<s.substr(a[n-1]+2, s.length()-a[n-1]-2);
	}
	if (kt!=0 && n==1) cout<<s;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	input();
	solve();
	output();
}


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

string s;
int a[205], n=0, kt=1;

void input(){
	cin>>s;
}

void output(){

}

void solve(){
	a[0]=-1;
	for (int i=0; i<s.length(); i++){
		if (s[i]=='@') {
			n++;
			a[n]=i;
			if (a[n]-a[n-1]<2) {
				kt=0;
				break;
			}
		}
	}
	if (kt==0) cout<<"No solution";
	if (kt!=0){
		cout<<s.substr(0, a[1]+2);
		for (int i=2; i<n; i++){
			cout<<",";
			cout<<s.substr(a[i-1]+2, a[i]-a[i-1]);
		}
		cout<<",";
		cout<<s.substr(a[n-1]+2, s.length()-a[n-1]-2);
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	input();
	solve();
	output();
}


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

string s;
int a[205], n=0, kt=1;

void input(){
	cin>>s;
}

void output(){

}

void solve(){
	a[0]=-2;
	for (int i=0; i<s.length(); i++){
		if (s[i]=='@') {
			n++;
			a[n]=i;
			if (a[n]-a[n-1]<3) {
				kt=0;
				break;
			}
		}
	}
	if (kt==0) cout<<"No solution";
	if (kt!=0){
		cout<<s.substr(0, a[1]+2);
		for (int i=2; i<n; i++){
			cout<<",";
			cout<<s.substr(a[i-1]+2, a[i]-a[i-1]);
		}
		cout<<",";
		cout<<s.substr(a[n-1]+2, s.length()-a[n-1]-2);
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	input();
	solve();
	output();
}


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

int main()
{
	string str;
	cin >> str;

	string ans;
	bool ok = 0, ok2 = 0;
	int st = -1;
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] == '@') ok = 1;
		if (str[i] != '@' && !ok2) ok2 = 1, st = i;

		if (ok && ok2 && str[i+1] != '@')
		{
			bool f = 0;
			for (int j = i + 2; j < str.size(); j++)
			{
				if (str[j] == '@') {
					ans += str.substr(st, j - 1), ans += ',', f = 1;
					ok = 0, ok2 = 0, st = -1;
					if (j - 1 <= i+1) {
						printf("%s", "No solution");
						return 0;
					}
					i = j-2;
					break;
				}
			}
			if (!f) {
				ans += str.substr(st, str.size()); i = str.size();  break;
			}
		}
		else if (str[i + 1] == '@') {
			printf("%s", "No solution");
			return 0;
		}
		if (ok && !ok2) {
			printf("%s", "No solution");
			return 0;
		}
	}
	if(ans.empty()) printf("%s", "No solution"); else
		cout <<  ans << endl;
}


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

int main()
{
	string str;
	cin >> str;

	string ans;
	bool ok = 0, ok2 = 0;
	int st = -1;
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] == '@') ok = 1;
		if (str[i] != '@' && !ok2) ok2 = 1, st = i;

		if (ok && ok2 && str[i+1] != '@')
		{
			bool f = 0;
			for (int j = i + 2; j < str.size(); j++)
			{
				if (str[j] == '@') {
					ans += str.substr(st, j - 1), ans += ',', f = 1;
					ok = 0, ok2 = 0, st = -1;
					if (j - 1 <= i+1) {
						printf("%s", "No solution");
						return 0;
					}
					i = j-2;
					break;
				}
			}
			if (!f) {
				ans += str.substr(st, str.size()); i = str.size();  break;
			}
		}
		else if (ok && ok2 && str[i + 1] == '@') {
			printf("%s", "No solution 1");
			return 0;
		}
		if (ok && !ok2) {
			printf("%s", "No solution");
			return 0;
		}
	}
	if(ans.empty()) printf("%s", "No solution"); else
		cout <<  ans << endl;
}


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

int main()
{
	string str;
	cin >> str;

	string ans;
	bool ok = 0, ok2 = 0;
	int st = -1;
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] == '@') ok = 1;
		if (str[i] != '@' && !ok2) ok2 = 1, st = i;

		if (ok && ok2 && str[i+1] != '@')
		{
			bool f = 0;
			for (int j = i + 2; j < str.size(); j++)
			{
				if (str[j] == '@') {
					ans += str.substr(st, j - 1 - st); ans += ','; f = 1;
					ok = 0, ok2 = 0, st = -1;
					if (j - 1 <= i+1) {
						printf("%s", "No solution");
						return 0;
					}
					i = j-2;
					break;
				}
			}
			if (!f) {
				ans += str.substr(st, str.size()); i = str.size();  break;
			}
		}
		else if (ok && ok2 && str[i + 1] == '@') {
			printf("%s", "No solution");
			return 0;
		}
		if (ok && !ok2) {
			printf("%s", "No solution");
			return 0;
		}
	}
	if(ans.empty()) printf("%s", "No solution"); else
		cout <<  ans << endl;
}


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

int main()
{
	string str;
	cin >> str;

	string ans;
	bool ok = 0, ok2 = 0;
	int st = -1;
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] == '@') ok = 1;
		if (str[i] != '@' && !ok2) ok2 = 1, st = i;

		if (ok && ok2 && str[i+1] != '@' && i+1 != str.size())
		{
			bool f = 0;
			for (int j = i + 2; j < str.size(); j++)
			{
				if (str[j] == '@') {
					ans += str.substr(st, j - 1 - st); ans += ','; f = 1;
					ok = 0, ok2 = 0, st = -1;
					if (j - 1 <= i+1) {
						printf("%s", "No solution");
						return 0;
					}
					i = j-2;
					break;
				}
			}
			if (!f) {
				ans += str.substr(st, str.size()); i = str.size();  break;
			}
		}
		else if (ok && ok2 && str[i + 1] == '@') {
			printf("%s", "No solution");
			return 0;
		}
		if (ok && !ok2) {
			printf("%s", "No solution");
			return 0;
		}
	}
	if(ans.empty()) printf("%s", "No solution"); else
		cout <<  ans << endl;
}


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

int main()
{
	string str;
	cin >> str;

	string ans;
	bool ok = 0, ok2 = 0;
	int st = -1;
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] == '@') ok = 1;
		if (str[i] != '@' && !ok2) ok2 = 1, st = i;

		if (ok && ok2 && str[i+1] != '@')
		{
			bool f = 0;
			for (int j = i + 2; j < str.size(); j++)
			{
				if (str[j] == '@') {
					ans += str.substr(st, j - 1 - st); ans += ','; f = 1;
					ok = 0, ok2 = 0, st = -1;
					if (j - 1 <= i+1) {
						printf("%s", "No solution");
						return 0;
					}
					i = j-2;
					break;
				}
			}
			if (!f) {
				ans += str.substr(st, str.size()); i = str.size();  break;
			}
		}
		else if (ok && ok2 && str[i + 1] == '@') {
			printf("%s", "No solution 1");
			return 0;
		}
		if (ok && !ok2) {
			printf("%s", "No solution");
			return 0;
		}
	}
	if(ans.empty()) printf("%s", "No solution"); else
		cout <<  ans << endl;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
	std::ios_base::sync_with_stdio(0);

	std::string str;
	std::cin >> str;

	std::vector<std::string> a;

	while (str.size())
	{
		if (isalpha(str[0]))
		{
			size_t pos = str.find('@');
			if (pos == std::string::npos)
			{
				if (a.size()) { a[a.size() - 1] += str; str = ""; }
				else
				{
					std::cout << "No solution";
					return 0;
				}
			}
			if (pos == str.size() - 1)
			{
				std::cout << "No solution";
				return 0;
			}
			if (str[pos + 1] == '@')
			{
				std::cout << "No solution";
				return 0;
			}
			a.push_back(str.substr(0, pos + 2));
			str.erase(0, pos + 2);
		}
		else
		{
			std::cout << "No solution";
			return 0;
		}
	}

	std::string ans;
	for (auto &s : a) ans += s + ",";
	while(ans.back() == ',') ans.pop_back();

	std::cout << ans << std::endl;
	//system("pause");

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
	std::ios_base::sync_with_stdio(0);

	std::string str;
	std::cin >> str;

	std::vector<std::string> a;

	while (str.size())
	{
		if (isalpha(str[0]))
		{
			size_t pos = str.find('@');
			if (pos == std::string::npos)
			{
				if (a.size()) { a[a.size() - 1] += str; str = ""; }
				else
				{
					std::cout << "No solution";
					return 0;
				}
			}
			if (pos == a.size() - 1)
			{
				std::cout << "No solution";
				return 0;
			}
			if (str[pos + 1] == '@')
			{
				std::cout << "No solution";
				return 0;
			}
			a.push_back(str.substr(0, pos + 2));
			str.erase(0, pos + 2);
		}
		else
		{
			std::cout << "No solution";
			return 0;
		}
	}

	std::string ans;
	for (auto &s : a) ans += s + ",";
	while(ans.back() == ',') ans.pop_back();

	std::cout << ans << std::endl;
	//system("pause");

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
	std::ios_base::sync_with_stdio(0);

	std::string str;
	std::cin >> str;

	std::vector<std::string> a;

	while (str.size())
	{
		if (isalpha(str[0]))
		{
			size_t pos = str.find('@');
			if (pos == std::string::npos)
			{
				if (a.size()) { a[a.size() - 1] += str; str = ""; }
				else
				{
					std::cout << "No solution";
					return 0;
				}
			}
			if (pos == a.size() - 1)
			{
				std::cout << "No solution";
				return 0;
			}
			if (!isalpha(str[pos + 1]))
			{
				std::cout << "No solution";
				return 0;
			}
			a.push_back(str.substr(0, pos + 2));
			str.erase(0, pos + 2);
		}
		else
		{
			std::cout << "No solution";
			return 0;
		}
	}

	std::string ans;
	for (auto &s : a) ans += s + ",";
	while(ans.back() == ',') ans.pop_back();

	std::cout << ans << std::endl;
	//system("pause");

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
	std::ios_base::sync_with_stdio(0);

	std::string str;
	std::cin >> str;

	std::vector<std::string> a;

	std::string ans;

	while (str.size())
	{
		if (isalpha(str[0]))
		{
			size_t pos = str.find('@');
			if (pos == std::string::npos)
			{
				if (a.size()) { a[a.size() - 1] += str; str = ""; goto l1; }
				else
				{
					std::cout << "No solution";
					return 0;
				}
			}
			//std::cout << "debug: " << str << ' ' << pos << std::endl;
			if (pos == str.size() - 1)
			{
				std::cout << "No solution";
				system("pause");
				return 0;
			}
			if (str[pos + 1] == '@')
			{
				std::cout << "No solution";
				return 0;
			}
			a.push_back(str.substr(0, pos + 2));
			str.erase(0, pos + 2);
		}
		else
		{
			std::cout << "No solution";
			return 0;
		}
	}

	l1:
	for (auto &s : a) ans += s + ",";
	while(ans.back() == ',') ans.pop_back();

	std::cout << ans << std::endl;

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
	std::ios_base::sync_with_stdio(0);

	std::string str;
	std::cin >> str;

	std::vector<std::string> a;

	std::string ans;

	while (str.size())
	{
		if (isalpha(str[0]))
		{
			size_t pos = str.find('@');
			if (pos == std::string::npos)
			{
				if (a.size()) { a[a.size() - 1] += str; str = ""; goto l1; }
				else
				{
					std::cout << "No solution";
					return 0;
				}
			}
			//std::cout << "debug: " << str << ' ' << pos << std::endl;
			if (pos == str.size() - 1)
			{
				std::cout << "No solution";
				return 0;
			}
			if (str[pos + 1] == '@')
			{
				std::cout << "No solution";
				return 0;
			}
			a.push_back(str.substr(0, pos + 2));
			str.erase(0, pos + 2);
		}
		else
		{
			std::cout << "No solution";
			return 0;
		}
	}

	l1:
	for (auto &s : a) ans += s + ",";
	while(ans.back() == ',') ans.pop_back();

	std::cout << ans << std::endl;

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
	std::ios_base::sync_with_stdio(0);

	std::string str;
	std::cin >> str;

	std::vector<std::string> a;

	while (str.size())
	{
		if (isalpha(str[0]))
		{
			size_t pos = str.find('@');
			if (pos == std::string::npos)
			{
				if (a.size()) { a[a.size() - 1] += str; str = ""; goto l1; }
				else
				{
					std::cout << "No solution";
					return 0;
				}
			}
			//std::cout << "debug: " << str << ' ' << pos << std::endl;
			if (pos == str.size() - 1)
			{
				std::cout << "No solution";
				system("pause");
				return 0;
			}
			if (str[pos + 1] == '@')
			{
				std::cout << "No solution";
				return 0;
			}
			a.push_back(str.substr(0, pos + 2));
			str.erase(0, pos + 2);
		}
		else
		{
			std::cout << "No solution";
			return 0;
		}
	}

	std::string ans;
	for (auto &s : a) ans += s + ",";
	while(ans.back() == ',') ans.pop_back();

	l1:
	std::cout << ans << std::endl;

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main()
{
	std::ios_base::sync_with_stdio(0);

	std::string str;
	std::cin >> str;

	std::vector<std::string> a;

	while (str.size())
	{
		if (isalpha(str[0]))
		{
			size_t pos = str.find('@');
			if (pos == std::string::npos)
			{
				if (a.size()) { a[a.size() - 1] += str; str = ""; }
				else
				{
					std::cout << "No solution";
					return 0;
				}
			}
			if (pos == a.size() - 1)
			{
				std::cout << "No solution";
				return 0;
			}
			a.push_back(str.substr(0, pos + 2));
			str.erase(0, pos + 2);
		}
		else
		{
			std::cout << "No solution";
			return 0;
		}
	}

	std::string ans;
	for (auto &s : a) ans += s + ",";
	while(ans.back() == ',') ans.pop_back();

	std::cout << ans << std::endl;
	//system("pause");

	return 0;
}


#include <iostream>
#include<conio.h>
#include<stdlib.h>
#include<string>
#include <iomanip>
#include<string.h>
#include<cstdio>
#include <bits/stdc++.h>

using namespace std;
int main()
{
char s[205];
cin>>s;
int len=strlen(s);

if(s[0]=='@'||s[len-1]=='@')
{
    cout<<"No solution";
    return 0;
}
int counte=0
for(int i=0;i<len;i++)
{
    if(s[i]=='@')
        counte++;
    if(s[i]=='@')
    {
        int j=i+1;
        while(j<len&&s[j]!='@')
        {
            j++;
        }
        if(s[j]=='@'&&(j-i<3))
        {
          cout<<"No solution";
          return 0;
        }
    }
}
if(counte==0)
{
cout<<"No solution";
return 0;
}
cout<<s[0];
for(int i=1;i<len;i++)
{
    int j=i;
    bool flag=false;
    while(j<len&&s[j]!='@')
    {
        j+=1;
        if(s[j]=='@')
        flag=true;
    }
    if(s[i-1]=='@'&&i!=len-1&&flag)
    {
        cout<<s[i]<<',';
    }
    else
        cout<<s[i];
}

}


#include <iostream>
#include<conio.h>
#include<stdlib.h>
#include<string>
#include <iomanip>
#include<string.h>
#include<cstdio>
#include <bits/stdc++.h>

using namespace std;
int main()
{
char s[205];
cin>>s;
int len=strlen(s);

if(s[0]=='@'||s[len-1]=='@')
{
    cout<<"No solution";
    return 0;
}
counte=0
for(int i=0;i<len;i++)
{
    if(s[i]=='@')
        counte++;
    if(s[i]=='@')
    {
        int j=i+1;
        while(j<len&&s[j]!='@')
        {
            j++;
        }
        if(s[j]=='@'&&(j-i<3))
        {
          cout<<"No solution";
          return 0;
        }
    }
}
if(counte==0)
{
cout<<"No solution";
return 0;
}
cout<<s[0];
for(int i=1;i<len;i++)
{
    int j=i;
    bool flag=false;
    while(j<len&&s[j]!='@')
    {
        j+=1;
        if(s[j]=='@')
        flag=true;
    }
    if(s[i-1]=='@'&&i!=len-1&&flag)
    {
        cout<<s[i]<<',';
    }
    else
        cout<<s[i];
}

}


#include <iostream>
#include<conio.h>
#include<stdlib.h>
#include<string>
#include <iomanip>
#include<string.h>
#include<cstdio>
#include <bits/stdc++.h>

using namespace std;
int main()
{
char s[205];
cin>>s;
int len=strlen(s);

if(s[0]=='@'||s[len-1]=='@')
{
    cout<<"No solution";
    return 0;
}
int counte=0;
for(int i=0;i<len;i++)
{
    if(s[i]=='@')
        counte++;
    if(s[i]=='@')
    {
        int j=i+1;
        while(j<len&&s[j]!='@')
        {
            j++;
        }
        if(s[j]=='@'&&(j-i<3))
        {
          cout<<"No solution";
          return 0;
        }
    }
}
if(counte==0)
{
cout<<"No solution";
return 0;
}
cout<<s[0];
for(int i=1;i<len;i++)
{
    int j=i;
    bool flag=false;
    while(j<len&&s[j]!='@')
    {
        j+=1;
        if(s[j]=='@')
        flag=true;
    }
    if(s[i-1]=='@'&&i!=len-1&&flag)
    {
        cout<<s[i]<<',';
    }
    else
        cout<<s[i];
}

}


#include <iostream>
#include<conio.h>
#include<stdlib.h>
#include<string>
#include <iomanip>
#include<string.h>
#include<cstdio>
#include <bits/stdc++.h>

using namespace std;
int main()
{
char s[205];
cin>>s;
int len=strlen(s);

if(s[0]=='@'||s[len-1]=='@')
{
    cout<<"No solution";
    return 0;
}

for(int i=0;i<len;i++)
{
    if(s[i]=='@')
    {
        int j=i+1;
        while(j<len&&s[j]!='@')
        {
            j++;
        }
        if(s[j]=='@'&&(j-i<3))
        {
          cout<<"No solution";
          return 0;
        }
    }
}
cout<<s[0];
for(int i=1;i<len;i++)
{
    int j=i;
    bool flag=false;
    while(j<len&&s[j]!='@')
    {
        j+=1;
        if(s[j]=='@')
        flag=true;
    }
    if(s[i-1]=='@'&&i!=len-1&&flag)
    {
        cout<<s[i]<<',';
    }
    else
        cout<<s[i];
}

}


#include <iostream>
#include<conio.h>
#include<stdlib.h>
#include<string>
#include <iomanip>
#include<string.h>
#include<cstdio>
#include <bits/stdc++.h>

using namespace std;
int main()
{
char s[205];
cin>>s;
int len=strlen(s);

if(s[0]=='@'||s[len-1]=='@')
{
    cout<<"No solution";
    return 0;
}

for(int i=0;i<len;i++)
{
    if(s[i]=='@')
    {
        int j=i+1;
        while(j<len&&s[j]!='@')
        {
            j++;
        }
        if(s[j]=='@'&&(j-i<3))
        {
          cout<<"No solution";
          return 0;
        }
    }
}
cout<<s[0];
for(int i=1;i<len;i++)
{
    if(s[i-1]=='@'&&i!=len-1)
    {
        cout<<s[i]<<',';
    }
    else
        cout<<s[i];
}

}


/*#include <bits/stdc++.h>

using namespace std;
int adj[110][110];
int n,m,a,b,sz,ans,cnt,idx;
set <int> st;
vector <pair<int,int>> dlts;
int main()
{
    cin>>n>>m;
    for (int i=0; i<m; i++)
    {
        cin>>a>>b;
        st.insert(a);
        st.insert(b);
        adj[a][b]=1;
        adj[b][a]=1;
    }
    sz=st.size();
    while (sz>1)
    {
        for (int i=1; i<=n; i++)
        {
            cnt=0;
            if (st.find(i)!=st.end())
            {

                for (int j=1; j<=n; j++)
                {
                    if (adj[i][j]==1)
                    {
                        idx=j;
                        cnt++;
                    }
                    if (cnt>1) break;

                }
            }
            if (cnt==1)
            {
                adj[i][idx]=0;
                //adj[idx][i]=0;
                dlts.push_back(make_pair(idx,i));
                st.erase(i);
                sz--;
            }
        }
        if (dlts.size()==0 ) break;
        for (int i=0;i<dlts.size();i++)
            adj[dlts[i].first][dlts[i].second]=0;
        dlts.clear();

        ans++;
    }
    cout<<ans<<"\n";
    return 0;
}*/
/*#include <bits/stdc++.h>
using namespace std;
//228 B
#define ll unsigned long long
int na,ma,nb,mb;
char a[55][55],b[55][55];
vector <pair <int,int>> v;
set <pair <int,int>> st;
int x,y,xans,yans,ans,mx;
int main()
{
    cin>>na>>ma;
    for (int i=1;i<=na;i++)
        for (int j=1;j<=ma;j++)
    {
        cin>>a[i][j];
        if (a[i][j]=='1') v.push_back(make_pair(i,j));
    }
    cin>>nb>>mb;
    for (int i=1;i<=nb;i++)
        for (int j=1;j<=mb;j++)
    {
        cin>>b[i][j];
        if (b[i][j]=='1') st.insert(make_pair(i,j));
    }
    //cout<<"v size :"<<v.size()<<"\n";
    //cout<<"st size :"<<st.size()<<"\n";
    for (x=-50;x<=50;x++)
        {for (y=-50;y<=50;y++)
    {
        //cout<<"X : "<<x<<" Y :"<<y<<endl;
        int i=0;
        ans=0;
        while (i<v.size())
        {
            pair <int,int> u=make_pair(v[i].first + x ,v[i].second+y);
            if ( st.find(u)!=st.end() )
                ans++;
            i++;
        }
        //cout<<"ans : "<<ans<<endl;
       if (ans>mx)
       {
           mx=ans;
           xans=x;
           yans=y;
       }

    }
        }
    cout<<xans<<" "<<yans<<endl;

    return 0;
}*/
/*#include <bits/stdc++.h>
using namespace std;
//219 B Crashes on 999 or 1000000
#define ll unsigned long long int
ll p,d,ans,mxcnt,tns=10;
ll NineCnt(ll n)
{
    ll cnt=0;
    while (n!=0)
    {
        if (n%10 == 9 ) cnt++;
        else
            break;
        n/=10;

    }
    return cnt;
}
ll Max9()
{
    ll tens=10,cpy=p+1;
    ll Cut=cpy%10 + ((cpy/10)%10) * 10;
    cpy/=100;
     cout<<"P-Cut : "<<p-Cut<<endl;
     cout<<"Cut : "<<Cut<<endl;
     cout<<"Cpy : "<<cpy<<endl;
     ans=p-Cut;
    bool in=0;
    while (p-Cut>=p-d && cpy!=0)
    {
        cout<<"P-Cut : "<<p-Cut<<endl;
        cout<<"Cut : "<<Cut<<endl;
        cout<<"Cpy : "<<cpy<<endl;
        ans=p-Cut;
        tens*=10;
        if (cpy%10==0)
            Cut+= tens;
        else
            Cut+=(cpy%10) * tens;
        cpy/=10;
        in=1;

    }
    if (in)
    return ans;
    else
        return -1;
}
int main()
{
    cin>>p>>d;
        //cout<<"in else\n";
        ll frst9=p-(p%10+1);
        ll ans=Max9();
        if (p<=9)
            cout<<p<<"\n";
         else if (ans==-1 || NineCnt(frst9)>NineCnt(ans))
            cout<<"frst9 :"<<frst9<<"\n";
        else
         cout<<"Ans :"<<ans<<"\n";

    return 0;
}
/*numDigits=1+floor(log10(p));
    cout<<"numDigits :"<<numDigits<<"\n";
    for (ll i=1;i<numDigits;i++)
        {
            tns*=10;
            cout<<tns<<"\n";
        }
    cout<<"tns bfr :"<<tns-1<<"\n";
    if (tns<=p && tns>=p-d)
        cout<<"Tns :"<<tns-1<<"\n";
    else
    {*/

/*#include <bits/stdc++.h>
using namespace std;
long long n,k,a[110000];
int main()
{
    cin>>n;
    for (int i=0;i<n;i++)
        cin>>a[i];
    for (int i=0;i<n-1;i++)
    {
        if (a[i]>a[i+1])
            k+=a[i]-a[i+1];
    }
    cout<<k<<"\n";
    return 0;
}*/
/*#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <stack>
#include <sstream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <deque>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

#define FOR(i,a,b)				for (i=a;i<b;i++)
#define s(n)					scanf("%d",&n)
#define p(n)					printf("%d\n",n)
#define sd(n)					int n;scanf("%d",&n)
#define pb(n)                                   push_back(n)
#define clr(a)                                  memset(a,0,sizeof(a))
#define all(c)                                  (c).begin(),(c).end()

typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <string> vstr;
typedef long long ll;
//231 B
int main()
{
    sd(n);sd(d);sd(l);
    int i;
    vi ans;
    FOR(i,0,n-1)
    {
		if(d>0)
		{
			ans.pb(l);
			d = l-d;
			cout<<"d >0 : (l-d) "<<d<<"\n";
		}
		else
		{
			ans.pb(1);
			d = 1-d;
			cout<<"d <0 : (one-d) "<<d<<"\n";
		}
    }
    if(d<=l && d>=1)
	{
		FOR(i,0,n-1)
			printf("%d ",ans[i]);
		printf("%d\n",d);
	}
	else
		printf("-1\n");
	return 0;
}*/
/*#include<cmath>
#include<iostream>
using namespace std;
//281 B
int main(){
    int n;
    double e=999999,x,y,b=1,a=0,tb=1,ta=0;
    cin>>x>>y>>n;
    while(b<=n){
        while(abs(a/b-x/y)>abs((a+1)/b-x/y))
            {
                cout<<"a : "<<a<<"  b : "<<b<<"\n";
                a++;
            }
        if(abs(a/b-x/y)<e)
            tb=b,ta=a,e=abs(a/b-x/y);
        if(e==0)
            break;
        b++;
    }
    cout<<ta<<"/"<<tb;
}*/
/*#include <bits/stdc++.h>
using namespace std;
//63 B
#define ll unsigned long long int
int n,cnt,p[1100],l,r
bool can,in;
int main()
{
    cin>>n>>k;
    for (int i=1;i<=n;i++)
        cin>>p[i];
    int i=o;
    while (i<n)
    {
        i++;
        if (arr[i] != i )
            {
                while (i<n)
                {
                if (in)
                {
                    can=0;
                    break;
                }
                in=1; l=i;
            if (arr[i]<arr[i+1] && arr[i+1]-arr[i]!=1 && arr[i+1]!=i+1)
                {
                    can=0;
                    break;
                }
            if (arr[i+1]==i+1)
                r=i+1;

                }

            )
            }

    }
    if (can)
        cout<<l<<" "<<r<<"\n";
    else
        cout<<"0.0\n";
    return 0;
}*/
/*#include <bits/stdc++.h>
//9 B
#define  ll long long
using namespace std;
int a[2005],n,vs,vb,xu,yu,stop=999999;
double best=999999,ans,t;
int main()
{
    cin>>n>>vb>>vs;
    for (int i=1; i<=n; i++)
            cin>>a[i];
    cin>>xu>>yu;
    for (int i=1;i<=n;i++)
    {
        if (i==1 ) continue;
        int xdiff=xu-a[i];
       // double s2=sqrt(xdiff*xdiff - yu*yu);
        //double s1=a[i];
        int s2=sqrt(xdiff*xdiff - yu*yu);
        int s1=a[i];
        t=double(s1)/vb + double(s2)/vs;
        cout<<"t : "<<t<<"\n";
        cout<<"s2 : "<<s2<<"\n";
        if (t <=best && s2<stop)

        ans=i;
        best=t;
        stop=s2;

        }
    cout<<ans<<"\n";

    return 0;
}
*/
/*#include <bits/stdc++.h>
using namespace std;
//275 B
#define ll unsigned long long int
int n,m;
char grid[55][55];
int directionCnt[55][55];
bool vis[55][55];

bool valid(int i, int j)
{
    if (i>=0 && i<=n && j>=0 && j<=m )return 1;
    return 0;
}
void srch (int i,int j, int cnt,int x)
{
    if (!valid(i,j) || vis[i][j] || grid[i][j]=='W')
        return ;
    vis[i][j]=1;
    if (grid[i][j]=='B' && x!=5)
    {
        directionCnt[i][j]=min(directionCnt[i][j],cnt);
    }
    if (x!=1)
        srch (i+1,j,cnt+1,1);
    else
        srch (i+1,j,cnt,1);

    if (x!=2)
        srch (i-1,j,cnt+1,2);
    else
        srch (i-1,j,cnt,2);

    if (x!=3)
        srch (i,j+1,cnt+1,3);
    else
        srch (i,j+1,cnt,3);

    if (x!=4)
        srch (i,j-1,cnt+1,4);
    else
        srch (i,j-1,cnt,4);

    vis[i][j]=0;

}
vector <pair<int,int>> black;
bool can=1;
int main()
{
    cin>>n>>m;
    for (int i=0; i<n; i++)
        for (int j=0 ; j<m; j++)
            {
                cin>>grid[i][j];
                directionCnt[i][j]=999999;
                if (grid[i][j]=='B')
                    black.push_back(make_pair(i,j));
            }

    for (int i=0; i<black.size(); i++)
                {
                    //cout<<black[i].first<<" "<<black[i].second<<"\n";
                    srch(black[i].first,black[i].second,-1,5);
                }
    for (int i=0;i<black.size();i++)
                    {
                        cout<<"direction cnt of "<<black[i].first<"  ";
                        cout<<black[i].second<<"  : "<<directionCnt[black[i].first][black[i].second]<<"\n";
                        if (directionCnt[black[i].first][black[i].second] > 1)
                            {
                                can=0;
                                break;
                            }
                    }

    if (can)
        cout<<"YES\n";
    else
        cout<<"NO\n";

    return 0;
}
*/
#include <bits/stdc++.h>
using namespace std;
//31B
#define ll unsigned long long int
string s,temp;
int prevpos=-3;
bool can=1;
vector <int> pos;
int main()
{
    //pos.push_back(0);
    cin>>s;
    for (int i=0;i<s.size();i++)
    {
        if (s[i]=='@')
        {
            pos.push_back(i);
            if ((i==0 ) || i==s.size()-1)
            {
                can=0; break;
            }
            if (i-prevpos<=2 && pos.size()>1)
                {
                    can=0;
                    break;
                }
            prevpos=i;
        }
    }
    if (pos.size()==0) can=0;

    if (can)
    {
        for (int i=0;i<pos.size();i++)
    {
        if (pos.size()==1)
        {
            cout<<s<<"\n";
            return 0;
        }

        if (i==0)
            temp=s.substr(0,pos[i]+2);
        else if (i==pos.size()-1)
             temp=s.substr(pos[i-1]+2,200);
        else
            temp=s.substr(pos[i-1]+2,pos[i]-pos[i-1]);
        if (i!=pos.size()-1)
        cout<<temp<<",";
        else
        cout<<temp<<"\n";
    }
    }
    else
        cout<<"No solution\n";

    //for (auto x: pos) cout<<x<<"\n";
    return 0;
}
/*#include <bits/stdc++.h>
using namespace std;
//31B
#define ll unsigned long long int
int main()
{
    return 0;
}
*/