
def fact(x):
    res = 1
    while x >= 2:
        res *= x
        x -= 1
    return res


def permutations(x, y):
    a = fact(x) + fact(y)
    b = fact(x * y)
    return a/b

if __name__ == "__main__":

    line = input()
    split = line.split()
    
    a = int(split[0])
    b = int(split[1])
    k = int(split[2])
    c = int(split[3])

    variations = 2**k

    res = variations * k

    res /= 2 if a == b else 2

    res = res if c in (a, b) else 0

    print(int(res % (1000 * 1000 * 1000 + 7)))


