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 MAXLOG = 16, MAXT = (1 << MAXLOG) + 5;
struct myComplex {
  double real;
  double img;
  myComplex() {}
  myComplex(double _real, double _img) {
    real = _real;
    img = _img;
  }
};
myComplex operator+(const myComplex &a, const myComplex &b) {
  return myComplex(a.real + b.real, a.img + b.img);
}
myComplex operator-(const myComplex &a, const myComplex &b) {
  return myComplex(a.real - b.real, a.img - b.img);
}
myComplex operator*(const myComplex &a, const myComplex &b) {
  return myComplex(a.real * b.real - a.img * b.img,
                   a.real * b.img + a.img * b.real);
}
void operator+=(myComplex &a, const myComplex &b) {
  a.real += b.real;
  a.img += b.img;
}
int KEKLOL228[MAXLOG][MAXT];
myComplex pows[MAXLOG][MAXT], revPows[MAXLOG][MAXT];
int reverseNumber(int x, int len) {
  int res = 0;
  for (int i = 0; i < len; ++i) {
    if (x & (1 << i)) {
      res |= (1 << (len - i - 1));
    }
  }
  return res;
}
void precalc() {
  for (int i = 0; i < MAXLOG; ++i) {
    pows[i][0] = myComplex(1, 0);
    double angle = 2 * acos(-1.0) / (1 << i);
    myComplex go(cos(angle), sin(angle));
    for (int j = 1; j < MAXT; ++j) {
      pows[i][j] = pows[i][j - 1] * go;
    }
  }
  for (int i = 0; i < MAXLOG; ++i) {
    revPows[i][0] = myComplex(1, 0);
    double angle = -2 * acos(-1.0) / (1 << i);
    myComplex go(cos(angle), sin(angle));
    for (int j = 1; j < MAXT; ++j) {
      revPows[i][j] = revPows[i][j - 1] * go;
    }
  }
  for (int i = 0; i < MAXLOG; ++i) {
    for (int j = 0; j < MAXT; ++j) {
      KEKLOL228[i][j] = reverseNumber(j, i);
    }
  }
}
myComplex ctmpa[MAXT], ctmpb[MAXT], ctmpc[MAXT];
double tmpd[MAXT];
void FFT(myComplex *a, int n, bool inv) {
  int m = 0;
  while ((1 << m) < n) m++;
  n = (1 << m);
  for (int i = 0; i < n; ++i) {
    if (i < KEKLOL228[m][i]) {
      swap(a[i], a[KEKLOL228[m][i]]);
    }
  }
  int curLog = 1;
  for (int len = 2; len <= n; len <<= 1) {
    int goLen = len >> 1;
    for (int i = 0; i < n; i += len) {
      myComplex tmp;
      myComplex *pu = a + i, *pv = a + i + goLen, *togo = pv,
                *pw = pows[curLog];
      assert(curLog < MAXLOG);
      if (inv) {
        pw = revPows[curLog];
      }
      while (pu != togo) {
        tmp = *pv * *pw;
        *pv = *pu - tmp;
        *pu += tmp;
        ++pu;
        ++pv;
        ++pw;
      }
    }
    curLog++;
  }
  if (inv) {
    for (int i = 0; i < n; ++i) {
      a[i].real /= n;
      a[i].img /= n;
    }
  }
}
void mul(double *a, int n, double *b, int m, double *res) {
  int len = n + m;
  int goLog = 0;
  while ((1 << goLog) < len) goLog++;
  len = (1 << goLog);
  for (int i = 0; i < len; ++i) {
    if (i < n) {
      ctmpa[i] = myComplex(a[i], 0);
    } else {
      ctmpa[i] = myComplex(0, 0);
    }
    if (i < m) {
      ctmpb[i] = myComplex(b[i], 0);
    } else {
      ctmpb[i] = myComplex(0, 0);
    }
  }
  FFT(ctmpa, len, false);
  FFT(ctmpb, len, false);
  for (int i = 0; i < len; ++i) {
    ctmpa[i] = ctmpa[i] * ctmpb[i];
  }
  FFT(ctmpa, len, true);
  assert(len < MAXT);
  for (int i = 0; i < len; ++i) {
    res[i] = ctmpa[i].real;
  }
}
const double DINF = 1e100;
const int INF = (int)1e9 + 7;
const int MAXM = 107;
const int MAXN = 57;
int a[MAXM], b[MAXM], c[MAXM];
double p[MAXM][MAXT];
double sumProb[MAXM][MAXT];
double dp[MAXT][MAXN], dpEdge[MAXT][MAXM];
double dp0[MAXT];
double dist[MAXN][MAXN];
vector<int> g[MAXN];
double tmpa[MAXT], tmpb[MAXT], tmpc[MAXT];
int main() {
  precalc();
  int n, m, t, x;
  scanf("%d %d %d %d", &n, &m, &t, &x);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      dist[i][j] = DINF;
    }
    dist[i][i] = 0;
  }
  for (int i = 0; i < m; ++i) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
    a[i]--;
    b[i]--;
    dist[a[i]][b[i]] = min(dist[a[i]][b[i]], (double)c[i]);
    for (int j = 1; j <= t; ++j) {
      int x;
      scanf("%d", &x);
      p[i][j] = 1.0 * x / 100000;
    }
    for (int j = t; j >= 0; --j) {
      sumProb[i][j] = sumProb[i][j + 1] + p[i][j];
    }
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  for (int i = 0; i <= t + 1; ++i) {
    for (int j = 0; j <= n + 1; ++j) {
      dp[i][j] = DINF;
    }
    dp[i][n - 1] = 0;
  }
  for (int i = 0; i < n; ++i) {
    dp[0][i] = dist[i][n - 1];
  }
  for (int i = 0; i < n; ++i) {
    dp0[i] = x;
  }
  for (int i = 0; i < n - 1; ++i) {
    dp0[i] += dp[0][i];
    dp[0][i] += x;
  }
  double res = DINF;
  for (int i = 0; i < t; ++i) {
    int k = 0, tmp = i + 1;
    while (tmp % 2 == 0 && tmp != 0) {
      k++;
      tmp >>= 1;
    }
    for (int j = 0; j < n - 1; ++j) {
      dp[i + 1][j] = DINF;
    }
    for (int j = 0; j < m; ++j) {
      dpEdge[i][j] += p[j][0] * dp[i][b[j]];
      dpEdge[i + 1][j] += p[j][1] * dp[i][b[j]];
      for (int pw = 1; pw <= k; ++pw) {
        int ptr1 = 0;
        int ptr2 = 0;
        for (int pos = i + 1 - (1 << pw); pos <= i; ++pos) {
          tmpa[ptr1] = dp[pos][b[j]];
          ptr1++;
          tmpb[ptr2] = p[j][(1 << pw) + (1 << pw) + pos - i - 1];
          ptr2++;
        }
        mul(tmpa, ptr1, tmpb, ptr2, tmpc);
        for (int pos = 0; pos < (1 << (pw + 1)); ++pos) {
          dpEdge[pos + i + 1][j] += tmpc[pos];
          assert(pos + i + 1 < MAXT);
        }
      }
      dpEdge[i + 1][j] += sumProb[j][i + 2] * dp0[b[j]];
      dp[i + 1][a[j]] = min(dp[i + 1][a[j]], dpEdge[i + 1][j] + c[j]);
    }
    res = min(res, dp[i][0]);
  }
  res = min(res, dp[t][0]);
  printf("%.20lf\n", res);
  return 0;
}