/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package sutaz; import java.math.BigInteger; import java.util.Scanner; /** * * @author janotka1 */ public class Barrels { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int A = sc.nextInt(); int B = sc.nextInt(); int K = sc.nextInt(); int C = sc.nextInt(); if(C != A && C != B){ System.out.println(0); }else if(A == B ) { System.out.println(K); }else{ BigInteger velkyInt = new BigInteger("2"); BigInteger bigIntK = new BigInteger(Integer.toString(K)); BigInteger bigMod = new BigInteger(Integer.toString(1000000007)); BigInteger KList = velkyInt.pow(K); KList = KList.multiply(bigIntK); KList = KList.divide(velkyInt); KList = KList.mod(bigMod); System.out.println(KList.toString()); } } }