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;
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
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; }
};
const double PI = 4 * atan(1);
const int LG = 19;
const int maxn = (1 << LG);
base W[maxn >> 1], invW[maxn >> 1];
void precompute_powers() {
  for (int i = 0; i < maxn / 2; i++) {
    double ang = (2 * PI * i) / maxn;
    double _cos = cos(ang), _sin = sin(ang);
    W[i] = base(_cos, _sin);
    invW[i] = base(_cos, -_sin);
  }
}
void fft(vector<base>& a, bool invert) {
  int n = (int)a.size();
  for (int i = 1, j = 0; i < n; ++i) {
    int bit = n >> 1;
    for (; j >= bit; bit >>= 1) j -= bit;
    j += bit;
    if (i < j) swap(a[i], a[j]);
  }
  for (int len = 2; len <= n; len <<= 1) {
    for (int i = 0; i < n; i += len) {
      int ind = 0, add = maxn / len;
      for (int j = 0; j < len / 2; ++j) {
        base u = a[i + j],
             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 < n; ++i) a[i] /= n;
}
const int N = 52, M = 101, TMAX = 200002;
int n, e, T, X, dist[N];
vector<pair<pair<int, int>, int> > edge_list;
vector<vector<double> > probs;
vector<pair<int, int> > rev_adj[N];
vector<int> adj[N];
double DP_V[N][TMAX], DP_E[M][TMAX], tot_prob[M];
void convolve(int l1, int r1, int l2, int r2, int e) {
  if (l1 > r1 || l2 > r2) return;
  int v = edge_list[e].first.second, sz1 = r1 - l1 + 1, sz2 = r2 - l2 + 1;
  int sz = sz1 + sz2 - 1;
  int n = 1;
  while (n < sz) n *= 2;
  vector<base> A(n, 0), B(n, 0);
  for (int i = l1; i <= r1; i++) A[i - l1] = DP_V[v][i];
  for (int i = l2; i <= r2; i++) B[i - l2] = probs[e][i];
  fft(A, false);
  fft(B, false);
  for (int i = 0; i < n; i++) A[i] *= B[i];
  fft(A, true);
  for (int i = 0; i < sz; i++) {
    int idx = l1 + l2 + i;
    if (idx <= T) DP_E[e][idx] += A[i].x;
  }
}
int main() {
  precompute_powers();
  scanf("%d%d%d%d", &n, &e, &T, &X);
  edge_list.resize(e);
  probs.resize(e);
  for (int i = 0; i < e; i++) {
    scanf("%d%d%d", &edge_list[i].first.first, &edge_list[i].first.second,
          &edge_list[i].second);
    adj[edge_list[i].first.first].push_back(i);
    probs[i].resize(T + 1);
    probs[i][0] = 0.0;
    for (int t = 1; t <= T; t++) {
      scanf("%lf", &probs[i][t]);
      probs[i][t] /= 100000.00;
    }
    tot_prob[i] = 1.0;
    rev_adj[edge_list[i].first.second].push_back(
        pair<int, int>(edge_list[i].first.first, edge_list[i].second));
  }
  for (int i = 1; i <= n; i++) dist[i] = (1000000007LL);
  priority_queue<pair<int, int> > pq;
  dist[n] = 0;
  pq.push(pair<int, int>(0, n));
  while (!pq.empty()) {
    int v = pq.top().second;
    int d = -pq.top().first;
    pq.pop();
    if (d > dist[v]) continue;
    for (auto it : rev_adj[v]) {
      int vv = it.first, dd = d + it.second;
      if (dd < dist[vv]) {
        dist[vv] = dd;
        pq.push(pair<int, int>(-dd, vv));
      }
    }
  }
  for (int i = 1; i <= n - 1; i++) DP_V[i][0] = dist[i] + X;
  DP_V[n][0] = 0;
  for (int j = 0; j < e; j++) {
    int b = edge_list[j].first.second;
    DP_E[j][1] += DP_V[b][0] * probs[j][1];
    DP_E[j][2] += DP_V[b][0] * probs[j][2];
  }
  for (int t = 1; t <= T; t++) {
    for (int j = 0; j < e; j++) {
      tot_prob[j] -= probs[j][t];
      int c = edge_list[j].second, b = edge_list[j].first.second;
      DP_E[j][t] += c + tot_prob[j] * (dist[b] + X);
    }
    for (int i = 1; i <= n - 1; i++) {
      DP_V[i][t] = 1e10;
      for (auto it : adj[i]) DP_V[i][t] = min(DP_V[i][t], DP_E[it][t]);
    }
    DP_V[n][t] = 0.0;
    for (int j = 0; j < e; j++) {
      int b = edge_list[j].first.second;
      if (t + 1 <= T) DP_E[j][t + 1] += DP_V[b][t] * probs[j][1];
      if (t + 2 <= T) DP_E[j][t + 2] += DP_V[b][t] * probs[j][2];
      for (int p = 2; t % p == 0 && p + 1 <= T; p *= 2) {
        convolve(t - p, t - 1, p + 1, min(T, 2 * p), j);
      }
    }
  }
  printf("%.7lf\n", DP_V[1][T]);
  return 0;
}