This page is still under construction.

Parts of this page are still being built. What you see may change.

Stomping Cats

Interview

Time limit2sMemory limit512 MB

Summary
Given cat counts per apartment in an n by m building, sum the fine a for every apartment whose upstairs neighbor has more than twice its cats.
Level

Easy2 of 10

Topics
Array, Implementation
Solved
No attempts yet

Problem

In a certain city, people kept complaining that they could not sleep. Every day, a large pile of complaints about certain people being too loud at night piled up at the relevant officials' office. Something had to be done. So at the next meeting, it was decided to pass a law banning loud noises after eleven o'clock at night.

Following bureaucratic tradition, the law had to spell out the concept of <>. After discussion, it was decided to ban, for example, playing musical instruments, moving furniture, and hammering nails at night.

Just as the law was about to be passed, one deputy noted that a refrigerator is not furniture, so moving it did not fall under the law. Other deputies also began to come up with additional prohibitions that had not originally been in the law. As a result, nighttime moans, creaks, dog barks, and the stomping of cats were banned.

A fine of aa rubles was introduced for violating the law.

Upon learning of the law, Petya decided to find out what fine could be imposed on the residents of his building. The building where Petya lives has nn floors, and each floor has mm apartments. The apartments are numbered from 1 to nmnm. If apartment number xx is on some floor that is not the top floor, then the apartment directly above it is number x+mx + m.

It is known that bib_i cats live in the ii-th apartment. Petya assumed that the residents of an apartment will complain about the neighbors above only if the cats above stomp substantially louder than their own. After conducting experiments, Petya decided that pp cats stomp substantially louder than qq cats if p>2qp > 2q.

Find the total fine the residents of this building will have to pay if everyone whose cats in the apartment directly above stomp substantially louder than their own cats complains about their upstairs neighbors and those neighbors are fined.

Input

The first line of the input file contains three integers nn, mm, aa: the number of floors, the number of apartments on each floor, and the fine amount (1≤n≤201 \le n \le 20, 1≤m≤101 \le m \le 10, 1≤a≤10001 \le a \le 1000). The next line contains nmnm integers b1,b2,…,bnmb_1, b_2, \ldots, b_{nm}, where bib_i is the number of cats in the ii-th apartment (1≤bi≤301 \le b_i \le 30).

Output

Print the total fine.

Hint

In the example, only the residents of apartment 6 have to pay the fine.

Examples1

  1. Example 1

    Input
    2 3 10
    3 5 2 4 10 5
    
    Expected output
    10