#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
struct node {
int x, y, id;
};
vector<node> nodes(1);
int n, flyprice, beginn, endn, inf = 99999;
double e[500][500];
double w(int x1, int y1, int x2, int y2) {
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
bool h(int x1, int y1, int x2, int y2, int x3, int y3) {
return !((x1 - x2) * (x1 - x3) + (y1 - y2) * (y1 - y3));
}
double f(int m) {
double dis[500];
bool book[500] = {0};
fill(dis, dis + 500, inf);
for (int i = 0; i < 500; i++) dis[i] = inf;
dis[m] = 0;
for (int i = 1; i <= n * 4 - 1; i++) {
int minn = inf, u = -1;
for (int j = 1; j <= n * 4; j++) {
if (book[j] == false && dis[j] < minn) {
minn = dis[j];
u = j;
}
}
if (u == -1) break;
book[u] = true;
for (int k = 1; k <= n * 4; k++) {
if (e[u][k] < inf && dis[k] > e[u][k] + dis[u]) {
dis[k] = e[u][k] + dis[u];
}
}
}
return min(min(dis[endn * 4 - 3], dis[endn * 4 - 2]), min(dis[endn * 4 - 1], dis[endn * 4]));
}
int main() {
fill(e[0], e[0] + 500 * 500, inf);
scanf("%d %d %d %d", &n, &flyprice, &beginn, &endn);
for (int i = 1; i <= n; i++) {
int x1, y1, x2, y2, x3, y3, x4, y4, t;
scanf("%d %d %d %d %d %d %d", &x1, &y1, &x2, &y2, &x3, &y3, &t);
if (h(x1, y1, x2, y2, x3, y3)) {
x4 = x2 + x3 - x1;
y4 = y2 + y3 - y1;
} else if (h(x2, y2, x1, y1, x3, y3)) {
x4 = x1 + x3 - x2;
y4 = y1 + y3 - y2;
} else {
x4 = x1 + x2 - x3;
y4 = y1 + y2 - y3;
}
e[(i - 1) * 4 + 1][(i - 1) * 4 + 2] = e[(i - 1) * 4 + 2][(i - 1) * 4 + 1] = w(x1, y1, x2, y2) * t;
e[(i - 1) * 4 + 1][(i - 1) * 4 + 3] = e[(i - 1) * 4 + 3][(i - 1) * 4 + 1] = w(x1, y1, x3, y3) * t;
e[(i - 1) * 4 + 1][(i - 1) * 4 + 4] = e[(i - 1) * 4 + 4][(i - 1) * 4 + 1] = w(x1, y1, x4, y4) * t;
e[(i - 1) * 4 + 2][(i - 1) * 4 + 3] = e[(i - 1) * 4 + 3][(i - 1) * 4 + 2] = w(x2, y2, x3, y3) * t;
e[(i - 1) * 4 + 2][(i - 1) * 4 + 4] = e[(i - 1) * 4 + 4][(i - 1) * 4 + 2] = w(x2, y2, x4, y4) * t;
e[(i - 1) * 4 + 3][(i - 1) * 4 + 4] = e[(i - 1) * 4 + 4][(i - 1) * 4 + 3] = w(x3, x3, x4, y4) * t;
nodes.push_back({x1, y1, i});
nodes.push_back({x2, y2, i});
nodes.push_back({x3, y3, i});
nodes.push_back({x4, y4, i});
}
for (int i = 1; i <= n * 4; i++) {
for (int j = i + 1; j <= n * 4; j++) {
if (nodes[i].id != nodes[j].id) {
e[i][j] = e[j][i] = flyprice * w(nodes[i].x, nodes[i].y, nodes[j].x, nodes[j].y);
}
}
}
double ans = inf;
for (int i = 3; i >= 0; i--)
ans = min(ans, f(beginn * 4 - i));
printf("%.1f\n", ans);
return 0;
}