
import java.util.Scanner;

/**
 *
 * @author Single Malt
 */
public class Barrels {
    static final int MOD = 1000_000_007;
    public static void main(String[] args) {
        String[] f = new Scanner(System.in).nextLine().split(" ");
        int a = Integer.parseInt(f[0]);
        int b = Integer.parseInt(f[1]);
        int k = Integer.parseInt(f[2]);
        int c = Integer.parseInt(f[3]);
        int x = 0;
        if (k > 0 && (c == a || c == b)) {
            int l = a == b ? k : (k - 1);
            int r = k;
            for (int i = 0; i < l; ++i) {
                r = (r * 2) % MOD;
            }
            x = r;
        }
        System.out.println(x);
    }
    
}

