import java.lang.Math.abs

fun main(args:Array<String>):Unit {
    val arg = readLine()!!.trim().split(' ').map(String::toInt)
    val (r, c) = arg.take(2)
    val (ax, ay, bx, by) = arg.drop(2)
    val mod = 100000007L
    val memoFactorial = LongArray(1001){-1}
    factorial(1000, mod, memoFactorial)
    val memoInverse = memoFactorial.map{power(it, mod - 2, mod)}.toLongArray()
    val combination:(Int, Int) -> Long = fun(n:Int, r:Int):Long{ return (((memoFactorial[n] * memoInverse[r]) % mod) * memoInverse[n - r]) % mod}
    val dx = abs(ax - bx)
    val dy = abs(ay - by)
    val diffX = minOf(dx, r - dx)
    val diffY = minOf(dy, c - dy)
    println((combination(diffX + diffY, diffX) * (if (dx * 2 == r) 2 else 1) * if (dy * 2 == c) 2 else 1) % mod)
}
fun factorial(n:Int, mod:Long, memo:LongArray):Long {
    if (memo[n] >= 0) return memo[n]
    memo[n] = when(n){
        0 -> 1
        else -> (n * factorial(n - 1, mod, memo)) % mod
    }
    return memo[n]
}
fun power(base:Long, exp:Long, mod:Long):Long {
    return when(exp){
        0L -> 1
        else -> (power(base, exp / 2, mod).let{if (exp % 2 == 0L) it * it else it * it} % mod * if (exp % 2 == 0L) 1 else base) % mod
    }
}

