r, c, a1, a2, b1, b2 = gets.chomp.split.map(&:to_i)
result = 1
if a1 == b1
    result = 2 if (a2 - b2).abs == c - (a2 - b2).abs
else
    if a2 == b2
        result = 2 if (a1 - b1).abs == r - (a1 - b1).abs
    else
        x1, x2 = [a2, b2].minmax
        y1, y2 = [a1, b1].minmax
        arr = [[x2 - x1, y2 - y1], [c + x1 - x2, y2 - y1], [x2 - x1, r + y1 - y2], [c + x1 - x2, r + y1 - y2]]
        min = nil
        arr.each{|x, y| min = x + y if min.nil? || min > x + y}
        result = 0
        arr.each{|x, y|
            next if x + y != min
            z = 1
            a, b = [x, y].minmax
            a.times{|i| z *= (a + b - i)}
            a.times{|i| z /= (i + 1)}
            result += z
        }
    end
end
puts result % 100_000_007

