r, c, a1, a2, b1, b2 = gets.split.map(&:to_i)

m = [(a1-b1).abs, a1+r-b1, b1+r-a1].min
n = [(a2-b2).abs, a2+c-b2, b2+c-a2].min

x = (1..m+n).inject(:*) / (1..m).inject(:*) / (1..n).inject(:*)
x *= 2 if (a1-b1).abs * 2 == r
x *= 2 if (a2-b2).abs * 2 == c
p x % 100000007