You are playing a tower defense game where you can build two types of defensive towers in an $$$n \times m$$$ grid.
Each tower type has a base DPS (Damage Per Second): Tower A has a base DPS of $$$d_A$$$, and Tower B has a base DPS of $$$d_B$$$. As monsters will increase in later stages, you want to maximize the total DPS of all towers.
Additionally, each tower type has unique characteristics:
Some grid cells are obstacles (marked as #) and cannot be used for building towers. The remaining cells are empty (marked as .), where you can build at most one tower per cell or leave them empty. How should you arrange the towers to maximize the total DPS?
The first line contains four integers: $$$n$$$, $$$m$$$, $$$d_A$$$, $$$d_B$$$ ($$$1 \leq n,m \leq 2000$$$, $$$1 \leq d_A,d_B \leq 10^9$$$).
The next $$$n$$$ lines each contains $$$m$$$ characters(. or #), where . denotes an empty cell and # denotes an obstacle.
The first line should output the maximum total DPS.
The next $$$n$$$ lines, each containing $$$m$$$ characters, should show the grid after tower placement, where A represents Tower A, B represents Tower B, and other symbols match the input.
3 3 2 8...#.....
46 BBB #AA BBB
The DPS for each tower is shown as follows:
| 7 | 6 | 7 |
| # | 3 | 3 |
| 7 | 6 | 7 |
| Name |
|---|


