P6833 [Cnoi2020] Thunderstorm

Background

> Uneasy clouds begin to cover the sky. Huge buildings creak in the strong wind. Discordant sounds echo throughout Gensokyo. — “Touhou Kishinjou ~ Double Dealing Character”. On a stormy night with thunder and lightning, a bolt of lightning struck the Scarlet Devil Mansion by the Misty Lake and the Bamboo Forest of the Lost. It seems that something big is about to happen, and Cirno is quietly thinking in her hut.

Description

The vertical cross-section of Gensokyo can be abstracted as an $n \times m$ rectangle. Each $1 \times 1$ cell $(i,j)$ has a **resistance measurement value** (a fictional concept) $R_{i,j}$. The lightning is emitted from $\texttt{O}(n,a)$ on the **thundercloud**, and hits the *Scarlet Devil Mansion* $\texttt{A}(1,b)$ and the *Bamboo Forest of the Lost* $\texttt{B}(1,c)$ on the **ground**. Since lightning is a natural creation, it will choose positions so that the total resistance measurement value is minimized. That is, the sum of resistance measurement values over the **union of the two paths** from $\texttt{O}$ to $\texttt{A}$ and $\texttt{B}$ is minimized. So, when the resistance measurements at all positions are known, Cirno wants to know the minimum possible sum of resistance measurement values along the lightning’s paths.

Input Format

The first line contains five integers $n,m,a,b,c$. $(0

Output Format

One line with one integer, representing the answer.

Explanation/Hint

# Sample Explanation ![](https://cdn.luogu.com.cn/upload/image_hosting/7ozs40i3.png) As shown in the figure, the yellow lines are the lightning’s paths. # Constraints For $100\%$ of the testdata, it is guaranteed that: $0