#include <iostream>
#include <math.h>
using namespace std;
int main() {
int n,m; scanf("%d %d",&n,&m);
double r; scanf("%lf",&r);
double inp, sum = 0;
for(int i = 0; i < n; i++) {
double b = 0.5;
bool t = true;
for(int j = 0; j < m; j++){
scanf("%lf", &inp);
if(inp > 0 && t) {
t = false;
b = inp;
}
}
sum += b*pow(r,n-i-1);
}
printf("%lf",sum);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWF0aC5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CglpbnQgbixtOyBzY2FuZigiJWQgJWQiLCZuLCZtKTsKCWRvdWJsZSByOyBzY2FuZigiJWxmIiwmcik7Cglkb3VibGUgaW5wLCBzdW0gPSAwOwoJZm9yKGludCBpID0gMDsgaSA8IG47IGkrKykgewoJCWRvdWJsZSBiID0gMC41OwoJCWJvb2wgdCA9IHRydWU7CgkJZm9yKGludCBqID0gMDsgaiA8IG07IGorKyl7CgkJCXNjYW5mKCIlbGYiLCAmaW5wKTsKCQkJaWYoaW5wID4gMCAmJiB0KSB7CgkJCQl0ID0gZmFsc2U7CgkJCQliID0gaW5wOwoJCQl9CgkJfQoJCXN1bSArPSBiKnBvdyhyLG4taS0xKTsKCX0KCXByaW50ZigiJWxmIixzdW0pOwoJcmV0dXJuIDA7Cn0=