import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Barrels {

    public static void main(String[] args) throws IOException {
        new Barrels().solve();
    }

    private void solve() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int a = Integer.parseInt(line[0]);
        int b = Integer.parseInt(line[1]);
        int k = Integer.parseInt(line[2]);
        int c = Integer.parseInt(line[3]);

        if (k == 0) {
            System.out.println(0);
        }

        else if (c!= a && c!= b) {
            System.out.println(0);
        }

        else if (a == b) {
            System.out.println(k);
        }
        else {

            long temp = 1;
            for (int i = 0; i < k - 1; i++) {
                temp = (temp * 2) % 1000000007;
            }

//            long tempInit = temp;
            System.out.println((temp*k) % 1000000007);

//            for (int i = 1; i < k; i++) {
//                temp = (temp + tempInit) % 1000000007;
//            }
//
//            System.out.println(temp);


            //long temp = computeSequence(k);



        }

    }

    private long computeSequence(int k) {
        long sum = 2*k; // first and the last

        long oldBinom = k;
        for (int i = 2; i < k; ++i) {
            long newBinom = (oldBinom * (k - i + 1)) % 1000000007;
            sum += newBinom;
            oldBinom = newBinom / i;
        }

        return sum;
    }
}

