#include <bits/stdc++.h>
using namespace std;
int n, m, f[300005], v[600005], o[600005], w[600005], d[300005], l[300005], t,
    g, in[300005], S, T, p;
bool b[600005], u[300005], h[300005];
void bd(int a, int b, int c) {
  v[++p] = b;
  o[p] = f[a];
  f[a] = p;
  w[p] = c;
}
void dfs(int x, int y) {
  d[x] = l[x] = ++t;
  for (int i = (f[x]); i; i = o[i])
    if (i != (y ^ 1)) {
      if (!d[v[i]]) {
        dfs(v[i], i);
        if (l[v[i]] > d[x]) b[i] = b[i ^ 1] = 1;
        l[x] = min(l[x], l[v[i]]);
      } else
        l[x] = min(l[x], d[v[i]]);
    }
}
void dfs2(int x, int y) {
  in[x] = y;
  for (int i = (f[x]); i; i = o[i])
    if (!b[i]) {
      if (w[i]) h[y] = 1;
      if (!in[v[i]]) dfs2(v[i], y);
    }
}
bool dfs3(int x, int y) {
  u[x] = 1;
  if (h[in[x]]) y = 1;
  if (x == T) return y;
  for (int i = (f[x]); i; i = o[i])
    if (!u[v[i]] && dfs3(v[i], w[i] ? 1 : y)) return 1;
  return 0;
}
int main() {
  p = 1;
  scanf("%d %d", &n, &m);
  for (int i = (0); i < (m); i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    bd(a, b, c);
    bd(b, a, c);
  }
  scanf("%d %d", &S, &T);
  dfs(1, 0);
  for (int i = (1); i <= (n); i++)
    if (!in[i]) dfs2(i, ++g);
  puts(dfs3(S, 0) ? "YES" : "NO");
}

### Prompt

Please provide a cpp coded solution to the problem described below:

Johnny is playing a well-known computer game. The game are in some country, where the player can freely travel, pass quests and gain an experience.

In that country there are n islands and m bridges between them, so you can travel from any island to any other. In the middle of some bridges are lying ancient powerful artifacts. Johnny is not interested in artifacts, but he can get some money by selling some artifact.

At the start Johnny is in the island a and the artifact-dealer is in the island b (possibly they are on the same island). Johnny wants to find some artifact, come to the dealer and sell it. The only difficulty is that bridges are too old and destroying right after passing over them. Johnnie's character can't swim, fly and teleport, so the problem became too difficult.

Note that Johnny can't pass the half of the bridge, collect the artifact and return to the same island. 

Determine if Johnny can find some artifact and sell it.

Input

The first line contains two integers n and m (1 ≤ n ≤ 3·105, 0 ≤ m ≤ 3·105) — the number of islands and bridges in the game.

Each of the next m lines contains the description of the bridge — three integers xi, yi, zi (1 ≤ xi, yi ≤ n, xi ≠ yi, 0 ≤ zi ≤ 1), where xi and yi are the islands connected by the i-th bridge, zi equals to one if that bridge contains an artifact and to zero otherwise. There are no more than one bridge between any pair of islands. It is guaranteed that it's possible to travel between any pair of islands.

The last line contains two integers a and b (1 ≤ a, b ≤ n) — the islands where are Johnny and the artifact-dealer respectively.

Output

If Johnny can find some artifact and sell it print the only word "YES" (without quotes). Otherwise print the word "NO" (without quotes).

Examples

Input

6 7
1 2 0
2 3 0
3 1 0
3 4 1
4 5 0
5 6 0
6 4 0
1 6


Output

YES


Input

5 4
1 2 0
2 3 0
3 4 0
2 5 1
1 4


Output

NO


Input

5 6
1 2 0
2 3 0
3 1 0
3 4 0
4 5 1
5 3 0
1 2


Output

YES

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
int n, m, f[300005], v[600005], o[600005], w[600005], d[300005], l[300005], t,
    g, in[300005], S, T, p;
bool b[600005], u[300005], h[300005];
void bd(int a, int b, int c) {
  v[++p] = b;
  o[p] = f[a];
  f[a] = p;
  w[p] = c;
}
void dfs(int x, int y) {
  d[x] = l[x] = ++t;
  for (int i = (f[x]); i; i = o[i])
    if (i != (y ^ 1)) {
      if (!d[v[i]]) {
        dfs(v[i], i);
        if (l[v[i]] > d[x]) b[i] = b[i ^ 1] = 1;
        l[x] = min(l[x], l[v[i]]);
      } else
        l[x] = min(l[x], d[v[i]]);
    }
}
void dfs2(int x, int y) {
  in[x] = y;
  for (int i = (f[x]); i; i = o[i])
    if (!b[i]) {
      if (w[i]) h[y] = 1;
      if (!in[v[i]]) dfs2(v[i], y);
    }
}
bool dfs3(int x, int y) {
  u[x] = 1;
  if (h[in[x]]) y = 1;
  if (x == T) return y;
  for (int i = (f[x]); i; i = o[i])
    if (!u[v[i]] && dfs3(v[i], w[i] ? 1 : y)) return 1;
  return 0;
}
int main() {
  p = 1;
  scanf("%d %d", &n, &m);
  for (int i = (0); i < (m); i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    bd(a, b, c);
    bd(b, a, c);
  }
  scanf("%d %d", &S, &T);
  dfs(1, 0);
  for (int i = (1); i <= (n); i++)
    if (!in[i]) dfs2(i, ++g);
  puts(dfs3(S, 0) ? "YES" : "NO");
}

```