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;
double dpE[109][20009], dpV[109][20009], tots[109], p[109][20009],
    adder[109][20009], maxi = 1e17;
int dis[109][109], cost[109], dest[109], t, x;
vector<int> l[109];
struct base {
  double x, y;
  base() { x = y = 0; }
  base(double _x, double _y) { x = _x, y = _y; }
  base(double _x) { x = _x, y = 0; }
  void operator=(double _x) { x = _x, y = 0; }
  double real() { return x; }
  double imag() { return y; }
  base operator+(const base& b) { return base(x + b.x, y + b.y); }
  void operator+=(const base& b) { x += b.x, y += b.y; }
  base operator*(const base& b) {
    return base(x * b.x - y * b.y, x * b.y + y * b.x);
  }
  void operator*=(const base& b) {
    double p = x * b.x - y * b.y, q = x * b.y + y * b.x;
    x = p, y = q;
  }
  void operator/=(double k) { x /= k, y /= k; }
  base operator-(const base& b) { return base(x - b.x, y - b.y); }
  void operator-=(const base& b) { x -= b.x, y -= b.y; }
  base conj() { return base(x, -y); }
};
double PI = 2.0 * acos(0.0);
const int MAXN = 19;
const int maxn = (1 << MAXN);
base W[maxn], invW[maxn];
void precompute_powers() {
  for (int i = 0; i < maxn / 2; i++) {
    double ang = (2 * PI * i) / maxn;
    double _cos = cos(ang);
    double _sin = sin(ang);
    W[i] = base(_cos, _sin);
    invW[i] = base(_cos, -_sin);
  }
}
void fft(vector<base>& a, bool invert) {
  int n1 = (int)a.size();
  for (int i = 1, j = 0; i < n1; i++) {
    int bit = n1 >> 1;
    for (; j >= bit; bit >>= 1) {
      j -= bit;
    }
    j += bit;
    if (i < j) swap(a[i], a[j]);
  }
  for (int len = 2; len <= n1; len <<= 1) {
    for (int i = 0; i < n1; i += len) {
      int ind = 0;
      int add = maxn / len;
      for (int j = 0; j < len / 2; j++) {
        base u = a[i + j];
        base v = (a[i + j + len / 2] * (invert ? invW[ind] : W[ind]));
        a[i + j] = (u + v);
        a[i + j + len / 2] = (u - v);
        ind += add;
      }
    }
  }
  if (invert) {
    for (int i = 0; i < n1; i++) {
      a[i] *= (1.0 / n1);
    }
  }
}
void convolve(int l1, int r1, int l2, int r2, int ind) {
  if (l1 > r1 || l2 > r2) {
    return;
  }
  int i, j, n1, sz;
  sz = (r1 - l1 + 1) + (r2 - l2 + 1) - 1;
  n1 = 1;
  while (n1 < sz) {
    n1 *= 2;
  }
  vector<base> v1(n1, 0), v2(n1, 0);
  for (i = l1; i <= r1; i++) {
    v1[i - l1] = dpV[dest[ind]][i];
  }
  for (i = l2; i <= r2; i++) {
    v2[i - l2] = p[ind][i];
  }
  fft(v1, false);
  fft(v2, false);
  for (i = 0; i < n1; i++) {
    v1[i] *= v2[i];
  }
  fft(v1, true);
  for (i = 0; i < sz; i++) {
    if (l1 + l2 + i <= t + 1) {
      dpE[ind][l1 + l2 + i] += v1[i].real();
    }
  }
  return;
}
int main() {
  int i, j, k, t1, t2, t3, t4, n, m;
  double ans;
  precompute_powers();
  scanf("%d %d %d %d", &n, &m, &t, &x);
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      dis[i][j] = (i == j) ? 0 : 1e9;
    }
  }
  for (i = 0; i < m; i++) {
    scanf("%d %d %d", &t1, &t2, &t3);
    l[t1].push_back(i);
    cost[i] = t3;
    dest[i] = t2;
    dis[t1][t2] = t3;
    tots[i] = 1.0;
    for (j = 1; j <= t; j++) {
      scanf("%lf", &p[i][j]);
      p[i][j] /= 100000.0;
    }
  }
  for (k = 1; k <= n; k++) {
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++) {
        if (dis[i][k] + dis[k][j] < dis[i][j]) {
          dis[i][j] = dis[i][k] + dis[k][j];
        }
      }
    }
  }
  for (i = 1; i <= t + 1; i++) {
    for (j = 1; j <= n; j++) {
      dpV[j][i] = maxi;
    }
  }
  dpV[n][1] = 0;
  for (i = 1; i <= n - 1; i++) {
    dpV[i][1] = dis[i][n] + x;
  }
  for (i = 1; i <= t + 1; i++) {
    if (i >= 2) {
      for (j = 0; j < m; j++) {
        tots[j] -= p[j][i - 1];
        adder[j][i] = cost[j] + (tots[j] * (dis[dest[j]][n] + x));
        dpE[j][i] += cost[j] + (tots[j] * (dis[dest[j]][n] + x));
      }
      dpV[n][i] = 0;
      for (j = 1; j <= n - 1; j++) {
        for (auto it : l[j]) {
          dpV[j][i] = min(dpV[j][i], dpE[it][i]);
        }
      }
    }
    for (j = 0; j < m; j++) {
      if (i + 1 <= t + 1) {
        dpE[j][i + 1] += dpV[dest[j]][i] * p[j][1];
      }
      if (i + 2 <= t + 1) {
        dpE[j][i + 2] += dpV[dest[j]][i] * p[j][2];
      }
      for (k = 2; i % k == 0 && k + 1 <= t + 1; k *= 2) {
        convolve(i - k, i - 1, k + 1, min(2 * k, t + 1), j);
      }
    }
  }
  dpV[n][t + 1] = 0;
  for (i = 1; i <= n - 1; i++) {
    for (auto it : l[i]) {
      dpV[i][t + 1] = min(dpV[i][t + 1], dpE[it][t + 1]);
    }
  }
  ans = dpV[1][t + 1];
  printf("%.10lf\n", ans);
  return 0;
}