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 JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class Problem553E {
  class Edge {
    public int u, v;
    public int cost;
    public double[] p;
    public double[] pSum;
    OnlineConvolution calc;
  }
  
  class Graph {
    @SuppressWarnings("unchecked")
    public Graph(int n) {
      edges = new List[n];
      for (int i = 0; i < n; i++) {
        edges[i] = new ArrayList<>();
      }
    }

    public void addEdge(Edge e) {
      edges[e.u].add(e);
    }
    
    public List<Edge>[] edges;
  }
  
  public static class OnlineConvolution {
    public OnlineConvolution(double[] b) {
      int m = 0;
      while ((1 << m) < b.length) {
        m++;
      }
      m++;
      this.a = new double[1 << m];
      this.b = new double[1 << m];
      this.c = new double[(2 << m)];
      System.arraycopy(b, 0, this.b, 0, b.length);
      
      bFourier = new HashMap<Integer, double[][]>();
    }
    
    // a.length must be a power of 2.
    public static double[][] fft(double[][] input, boolean inverse) {
      int n = input[0].length;
      int m = 0;
      while ((1 << m) < n) {
        m++;
      }
      if ((1 << m) != n) {
        throw new IllegalArgumentException();
      }
      
      double[][] result = new double[2][n];
      double[] fr = result[0];
      double[] fi = result[1];
      for (int i = 0; i < n; i++) {
        int cur = 0;
        for (int j = 0; j < m; j++) {
          if ((i & (1 << j)) != 0) {
            cur |= (1 << (m - j - 1));
          }
        }
        fr[cur] = input[0][i];
        fi[cur] = input[1][i];
      }
      
      double[] wr = tmpArrays7[m];  // new double[n];
      double[] wi = tmpArrays8[m];  // new double[n];
      double gr = Math.cos(2 * Math.PI / n * (inverse ? -1.0 : 1.0));
      double gi = Math.sin(2 * Math.PI / n * (inverse ? -1.0 : 1.0));
      wr[0] = 1; wi[0] = 0;
      for (int i = 1; i < n; i++) {
        if ((i & 127) == 0) {
          // Correct values for better precision.
          wr[i] = Math.cos(2 * Math.PI * i / n * (inverse ? -1.0 : 1.0));
          wi[i] = Math.sin(2 * Math.PI * i / n * (inverse ? -1.0 : 1.0));
        } else {
          wr[i] = wr[i - 1] * gr - wi[i - 1] * gi;
          wi[i] = wr[i - 1] * gi + wi[i - 1] * gr;
        }
      }
      for (int level = 0; level < m; level++) {
        int blockSize = 1 << level;
        for (int offset = 0; offset < n; offset += 2 * blockSize) {
          for (int i1 = offset, i2 = offset + blockSize; i1 < offset + blockSize; i1++, i2++) {
            double cr = wr[(i1 - offset) << (m - level - 1)];
            double ci = wi[(i1 - offset) << (m - level - 1)];
            
            // t := w * f[offset + blockSize + i].
            // Use faster complex multiplication.
            double p1 = cr * fr[i2];
            double p2 = ci * fi[i2];
            double p3 = (cr + ci) * (fr[i2] + fi[i2]);
            
            double tr = p1 - p2;
            double ti = p3 - p1 - p2;
            fr[i2] = fr[i1] - tr;
            fi[i2] = fi[i1] - ti;
            fr[i1] += tr;
            fi[i1] += ti;
          }
        }
      }
      
      if (inverse) {
        for (int i = 0; i < n; i++) {
          fr[i] /= n;
          fi[i] /= n;
        }
      }
      
      return result;
    }
    
    void add(double value) {
      if (index >= a.length) {
        double[] tmp = new double[a.length * 2];
        System.arraycopy(a, 0, tmp, 0, a.length);
        a = tmp;
      }
      if (index + b.length >= c.length) {
        double[] tmp = new double[c.length * 2];
        System.arraycopy(c, 0, tmp, 0, c.length);
        c = tmp;
      }
      
      a[index] = value;
      c[index] += value * b[0];
      if (b.length == 1) {
        index++;
        return;
      }
      c[index + 1] += value * b[1];
      
      for (int i = 1; (1 << i) <= index; i++) {
        int size = (1 << i);
        if (size >= b.length) {
          break;
        }
        if ((index & (size - 1)) == 0) {
          update(index - size, size, size);
        } else {
          break;
        }
      }
      
      index++;
      return;
    }
    
    public double value() {
      return index == 0 ? 0.0 : c[index - 1];
    }
    
    private void update(int posa, int posb, int size) {
      if (size <= 128) {
        for (int i = posa; i < posa + size; i++) {
          for (int j = posb; j < posb + size; j++) {
            c[i + j] += a[i] * b[j];
          }
        }
      } else {
        int m = 0;
        while ((1 << m) < size) {
          m++;
        }
        
//        double[][] inputFourier = new double[2][2 * size];
        double[][] inputFourier = new double[2][];
        inputFourier[0] = tmpArrays1[m + 1];
        inputFourier[1] = tmpArrays2[m + 1];
        System.arraycopy(a, posa, inputFourier[0], 0, size);
        double[][] fourierA = fft(inputFourier, false);

        if (bFourier.containsKey(size)) {
        } else {
          System.arraycopy(b, size, inputFourier[0], 0, size);
          bFourier.put(size, fft(inputFourier, false));
        }
        double[][] fourierB = bFourier.get(size);
        
//        double[][] product = new double[2][2 * size];
        double[][] product = new double[2][];
        product[0] = tmpArrays3[m + 1];
        product[1] = tmpArrays4[m + 1];
        for (int i = 0; i < 2 * size; i++) {
          product[0][i] = fourierA[0][i] * fourierB[0][i] - fourierA[1][i] * fourierB[1][i]; 
          product[1][i] = fourierA[0][i] * fourierB[1][i] + fourierA[1][i] * fourierB[0][i]; 
        }
        
        double[][] resultFourier = fft(product, true);
        for (int i = 0; i < 2 * size - 1; i++) {
          c[posa + posb + i] += resultFourier[0][i];
        }
      }
    }

    private double[] a;
    private double[] c;
    private int index;
    private Map<Integer, double[][]> bFourier;
    private final double[] b;
    
    static double[][] tmpArrays1;
    static double[][] tmpArrays2;
    static double[][] tmpArrays3;
    static double[][] tmpArrays4;
    static double[][] tmpArrays7;
    static double[][] tmpArrays8;
    static {
      tmpArrays1 = new double[16][];
      tmpArrays2 = new double[16][];
      tmpArrays3 = new double[16][];
      tmpArrays4 = new double[16][];
      tmpArrays7 = new double[16][];
      tmpArrays8 = new double[16][];
      for (int i = 0; i < 16; i++) {
        tmpArrays1[i] = new double[1 << i];
        tmpArrays2[i] = new double[1 << i];
        tmpArrays3[i] = new double[1 << i];
        tmpArrays4[i] = new double[1 << i];
        tmpArrays7[i] = new double[1 << i];
        tmpArrays8[i] = new double[1 << i];
      }
    }
  }
  
  private void solve() throws IOException {
//    int n = 50;
//    int m = 100;
//    int t = 20000;
//    int x = 1000000;
    
    int n = nextInt();
    int m = nextInt();
    int t = nextInt();
    int x = nextInt();
    Graph g = new Graph(n);
    for (int i = 0; i < m; i++) {
      Edge e = new Edge();
//      e.u = i % n;
//      e.v = (3 * i) % n;
//      e.cost = 239;
      e.u = nextInt() - 1;
      e.v = nextInt() - 1;
      e.cost = nextInt();
      e.p = new double[t];
      e.pSum = new double[t + 1];
      for (int j = 0; j < t; j++) {
        e.p[j] = nextInt() / 100000.0;
//        e.p[j] = 1.0 / 20000.0;
        if (j >= 1) {
          e.pSum[j] = e.pSum[j - 1] + e.p[j - 1];
        }
      }
      e.pSum[t] = e.pSum[t - 1] + e.p[t - 1];
      e.calc = new OnlineConvolution(e.p);
      g.addEdge(e);
    }
    
    double[][] answer = new double[t + 2][n];
    Arrays.fill(answer[t + 1], 1e100);
    answer[t + 1][n - 1] = x;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        for (Edge e : g.edges[j]) {
          answer[t + 1][e.u] = Math.min(answer[t + 1][e.u], e.cost + answer[t + 1][e.v]);
        }
      }
    }
    
    for (int time = t; time >= 0; time--) {
//      if (time % 100 == 0) {
//        System.out.println("Time=" + time + " of " + t);
//      }
      Arrays.fill(answer[time], 1e100);
      answer[time][n - 1] = 0.0;
      for (int i = 0; i < n; i++) {
        for (Edge e : g.edges[i]) {
          double cur = e.cost;
          cur += (1.0 - e.pSum[t - time]) * answer[t + 1][e.v];
          cur += e.calc.value();
          answer[time][e.u] = Math.min(answer[time][e.u], cur);
        }
      }
      for (int i = 0; i < n; i++) {
        for (Edge e : g.edges[i]) {
          e.calc.add(answer[time][e.v]);
        }
      }
    }
    out.println(answer[0][0]);
  }
  
  public static void main(String[] args) {
    new Problem553E().run();
  }

  private void run() {
    try {
      in = new BufferedReader(new InputStreamReader(System.in));
      out = new PrintWriter(new OutputStreamWriter(System.out));
//      long startTime = System.nanoTime();
      solve();
//      System.out.println("Total time: " + (System.nanoTime() - startTime) / 1000000 + " ms"); 
      in.close();
      out.close();
    } catch (IOException e) {
      System.exit(1);
    }
  }
  
  private int nextInt() throws IOException {
    return Integer.parseInt(next());
  }
  
  private String next() throws IOException {
    while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
      String line = in.readLine();
      if (line == null) {
        throw new IllegalStateException("EOF");
      }
      stringTokenizer = new StringTokenizer(line);
    }
    return stringTokenizer.nextToken();
  }
  
  private BufferedReader in;
  private PrintWriter out;
  private StringTokenizer stringTokenizer;
}