r = 3
c = 4

a1 = 0
a2 = 0
b1 = 1
b2 = 2

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

DIV = 100000007

def fact(n)
	if n == 0
		1
	else
		(1..n).inject(:*)
	end
end

def f(x,y)
	fact(x+y)/fact(x)/fact(y)
end

xls = [(b1-a1).abs , (b1>a1)? a1+r-b1 : r-a1+b1]
yls = [(b2-a2).abs , (b2>a2)? a2+c-b2 : c-a2+b2]

as = xls.map {|lx|
	yls.map {|ly|
		[lx,ly]
	}
}.flatten(1).map {|x,y| [x+y,f(x,y)%DIV]}

h=Hash.new(0)
as.each {|x,y|
	h[x]=(h[x]+y)%DIV
}
p (a1==b1 and a2==b2)? 1 : h[as.map{|a,b|a}.min]