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;
namespace graph {
struct ForwardStar {
  inline ForwardStar(int n = 0, int edgeCapacity = -1) {
    init(n, edgeCapacity);
  }
  inline void init(int n, int edgeCapacity = -1) {
    if (edgeCapacity > 0) {
      nxtOut.reserve(edgeCapacity);
      toIdx.reserve(edgeCapacity);
    }
    _n = n;
    _edgeIdx = 0;
    lastOut.assign(_n, -1);
    nxtOut.clear();
    toIdx.clear();
  }
  inline void addDirected(int x, int y) {
    nxtOut.push_back(lastOut[x]);
    toIdx.push_back(y);
    lastOut[x] = _edgeIdx++;
  }
  vector<int> lastOut, nxtOut, toIdx;
  int _n, _edgeIdx;
};
template <typename EDGE_W>
struct ForwardStarEdgeWeighted : ForwardStar {
  inline ForwardStarEdgeWeighted(int n = 0, int edgeCapacity = -1) {
    init(n, edgeCapacity);
  }
  inline void init(int n, int edgeCapacity = -1) {
    ForwardStar::init(n, edgeCapacity);
    if (edgeCapacity > 0) {
      weights.reserve(edgeCapacity);
    }
  }
  inline void addDirected(int x, int y, EDGE_W&& w) {
    weights.push_back(std::move(w));
    ForwardStar::addDirected(x, y);
  }
  inline void spfa(int startIdx, const function<bool(int, int, int)>& updater) {
    static vector<bool> inQ;
    static queue<int> q;
    inQ.assign(_n, false);
    q.push(startIdx);
    inQ[startIdx] = true;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      inQ[u] = false;
      for (int i = (*this).lastOut[u]; i >= 0; i = (*this).nxtOut[i]) {
        int v = toIdx[i];
        if (updater(u, v, i)) {
          q.push(v);
          inQ[v] = true;
        }
      }
    }
  }
  vector<EDGE_W> weights;
};
}  // namespace graph
namespace math {
inline uint32_t nextPow2_32(uint32_t v) {
  if (!v) {
    return 1;
  }
  uint32_t res = 1U << (31 - __builtin_clz(v));
  return res == v ? res : res << 1;
}
template <typename T = double>
struct Complex {
  inline Complex(T _real = 0, T _imag = 0) : real(_real), imag(_imag) {}
  inline void operator+=(const Complex<T>& o) {
    real += o.real;
    imag += o.imag;
  }
  inline Complex<T> operator*(const Complex<T>& o) const {
    return Complex<T>(real * o.real - imag * o.imag,
                      real * o.imag + o.real * imag);
  }
  inline void operator*=(const Complex<T>& o) {
    T realCopy = real, oRealCopy = o.real;
    real = realCopy * oRealCopy - imag * o.imag;
    imag = realCopy * o.imag + imag * oRealCopy;
  }
  inline void operator/=(T scale) {
    real /= scale;
    imag /= scale;
  }
  inline void init(T _real = 0, T _imag = 0) {
    real = _real;
    imag = _imag;
  }
  inline void initConj(const Complex<T>& o) {
    real = o.real;
    imag = -o.imag;
  }
  inline void initPolar(T r, T theta) {
    real = r * cos(theta);
    imag = r * sin(theta);
  }
  inline void initSub(const Complex<T>& x, const Complex<T>& y) {
    real = x.real - y.real;
    imag = x.imag - y.imag;
  }
  T real, imag;
};
const long double PI = acos(static_cast<long double>(-1));
template <typename T = double>
struct FFTUtils {
  inline static FFTUtils& instance() {
    static FFTUtils instance;
    return instance;
  }
  inline void initCapacity(int capacity) {
    if (_revs.size() >= capacity) {
      return;
    }
    int pow2 = nextPow2_32(max(capacity, 2));
    _revs.reserve(pow2);
    _roots.reserve(pow2);
    if (_revs.size() < 2) {
      _revs.resize(2);
      _revs[0] = 0;
      _revs[1] = 1;
      _roots.resize(2);
      _roots[0].init(0, 0);
      _roots[1].init(1, 0);
    }
    int oldPow2 = _revs.size(), lgN = __builtin_ctz(pow2);
    _revs.resize(pow2);
    for (int i = 0; i < pow2; ++i) {
      _revs[i] = (_revs[i >> 1] >> 1) + ((i & 1) << (lgN - 1));
    }
    _roots.resize(pow2);
    for (int i = oldPow2; i < pow2; i <<= 1) {
      T baseAngle = PI / i;
      for (int j = i, k = 1; j < i << 1; j += 2, k += 2) {
        _roots[j] = _roots[j >> 1];
        _roots[j | 1].initPolar(1, baseAngle * k);
      }
    }
  }
  inline void fft(vector<Complex<T>>& cs, bool inverse, int n = -1) {
    int pow2 = nextPow2_32(n < 0 ? cs.size() : n);
    initCapacity(pow2);
    _expand(cs, pow2);
    if (inverse) {
      reverse(cs.begin() + 1, cs.begin() + pow2);
      for (int i = 0; i < pow2; ++i) {
        cs[i] /= pow2;
      }
    }
    int shift = __builtin_ctz(_revs.size()) - __builtin_ctz(pow2);
    for (int i = 0; i < pow2; ++i) {
      int j = _revs[i] >> shift;
      if (i < j) {
        swap(cs[i], cs[j]);
      }
    }
    for (int l = 1; l < pow2; l <<= 1) {
      for (int i = 0; i < pow2; i += l << 1) {
        for (int j = 0; j < l; ++j) {
          Complex<T> c = cs[i + j + l] * _roots[j + l];
          cs[i + j + l].initSub(cs[i + j], c);
          cs[i + j] += c;
        }
      }
    }
  }
  inline void _expand(vector<Complex<T>>& cs, int pow2) {
    int n = cs.size();
    cs.resize(pow2);
    for (size_t i = n; i < pow2; ++i) {
      cs[i].init(0, 0);
    }
  }
  vector<int> _revs;
  vector<Complex<T>> _roots;
};
template <typename T = double>
struct FFTMulUtils {
  inline static FFTMulUtils& instance() {
    static FFTMulUtils instance;
    return instance;
  }
  template <typename R>
  inline const vector<Complex<T>>& mulReal(const vector<R>& xs,
                                           const vector<R>& ys, bool cyclic) {
    static vector<Complex<T>> cs;
    if (xs.empty() || ys.empty()) {
      cs.resize(1);
      cs[0].init(0, 0);
      return cs;
    }
    int pow2 = nextPow2_32(cyclic ? max(xs.size(), ys.size())
                                  : xs.size() + ys.size() - 1);
    cs.resize(pow2);
    for (size_t i = 0; i < pow2; ++i) {
      cs[i].init(i < xs.size() ? xs[i] : 0, i < ys.size() ? ys[i] : 0);
    }
    auto& fft = FFTUtils<T>::instance();
    fft.fft(cs, false, pow2);
    for (int i = 0; i <= (pow2 >> 1); ++i) {
      int j = (pow2 - i) & (pow2 - 1);
      cs[i] *= cs[i];
      if (i != j) {
        cs[j] *= cs[j];
        cs[j].imag = -cs[j].imag;
        cs[j].initSub(cs[i], cs[j]);
        cs[j] /= pow2 << 2;
        swap(cs[j].real, cs[j].imag);
        cs[j].imag = -cs[j].imag;
      } else {
        cs[j].real = cs[j].imag / (pow2 << 1);
        cs[j].imag = 0;
      }
      cs[i].initConj(cs[j]);
    }
    fft.fft(cs, false, pow2);
    if (is_integral<R>::value) {
      _shrink(cs);
    }
    return cs;
  }
  template <typename R>
  inline void mulInlineReal(vector<R>& xs, const vector<R>& ys, bool cyclic) {
    const auto& cs = mulReal(xs, ys, cyclic);
    xs.resize(cs.size());
    for (size_t i = 0; i < cs.size(); ++i) {
      xs[i] = is_integral<R>::value ? cs[i].real + 0.5 : cs[i].real;
    }
  }
  inline void _shrink(vector<Complex<T>>& cs) {
    for (; cs.size() > 1; cs.pop_back()) {
      T real = cs.back().real;
      if (real < -0.5 || real > 0.5) {
        break;
      }
    }
  }
};
template <typename V, typename FFT_T = long double>
struct FFTPoly : public vector<V> {
  inline void operator*=(const FFTPoly& o) {
    FFTMulUtils<FFT_T>::instance().mulInlineReal(*this, o, false);
  }
};
}  // namespace math
const int MAXN = 50;
using Poly = math::FFTPoly<double>;
struct Edge {
  int cost;
  Poly timeCost;
};
graph::ForwardStarEdgeWeighted<Edge> fs;
Poly costs[MAXN];
int main() {
  int n, m, T, penalty;
  scanf("%d%d%d%d", &n, &m, &T, &penalty);
  fs.init(n, m);
  for (int i = (0); i < (m); ++i) {
    Edge edge;
    int x, y;
    scanf("%d%d%d", &x, &y, &edge.cost);
    --x;
    --y;
    edge.timeCost.resize(T);
    for (int j = T - 1; j >= 0; --j) {
      scanf("%lf", &edge.timeCost[j]);
      edge.timeCost[j] /= 100000;
    }
    fs.addDirected(y, x, std::move(edge));
  }
  int T2p2 = (T << 1) + 2;
  for (int i = (0); i < (n - 1); ++i) {
    costs[i].assign(T2p2, 1E100);
  }
  costs[n - 1].resize(T2p2);
  for (int i = (0); i < (T + 1); ++i) {
    costs[n - 1][i] = 0;
  }
  for (int i = (T + 1); i < (T2p2); ++i) {
    costs[n - 1][i] = penalty;
  }
  fs.spfa(n - 1, [&](int fromIdx, int toIdx, int edgeIdx) {
    static Poly newCost;
    const auto& weight = fs.weights[edgeIdx];
    newCost = costs[fromIdx];
    newCost *= weight.timeCost;
    auto& targetCosts = costs[toIdx];
    bool updated = false;
    for (int i = (0); i < (T + 2); ++i) {
      if (targetCosts[i] > newCost[i + T] + weight.cost) {
        updated = true;
        targetCosts[i] = newCost[i + T] + weight.cost;
      }
    }
    for (int i = (T + 2); i < (T2p2); ++i) {
      targetCosts[i] = targetCosts[i - 1];
    }
    return updated;
  });
  printf("%.13lf\n", costs[0][0]);
}