PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000125. Lát lại quảng trường (New Theatre Square)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Lát lại quảng trường (New Theatre Square)

New Theatre Square

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

An n×mn\times m board contains white cells . that must be covered and blocked cells * that cannot be covered. A single horizontal 1×11\times1 tile costs xx and a horizontal 1×21\times2 tile costs yy. Cover every white cell without overlap for minimum cost.

Input

The first line contains n,m,x,yn,m,x,y. Then follow nn strings of length mm, each containing only . and *.

Output

Print the minimum tiling cost.

Subtasks

  • Subtask 1 (20 points): 1≤n≤51\le n\le 5; 1≤m≤10001\le m\le1000; 1≤x,y≤10001\le x,y\le1000; each row has exactly mm characters from . hoặc *.
  • Subtask 2 (30 points): 1≤n≤251\le n\le 25; 1≤m≤10001\le m\le1000; 1≤x,y≤10001\le x,y\le1000; each row has exactly mm characters from . hoặc *.
  • Subtask 3 (50 points): 1≤n≤1001\le n\le 100; 1≤m≤10001\le m\le1000; 1≤x,y≤10001\le x,y\le1000; each row has exactly mm characters from . hoặc *.

Examples

Input

2 3 3 4
..*
...

Output

11

Explanation

Cover the two adjacent white cells in row one with a double tile (44). Row two needs one double tile (44) and one single tile (33). Total cost is 1111.