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 double pi = 3.1415926535897932384626;
const int oo = 0x3f3f3f3f;
template <typename T>
bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
struct comp {
  double a, b;
  comp() {}
  comp(const double &_a, const double &_b) : a(_a), b(_b) {}
  friend comp operator+(const comp &a, const comp &b) {
    return comp(a.a + b.a, a.b + b.b);
  }
  friend comp operator-(const comp &a, const comp &b) {
    return comp(a.a - b.a, a.b - b.b);
  }
  friend comp operator*(const comp &a, const comp &b) {
    return comp(a.a * b.a - a.b * b.b, a.a * b.b + a.b * b.a);
  }
};
const int maxN = 65536;
const int maxn = 50, maxm = 100, maxt = 20000;
const int max0 = 3000;
struct edge {
  int id, g;
  double P[maxt + 5];
  int nxt;
  edge() { memset(P, 0, sizeof P); }
  edge(const int &_id, const int &_g, double *_P, const int &_nxt)
      : id(_id), g(_g), nxt(_nxt) {
    memcpy(P, _P, sizeof P);
  }
};
int st[maxn + 5];
edge e[(maxm << 1) + 5];
int en = 0;
int f[maxn + 5][maxn + 5];
int n, m, T, X;
vector<int> reve[maxn + 5];
inline void init() {
  memset(st, -1, sizeof st), en = 0;
  memset(f, oo, sizeof f);
  scanf("%d%d%d%d", &n, &m, &T, &X);
  for (int i = (0), _end_ = (n); i < _end_; ++i) f[i][i] = 0;
  for (int i = (0), _end_ = (m); i < _end_; ++i) {
    static int x, y, z;
    scanf("%d%d%d", &x, &y, &z), --x, --y;
    reve[y].push_back(en);
    chkmin(f[x][y], z);
    e[en].id = y;
    e[en].g = z;
    e[en].nxt = st[x];
    for (int j = (1), _end_ = (T + 1); j < _end_; ++j) {
      static int x;
      scanf("%d", &x);
      e[en].P[j] = double(x) / 100000;
    }
    st[x] = en++;
  }
}
comp tmp[maxN + 5], tmp0[maxN + 5], w[maxN + 5];
int bitrev[maxN + 5];
double dp[maxm + 5][maxN + 5];
double best[maxn + 5][maxN + 5];
void fft(comp *a, const int &n) {
  for (int i = (0), _end_ = (n); i < _end_; ++i)
    if (i < bitrev[i]) swap(a[i], a[bitrev[i]]);
  for (int i = 1, len = n >> 1; i < n; i <<= 1, len >>= 1)
    for (int j = 0; j < n; j += (i << 1)) {
      comp *l = a + j, *r = a + j + i;
      comp *w0 = w;
      for (int k = 0; k < i; ++k, ++l, ++r, w0 += len) {
        comp s = *l, t = *r * *w0;
        *l = s + t, *r = s - t;
      }
    }
}
inline void calc(const int &l, const int &mid, const int &r) {
  int N = mid - l + min(T, r - l - 1);
  while (N & (N - 1)) ++N;
  if (r - l <= max0) {
    for (int x = (0), _end_ = (n); x < _end_; ++x) {
      for (int i = st[x]; i != -1; i = e[i].nxt)
        for (int k = (l), _end_ = (mid); k < _end_; ++k)
          chkmin(best[x][k], dp[i][k] + e[i].g);
      for (auto i : reve[x]) {
        for (int j = (l), _end_ = (mid); j < _end_; ++j)
          for (int k = (max(1, mid - j)), _end_ = (min(r - j, T + 1));
               k < _end_; ++k)
            dp[i][j + k] += best[x][j] * e[i].P[k];
      }
    }
    return;
  }
  comp step = comp(cos(2 * pi / N), sin(2 * pi / N));
  w[0] = comp(1, 0);
  for (int i = (0), _end_ = (N); i < _end_; ++i) w[i + 1] = w[i] * step;
  int L = 0;
  for (L = 0; (1 << L) < N; ++L)
    ;
  for (int i = (0), _end_ = (N); i < _end_; ++i)
    bitrev[i] = (bitrev[i >> 1] >> 1) | ((i & 1) << (L - 1));
  for (int x = (0), _end_ = (n); x < _end_; ++x) {
    for (int i = st[x]; i != -1; i = e[i].nxt)
      for (int k = (l), _end_ = (mid); k < _end_; ++k)
        chkmin(best[x][k], dp[i][k] + e[i].g);
    for (int j = (0), _end_ = (N); j < _end_; ++j) tmp[j] = comp(0, 0);
    for (int j = (l), _end_ = (mid); j < _end_; ++j)
      tmp[j - l] = comp(best[x][j], 0);
    fft(tmp, N);
    for (auto i : reve[x]) {
      for (int j = (0), _end_ = (N); j < _end_; ++j) tmp0[j] = comp(0, 0);
      for (int j = (1), _end_ = (min(T + 1, r - l)); j < _end_; ++j)
        tmp0[j] = comp(e[i].P[j], 0);
      fft(tmp0, N);
      for (int j = (0), _end_ = (N); j < _end_; ++j) tmp0[j] = tmp0[j] * tmp[j];
      reverse(w + 1, w + N);
      fft(tmp0, N);
      reverse(w + 1, w + N);
      for (int j = (mid), _end_ = (r); j < _end_; ++j)
        dp[i][j] += tmp0[j - l].a / N;
    }
  }
}
inline void work(const int &l, const int &r) {
  if (r - l <= 1) {
    for (int x = (0), _end_ = (n); x < _end_; ++x)
      for (int i = st[x]; i != -1; i = e[i].nxt)
        for (int k = (l), _end_ = (r); k < _end_; ++k)
          chkmin(best[x][k], dp[i][k] + e[i].g);
    return;
  }
  int mid = (l + r) >> 1;
  work(l, mid);
  calc(l, mid, r);
  work(mid, r);
}
inline void solve() {
  for (int k = (0), _end_ = (n); k < _end_; ++k)
    for (int i = (0), _end_ = (n); i < _end_; ++i)
      for (int j = (0), _end_ = (n); j < _end_; ++j)
        chkmin(f[i][j], f[i][k] + f[k][j]);
  for (int i = (0), _end_ = (en); i < _end_; ++i)
    for (int j = (0), _end_ = (T << 1 | 1); j < _end_; ++j)
      if (j < T)
        dp[i][j] = f[e[i].id][n - 1] + X;
      else
        dp[i][j] = 0;
  for (int i = (0), _end_ = (n); i < _end_; ++i)
    for (int j = (0), _end_ = (T << 1 | 1); j < _end_; ++j)
      best[i][j] = (i == n - 1 ? (j < T ? X : 0) : oo);
  calc(0, T, T << 1 | 1);
  work(T, T << 1 | 1);
}
inline void output() { printf("%.10f\n", best[0][T << 1]); }
int main() {
  init();
  solve();
  output();
  return 0;
}