import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
static Scanner sc
= new Scanner
(System.
in);
{
int n, m;
n = sc.nextInt();
m = sc.nextInt();
double r = sc.nextDouble();
double[][] a = new double[n][m];
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
a[i][j] = sc.nextDouble();
}
}
double sum = 0;
for(int i = 0; i < n; i++){
double b = 0.5;
for(int j = 0; j < m; j++){
if(a[i][j] > 0){
b = a[i][j];
break;
}
}
sum
+= b
*Math.
pow(r, n
-i
-1); }
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBNYWluCnsKCXN0YXRpYyBTY2FubmVyIHNjID0gbmV3IFNjYW5uZXIoU3lzdGVtLmluKTsKCQoJcHVibGljIHN0YXRpYyB2b2lkIG1haW4gKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBqYXZhLmxhbmcuRXhjZXB0aW9uCgl7CgkJaW50IG4sIG07CgkJbiA9IHNjLm5leHRJbnQoKTsKCQltID0gc2MubmV4dEludCgpOwoJCWRvdWJsZSByID0gc2MubmV4dERvdWJsZSgpOwoJCWRvdWJsZVtdW10gYSA9IG5ldyBkb3VibGVbbl1bbV07CgkJZm9yKGludCBpID0gMDsgaSA8IG47IGkrKyl7CgkJCWZvcihpbnQgaiA9IDA7IGogPCBtOyBqKyspewoJCQkJYVtpXVtqXSA9IHNjLm5leHREb3VibGUoKTsKCQkJfQoJCX0KCQlkb3VibGUgc3VtID0gMDsKCQlmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKXsKCQkJZG91YmxlIGIgPSAwLjU7CgkJCWZvcihpbnQgaiA9IDA7IGogPCBtOyBqKyspewoJCQkJaWYoYVtpXVtqXSA+IDApewoJCQkJCWIgPSBhW2ldW2pdOwoJCQkJCWJyZWFrOwoJCQkJfQoJCQl9CgkJCXN1bSArPSBiKk1hdGgucG93KHIsIG4taS0xKTsKCQl9CgkJU3lzdGVtLm91dC5wcmludGxuKHN1bSk7Cgl9Cn0=