#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <fstream>
#include <queue>

#define rep(i, l, r) for(int i = l; i <= r; i++)
#define down(i, l, r) for(int i = l; i >= r; i--)
#define MS 1234
#define MAX 1037471823
#define Q 12345678

using namespace std;

struct node
{
	int x, y, z;
	bool operator < (const node &k) const { return z < k.z; }
} c[5678];
int n, m, s, t, ss, tt, h[567], v[34567];
long long fz, fm;

int Head(int x) { while (h[h[x]] != h[x]) h[x] = h[h[x]]; return h[x]; }

int gcd(int x, int y) { return y==0 ? x : x<y ? gcd(x, y%x) : gcd(y, x%y); }

int main()
{
	scanf("%d%d", &n, &m);
	fm = 1; fz = 123456;
	rep(i, 1, m) scanf("%d%d%d", &c[i].x, &c[i].y, &c[i].z); sort(c+1, c+1+m); c[m+1].z = MAX;
	v[1] = 1; rep(i, 2, 30000) { v[i] = v[i+1]; while (c[v[i]].z < i) v[i]++; }
	scanf("%d%d", &s, &t); ss = 1; 
	while (true)
	{
		rep(i, 1, n) h[i] = i;
		while (Head(s) != Head(t) && ss <= 30000) 
		{ 
			rep(i, v[ss], v[ss+1]-1) if (Head(c[i].x) != Head(c[i].y)) h[h[c[i].x]] = h[c[i].y];
			ss++;
		}
		if (ss > 30000) break; ss--;
		tt = ss;
		rep(i, 1, n) h[i] = i;
		while (Head(s) != Head(t)) 
		{ 
			rep(i, v[tt], v[tt+1]-1) if (Head(c[i].x) != Head(c[i].y)) h[h[c[i].x]] = h[c[i].y];
			tt--;
		}
		tt++; if (fm*ss < fz*tt) fz = ss, fm = tt; ss = tt+1;
	}
	n = gcd(fz, fm);
	if (fz == 123456) printf("IMPOSSIBLE\n"); else if (fz % fm == 0) printf("%lld\n", fz/fm); else printf("%lld/%lld\n", fz/n, fm/n);
	return 0;
}