/* * 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 beerbarrels; import java.util.Scanner; /** * * @author boban3 */ public class Main { public static int a, b, k, c, vysledok; public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNextLine()) { String[] riadok = sc.nextLine().split(" "); a = Integer.parseInt(riadok[0]); b = Integer.parseInt(riadok[1]); k = Integer.parseInt(riadok[2]); c = Integer.parseInt(riadok[3]); vysledok = 0; if (a != c && b != c) { System.out.println("0"); continue; } if (a == b) { System.out.println(k); continue; } if (k == 1) { System.out.println("1"); continue; } long vysledok = 1; for (int i = k - 1; i >= 1; i--) { vysledok *= 2; vysledok %= 1000000007; } vysledok *= k; System.out.println(vysledok % 1000000007); } } }