Under construction

Still being built. Things may change

House Plates

Time limit2sMemory limit1024 MB

Summary
Given house numbers on each street, find the total cost of plates when each binary 0 digit costs a rubles and each binary 1 digit costs b rubles.
Level

Easy2 of 10

Topics
Implementation, Math
Solved
No attempts yet

Problem

A country plans to build a programmer city called Oskolkovo. The city will be large. It will have NN streets, and each street has aia_i houses. The government decided to use an innovation: instead of ordinary house number plates, the plates will show house numbers written in binary.

After the numbering plan was approved, a tender was held for making plates with the digits 0 and 1. The winning company makes a plate with the digit 0 for aa rubles and a plate with the digit 1 for bb rubles. The government wants to know the cost of making the plates for the houses.

Input

The first line contains a natural number NN (1≤N≤1001 \le N \le 100) and aa, bb (1≤a,b≤1001 \le a, b \le 100). NN is the number of streets, and aa and bb are the costs of making the digits 0 and 1.

Each of the next NN lines contains a natural number aia_i (1≤ai≤1001 \le a_i \le 100), the number of houses on that street. After that, the line contains aia_i natural numbers cjc_j (1≤cj≤1001 \le c_j \le 100), the house numbers on that street that need plates. A house may need more than one plate.

Output

Output one natural number: the cost of making the plates.

Examples1

  1. Example 1

    Input
    1 1 2
    3 2 2 3
    
    Expected output
    10