传送门
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
#define re register
#define ll long long
const int N=2010;
void read(int &a)
{
a=0;
int d=1;
char ch;
while(ch=getchar(),ch>'9'||ch<'0')
if(ch=='-')
d=-1;
a=ch^48;
while(ch=getchar(),ch>='0'&&ch<='9')
a=(a<<3)+(a<<1)+(ch^48);
a*=d;
}
double k[N],f[N][N][5];
int ma[N][N],a[N],b[N];
int main()
{
//freopen("in.txt","r",stdin);
int n,m,v,e;
read(n);
read(m);
read(v);
read(e);
for(re int i=1;i<=n;i++)
read(a[i]);
for(re int i=1;i<=n;i++)
read(b[i]);
for(re int i=1;i<=n;i++)
scanf("%lf",&k[i]);
for(re int i=1;i<=v;i++)
for(re int j=1;j<=v;j++)
ma[i][j]=100000000;
for(re int i=1;i<=v;i++)
ma[i][i]=0;
for(re int i=1;i<=e;i++)
{
int u,v,w;
read(u);
read(v);
read(w);
ma[u][v]=ma[v][u]=min(w,ma[u][v]);
}
for(re int i=1;i<=v;i++)
for(re int j=1;j<=v;j++)
for(re int k=1;k<=v;k++)
if(ma[j][k]>ma[j][i]+ma[i][k])
ma[j][k]=ma[j][i]+ma[i][k];
for(re int i=0;i<=n;i++)
for(re int j=0;j<=m;j++)
f[i][j][0]=f[i][j][1]=100000000;
f[1][0][0]=f[1][1][1]=0;
for(re int i=2;i<=n;i++)
{
f[i][0][0]=f[i-1][0][0]+ma[a[i-1]][a[i]];
for(re int j=1;j<=min(m,i);j++)
{
f[i][j][0]=min(f[i][j][0],min(f[i-1][j][0]+ma[a[i-1]][a[i]],f[i-1][j][1]+ma[b[i-1]][a[i]]*k[i-1]+ma[a[i-1]][a[i]]*(1-k[i-1])));
f[i][j][1]=min(f[i][j][1],min(f[i-1][j-1][0]+ma[a[i-1]][a[i]]*(1-k[i])+ma[a[i-1]][b[i]]*k[i],f[i-1][j-1][1]+ma[a[i-1]][a[i]]*(1-k[i-1])*(1-k[i])+ma[a[i-1]][b[i]]*(1-k[i-1])*k[i]+ma[b[i-1]][a[i]]*(1-k[i])*k[i-1]+ma[b[i-1]][b[i]]*k[i-1]*k[i]));
}
}
double ans=100000000;
for(re int i=0;i<=m;i++)
ans=min(ans,min(f[n][i][0],f[n][i][1]));
printf("%.2lf",ans);
return 0;
}