#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), i##end = (b); i < i##end; ++i)
#define debug(...) fprintf(stderr, VA_ARGS)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
template<typename T> inline bool chkmin(T &a, const T &b) {
return b < a ? a = b, 1 : 0;
}
template<typename T> inline bool chkmax(T &a, const T &b) {
return a < b ? a = b, 1 : 0;
}
typedef long long LL;
const int oo = 0x3f3f3f3f;
const int maxn = 500010, maxm = 1000100;
struct edge {
int id, g, nxt;
};
int en;
int st[maxn + 5];
edge e[(maxm << 1) + 5];
inline void add_edge(int x, int y, int z) {
e[en] = edge(y, z, st[x]), st[x] = en++;
}
int n, m;
int S, T;
bool bad[maxn + 5];
int buffer[maxn + 5];
int dfn_cnt = 0;
int dfn[maxn + 5], low[maxn + 5];
bool has_T[maxn + 5];
void get_bad_vertices(int x) {
if (x == T)
has_T[x] = 1;
}
LL dis[maxn + 5];
bool on_path[maxm + 5];
int pathn;
int path[maxn + 5];
int id[maxn + 5];
inline void get_path() {
static bool vis[maxn + 5];
static int pre[maxn + 5];
priority_queue<pair<LL, int>, vector<pair<LL, int>>, greater<pair<LL, int>>> q;
memset(dis, oo, sizeof(dis[0]) * n);
memset(vis, 0, sizeof(vis[0]) * n);
q.push(mp(0, S));
dis[S] = 0;
}
int bad_pair[(maxm << 1) + 5];
vector<int> down[maxn + 5];
inline void set_bad_pair(const vector<int> &v) {
if (SZ(v) != 2)
return;
}
void get_bad_pairs(int x) {
dfn[x] = low[x] = dfn_cnt++;
vector<int> up;
}
int fa[maxn + 5];
int get(int x) {
return fa[x] == x ? x : fa[x] = get(fa[x]);
}
int lim[maxn + 5];
inline bool get_lim() {
static bool leftmost[maxn + 5], rightmost[maxn + 5];
static bool vis[maxn + 5];
memset(leftmost, 0, sizeof(leftmost[0]) * pathn);
memset(rightmost, 0, sizeof(rightmost[0]) * pathn);
memset(vis, 0, sizeof(vis[0]) * n);
REP(i, 0, pathn) {
if (!vis[get(path[i])]) {
leftmost[i] = 1;
vis[get(path[i])] = 1;
}
}
memset(vis, 0, sizeof(vis[0]) * n);
}
inline LL work() {
static int vis[maxn + 5];
static int info[maxn + 5];
priority_queue<pair<LL, pair<int, int>>, vector<pair<LL, pair<int, int>>>, greater<pair<LL, pair<int, int>>>>
q;
memset(vis, 0, sizeof(vis[0]) * n);
q.push(mp(0, mp(S, 0)));
}
int main() {
scanf("%d%d", &n, &m);
memset(st, -1, sizeof(st[0]) * n), en = 0;
REP(i, 0, m) {
int x, y, z;
scanf("%d%d%d", &x, &y, &z), --x, --y;
add_edge(x, y, z);
add_edge(y, x, z);
}
scanf("%d%d", &S, &T), --S, --T;
memset(buffer, 0, sizeof(buffer[0]) * n);
memset(dfn, -1, sizeof(dfn[0]) * n);
memset(bad, 0, sizeof(bad[0]) * n);
memset(has_T, 0, sizeof(has_T[0]) * n);
dfn_cnt = 0;
get_bad_vertices(S);
}