Problem: Kyoya Ootori wants to take the train to get to school. There are n train stations and m one-way train lines going between various stations. Kyoya is currently at train station 1, and the school is at station n. To take a train, he must pay for a ticket, and the train also takes a certain amount of time. However, the trains are not perfect and take random amounts of time to arrive at their destination. If Kyoya arrives at school strictly after t time units, he will have to pay a fine of x.

Each train line is described by a ticket price, and a probability distribution on the time the train takes. More formally, train line i has ticket cost ci, and a probability distribution pi, k which denotes the probability that this train will take k time units for all 1 ≤ k ≤ t. Amounts of time that each of the trains used by Kyouya takes are mutually independent random values (moreover, if Kyoya travels along the same train more than once, it is possible for the train to take different amounts of time and those amounts are also independent one from another). 

Kyoya wants to get to school by spending the least amount of money in expectation (for the ticket price plus possible fine for being late). Of course, Kyoya has an optimal plan for how to get to school, and every time he arrives at a train station, he may recalculate his plan based on how much time he has remaining. What is the expected cost that Kyoya will pay to get to school if he moves optimally?

Input

The first line of input contains four integers n, m, t, x (2 ≤ n ≤ 50, 1 ≤ m ≤ 100, 1 ≤ t ≤ 20 000, 0 ≤ x ≤ 106).

The next 2m lines contain the description of the trains. 

The 2i-th line will have 3 integers ai, bi, ci, representing a one way train from station ai to bi with ticket cost ci (1 ≤ ai, bi ≤ n, ai ≠ bi, 0 ≤ ci ≤ 106). There will always be at least one path from any station to the school. 

The (2i + 1)-th line will contain t integers, pi, 1, pi, 2, ..., pi, t where pi, k / 100000 is the probability that this train will take k units of time to traverse (0 ≤ pi, k ≤ 100 000 for 1 ≤ k ≤ t, <image>). 

It is guaranteed that there is no more than one train between each pair of platforms in each of the directions.

Output

Print a single real number that is equal to an optimal expected cost of getting to school. The answer will be considered correct if its relative or absolute error doesn't exceed 10 - 6.

Examples

Input

4 4 5 1
1 2 0
50000 0 50000 0 0
2 3 0
10000 0 0 0 90000
3 4 0
100000 0 0 0 0
2 4 0
0 0 0 50000 50000


Output

0.7000000000


Input

4 4 5 1
1 2 100
50000 0 50000 0 0
2 3 100
10000 0 0 0 90000
3 4 100
100000 0 0 0 0
2 4 100
0 0 0 50000 50000


Output

200.7500000000

Note

The optimal strategy in the first case is as follows:

First, travel along first train line. With probability 1 / 2 Kyoya will take 1 time unit. Otherwise, Kyoya will take 3 time units.

If the train takes 1 time unit, travel along the 4th train line. Kyoya will make it to school in time with probability 1 / 2. Otherwise, if the train takes 3 time units, travel along the 2nd train line. Kyoya will make it to school in time with probability 1 / 10.

Since the cost of all train lines are zero, we can just look at the probability that Kyoya will incur the penalty. The probability that Kyoya will have to pay the penalty is 1 / 2 × 1 / 2 + 1 / 2 × 9 / 10 = 7 / 10. We can show that no other strategy is strictly better.

The optimal strategy in the second case is to travel along 1 → 2 → 4 no matter what. Kyoya will incur the penalty with probability 3 / 4, and the cost of the trains is 200, thus the expected cost is 200.75.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 70010;
struct comp {
  double x, y;
};
struct edge {
  int y, nex, c;
} s[110];
struct node {
  int x, y, c;
} p[110];
vector<int> V[N];
int first[N], len, dis[55];
double q[110][20010], f[55][20010], g[55][20010];
priority_queue<pair<int, int> > qs;
comp operator+(const comp& a, const comp& b) {
  return (comp){a.x + b.x, a.y + b.y};
}
comp operator-(const comp& a, const comp& b) {
  return (comp){a.x - b.x, a.y - b.y};
}
comp operator*(const comp& a, const comp& b) {
  return (comp){a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x};
}
int n, m, T, X;
void ins(int x, int y, int c) {
  s[++len] = (edge){y, first[x], c};
  first[x] = len;
}
void Dijkstra() {
  memset(dis, 63, sizeof(dis));
  dis[n] = 0;
  qs.push(make_pair(0, n));
  while (!qs.empty()) {
    pair<int, int> X = qs.top();
    qs.pop();
    if (dis[X.second] != -X.first) continue;
    int x = X.second;
    for (int i = first[x]; i != 0; i = s[i].nex)
      if (dis[s[i].y] > dis[x] + s[i].c) {
        dis[s[i].y] = dis[x] + s[i].c;
        qs.push(make_pair(-dis[s[i].y], s[i].y));
      }
  }
}
comp A[N], B[N];
int l, limit, id[N];
const double Pi = acos(-1.0);
void DFT(comp* f, int d) {
  for (int i = 0; i < limit; i++)
    if (i < id[i]) swap(f[i], f[id[i]]);
  for (int l = 1; l < limit; l <<= 1) {
    comp wn = (comp){cos(Pi / l), sin(Pi / l)};
    if (!d) wn.y = -wn.y;
    for (int i = 0; i < limit; i += l + l) {
      comp w = (comp){1, 0};
      for (int x = i, y = i + l; x < i + l; x++, y++, w = w * wn) {
        comp a = f[x], b = f[y] * w;
        f[x] = a + b;
        f[y] = a - b;
      }
    }
  }
  if (!d)
    for (int i = 0; i < limit; i++) f[i].x /= limit;
}
void prepare(int n) {
  limit = 1, l = 0;
  while (limit <= n) limit <<= 1, l++;
  for (int i = 0; i < limit; i++)
    id[i] = ((id[i >> 1] >> 1) | ((i & 1) << (l - 1)));
}
void cdq(int l, int r) {
  if (l == r) {
    for (int i = 1; i < n; i++) f[i][l] = 1e9;
    f[n][l] = 0;
    for (int i = 1; i <= m; i++)
      f[p[i].x][l] = min(f[p[i].x][l], g[i][l] + p[i].c);
    return;
  }
  int mid = (l + r) / 2;
  cdq(mid + 1, r);
  prepare(r - mid - 1 + r - l - 1);
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < limit; j++) A[j] = B[j] = (comp){0, 0};
    for (int j = 0; j < r - mid; j++) A[j] = (comp){f[p[i].y][j + mid + 1], 0};
    for (int j = 0; j < r - l; j++) B[j] = (comp){q[i][r - l - j], 0};
    DFT(A, 1);
    DFT(B, 1);
    for (int j = 0; j < limit; j++) A[j] = A[j] * B[j];
    DFT(A, 0);
    for (int j = l; j <= mid; j++) g[i][j] += A[j + r - l - mid - 1].x;
  }
  cdq(l, mid);
}
void solve() {
  prepare(T + T - 2);
  for (int i = 1; i <= m; i++) {
    for (int j = 0; j < limit; j++) A[j] = B[j] = (comp){0, 0};
    for (int j = 0; j < T; j++) A[j] = (comp){1.0 * dis[p[i].y] + X, 0};
    for (int j = 0; j < T; j++) B[j] = (comp){q[i][T - j], 0};
    DFT(A, 1);
    DFT(B, 1);
    for (int j = 0; j < limit; j++) A[j] = A[j] * B[j];
    DFT(A, 0);
    for (int j = 1; j <= T; j++) g[i][j] += A[j - 1].x;
  }
  cdq(0, T);
  printf("%.10lf\n", f[1][0]);
}
int main() {
  scanf("%d %d %d %d", &n, &m, &T, &X);
  int x, y, c;
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &p[i].x, &p[i].y, &p[i].c);
    V[p[i].x].push_back(i);
    ins(p[i].y, p[i].x, p[i].c);
    for (int j = 1; j <= T; j++) scanf("%lf", &q[i][j]), q[i][j] /= 1e5;
  }
  Dijkstra();
  solve();
}