#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef map <int, int> mii;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const int inf=1e9;
#define maxn 1000001
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#include <conio.h>
int n,m,x,y;
int main(){
scanf("%d %d",&n,&m);
scanf("%d %d",&x,&y);
vector < vector <double> >a(n+1, vector <double>(n+1,100));
vector < vector <double> >b(n+1, vector <double>(n+1,inf));
for(int i=1;i<=n;i++) a[i][i]=0;
while(m--){
int u,v,p;
scanf("%d %d %d",&u,&v,&p);
a[u][v]-=p;
a[v][u]-=p;
b[u][v]=b[v][u]=p;
}
for(int k=1;k<=n;k++){
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if( b[i][k]==inf || b[k][j]==inf || a[i][k]==100 || a[k][j]==100) continue;
if( a[i][j]==100){
a[j][i]=a[i][j] = a[i][k]-( (double)(b[j][k]*a[i][k])/(double)100 );
}
else{
double x1 = a[i][k]-( (double)(b[j][k]*a[i][k])/(double)100);
if((double)(100-a[i][j])/(double)100> (double)(100-x1)/(double)100 && x1>=0 && x1<=100){
a[j][i]=a[i][j]=x1;
}
}
}
}
}
printf("%.6lf", (100-a[x][y])/100);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNpbmNsdWRlIDxhbGdvcml0aG0+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAgCnR5cGVkZWYgbG9uZyBsb25nICBsbDsKdHlwZWRlZiBtYXAgPGludCwgaW50PiBtaWk7CnR5cGVkZWYgcGFpciA8aW50LCBpbnQ+IHBpaTsKdHlwZWRlZiBwYWlyIDxsbCwgbGw+IHBsbDsKY29uc3QgaW50IGluZj0xZTk7CiAgCiNkZWZpbmUgbWF4biAxMDAwMDAxCiNkZWZpbmUgbXAgbWFrZV9wYWlyCiNkZWZpbmUgcGIgcHVzaF9iYWNrCiNkZWZpbmUgZmYgZmlyc3QKI2RlZmluZSBzcyBzZWNvbmQKI2RlZmluZSBhbGwoeCkgeC5iZWdpbigpLCB4LmVuZCgpCiNpbmNsdWRlIDxjb25pby5oPgppbnQgbixtLHgseTsKaW50IG1haW4oKXsKICAgIHNjYW5mKCIlZCAlZCIsJm4sJm0pOwogICAgc2NhbmYoIiVkICVkIiwmeCwmeSk7CiAgICB2ZWN0b3IgPCB2ZWN0b3IgPGRvdWJsZT4gPmEobisxLCB2ZWN0b3IgPGRvdWJsZT4obisxLDEwMCkpOwogICAgdmVjdG9yIDwgdmVjdG9yIDxkb3VibGU+ID5iKG4rMSwgdmVjdG9yIDxkb3VibGU+KG4rMSxpbmYpKTsKICAgICAgCiAgICBmb3IoaW50IGk9MTtpPD1uO2krKykgYVtpXVtpXT0wOwogICAgICAKICAgIHdoaWxlKG0tLSl7CiAgICAgICAgaW50IHUsdixwOwogICAgICAgIHNjYW5mKCIlZCAlZCAlZCIsJnUsJnYsJnApOwogICAgICAgICAgCiAgICAgICAgYVt1XVt2XS09cDsKICAgICAgICBhW3ZdW3VdLT1wOwogICAgICAgIGJbdV1bdl09Ylt2XVt1XT1wOwogICAgfQogICAgICAKICAgICAgCiAgICBmb3IoaW50IGs9MTtrPD1uO2srKyl7CiAgICAgICAgZm9yKGludCBpPTE7aTw9bjtpKyspewogICAgICAgICAgICBmb3IoaW50IGo9MTtqPD1uO2orKyl7CiAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgaWYoIGJbaV1ba109PWluZiB8fCBiW2tdW2pdPT1pbmYgfHwgYVtpXVtrXT09MTAwIHx8IGFba11bal09PTEwMCkgY29udGludWU7CiAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgaWYoIGFbaV1bal09PTEwMCl7ICAgICAgCiAgICAgICAgICAgICAgICAgICAgYVtqXVtpXT1hW2ldW2pdID0gYVtpXVtrXS0oIChkb3VibGUpKGJbal1ba10qYVtpXVtrXSkvKGRvdWJsZSkxMDAgKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2V7CiAgICAgICAgICAgICAgICAgICAgZG91YmxlIHgxID0gYVtpXVtrXS0oIChkb3VibGUpKGJbal1ba10qYVtpXVtrXSkvKGRvdWJsZSkxMDApOwogICAgICAgICAgICAgICAgICAgIGlmKChkb3VibGUpKDEwMC1hW2ldW2pdKS8oZG91YmxlKTEwMD4gKGRvdWJsZSkoMTAwLXgxKS8oZG91YmxlKTEwMCAmJiB4MT49MCAmJiB4MTw9MTAwKXsKICAgICAgICAgICAgICAgICAgICAgICAgYVtqXVtpXT1hW2ldW2pdPXgxOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfSAgIAogICAgICAgIH0KICAgIH0KICAgICAgCiAgICAgIAogICAgICAKICAgIHByaW50ZigiJS42bGYiLCAoMTAwLWFbeF1beV0pLzEwMCk7CiAgICAgIAogICAgcmV0dXJuIDA7Cn0=