# class construction():
#     current = ""
#     vals = []
#     def constructInts(self,x:str,y:str,length:int):
#         if len(self.current) == length:
#             self.vals.append(self.current)
#             self.current = self.current[0:-1]
#             return
#         for i in[x,y]:
#             self.current += i
#             self.constructInts(x,y,length)
#         self.current = self.current[0:-1]
#         return self.vals   
from typing import List
def barrels(d:List[int]):
    if d[3] in [d[0],d[1]]:
        return ((2**d[2]) * d[2]) / 2 % 1000000007
    #return 2**d[3] 
    #return dict1[str(d[3])]% 1000000007
 

print(barrels([6,5,2,6]))
#new = construction()
#a = new.constructInts("5","6",3)
