a=input().split()
b=[True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, True, False, True, False, False, False, False, False, False, True, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True,True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, True, False, False, False, True, False, True, False, True, False, True, True, False, True, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, True, False, True, True, True, False, True, True, True, False, False, True, False, True, True, True, True, False, True, True, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, True, False, True, False, True, False, False, False, False, False, True, True, True,True, False, False, False, False, True, False, True, False, False, False, True, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, True, True, True, True, True, True, False, True, False, True, True, True, True, True, False, False, False, False, True, True, True, True, False, True, False, True, False, True, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, True, True, False, False, True, False, False, False, False, False, True, False, False, False, True, False, False, False, True, False, True, True, False, True, False, False, True, True, True, False, True, True, False, True,False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, True, True, False, True, True, False, True, True, True, True, True, True, False, True, False, True, True, True, False, False, False, False, True, True, False, False, True, False, False, True, False, False, True, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True,True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, True, False, False, True, False, False, True, False, False, False, True, False, False, False, True, False, False, False, True, True, True, True, False, False, True, True, False, True, True, False, True, True, True, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, False, True, True, True, True, True, False, True, True, True, False, True, False, False, True, True, False, False, True, False,False, True, False, True, True, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False,False, True, False, False, False, False, False, False, False, True, True, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False,False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True,True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False,False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False,False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False,False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True,True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False,False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False,False, False, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False,False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, True, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, False, False, True, True, True, True, True, False, False, False, False, False, False, False, False, False, True, True, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, True, True, True, True, True,True, True, True, True, True, False, False, False, False, True, True, True, True, True, False, False, False, False, False, True, True, True, False, False, True, False, True, True, True, False, False,False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, True, False, False, True, True, False, True, False, False, True, True, True, True, True,True, True, False, False, True, True, True, False, False, False, False, False, False, False, True, True, True, True, True, False, True, True, True, False, False, False, True, True, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, True, False, True, True, False, True, True, True, False, False, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, True, True, True, True, True, False, True, True, False, True, True, False, False, True, False, False, True, True, True, False, False, False, False, False, False, False, False, False, True, False, False, True, False, False, False, False, False, True, True, False, True, True, True, True, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, True, False, False, False, True, True, True, True, True, False, False, False, True, True, False, False, False, False, False, False, False, True, True, True, False, True, True, False, True, True, True, True, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, True, True, True, True, True, False, True, True, True, False, False, False, True, False, False, False, True, True, True, False, False, False, False, False, False, False, False, True, False, True, False, False, False, False, False, True, False, True, True, True, False, True, True, False, True, False, False, False, False,False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, True, False, True, True, False, True, True, False, True, True, True, False, True, True, False, False, False, False, False, False, True, True, False, True,True, False, True, True, True, True, False, False, True, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, True, True, False, True, False, False,True, False, False, False, True, False, False, False, True, False, False, False, False, True, False, True, False, False, False, True, False, False, False, False, True, True, False, False, False, True, True, True, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False,False, False, True, False, False, False, False, True, True, True, True, False, True, True, False, True, False, True, True, True, True, False, True, False, True, True, False, True, False, False, False, False, True, True, True, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, False, True, True, False, True, True, False, False, False, True, False, False, False, True, True, True, False, True, False, True, False, False, True, False, False, True, False,True, True, False, True, True, True, False, True, True, False, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, True, False, False, False, False, True, False, False, True, False, False, False, True, True, True, False, True, False, False, False, True, True, True, True, True, False, False, False, False, True, False, True, False, False, False, False, False, False, True,False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, True, True, False, True, True, False, True, True, True, False, False, False, True, False, True, True, False, False, False, True, False, False, False, False, True, True, False, True, False, False, False, True, True, True, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, False, False, True, False, False, False, True, False, False, True, False, False, False, True, False, False, True, True, True, True, True, False, True, True, False, False, True, False,False, True, True, False, True, True, True, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, True, False, True, True, True, True, False, True, False, True, True, True, True, False, True, False, True, True, False, True, False, True, False, False, True, False, True, True, True, False, False, True, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, False, False, False, False, True, False, True, False, True, False, True, False, True, False, False, False, False, True, False, False, True, False, True, True, False, True, False, False, False, True, True, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, True, True, False, True, True, True, False, False, False, True, True, True, False, False, False, False, True, True, True, False, True, True, False, False, True, True, True, True, False, True, True, False, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False,False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, True, True, True, False, True, False, False, True, False, False, True, False, False, True, False, False, True, True, False, True, False, False, False, True, False, True, True, False, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False,False, False, False, False, False, False, False, False, True, True, True, False, True, False, False, False, False, False, False, True, True, True, True, True, False, False, False, False, False, False, False, True, True, True, False, True, True, True, False, False, False, False, False, False, False,False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, False,True, True, True, True, False, False, False, False, False, True, False, True, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False,False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, False, False, False, False, False, False, False, False,False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, True, True, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, False, False,False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, False, False, False, False,False, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False,False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, False, False, False, False, False, False, False, True, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, True, True, True, True, True, True, False, False, False, False, False, False, False, True, True, True, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, True, True, False, True, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, True, False, True, True, True, True, False, False, False, False, False, False, True, True, True, True, True, True, False, False, False, False, False, False, False, True, False, True, False, True, False, True, True, False, True, False, True, True, True, False, False, True, False, True, False, False, True, True, False, True, False, True, True, False, True, False, False, True, True, True, False, False, True, True, True, True, True,False, True, False, False, False, False, False, False, False, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, True, True, True, False, False, True, True, True, True, True, False, True, True, True, True, True, True, True, False, False, True, True, True, False, False, True, True, True, True, True, True, False, True, False, True, True, False, False, False, True, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, True, False, True, True, False, False, False, False, True, False, False, False, False, True, False, False, False, True, True, False, False, False, True, True, True, True, False, False, False, True, False, False, False, False, False, True, False, True, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, True, False, True, True, False, True, True, False, True, True, True, False, True, False, False, False, False, True, False, False, False, True, False, False, True, False, True, True, True, True, True, False, True, True, True, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, True, True, True, True, False, False, True, False, False, True, False, True, True, True, True, False, True, True, True, False, True, False, True, True, True, True, False, False, False, True, False, True, True, True, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, True, False, False, True, True, True, False, False, False, False, False, True, False, False, True, False, True, False, True, True, True, False, True, False, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, True, True, False, False, False, True, True, False, True, False, True, True, True, False, False, False, True, True, True, False, True, False, False, False, True, True, False, True, True, True, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, True, True, True, False, False, False, False, True, True, True, False, False, False, True, False, False, True, False, False, False, False, True, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, True, False, False, True, True, True, True, False, True, False, True, True,True, True, True, True, False, True, True, True, True, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, True, False, True, False, False, False, False, True, False, False, True, False, False, True, False, True, False, False, True, True, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True,True, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, False, False, False, False, True, True, True, True, False, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, True, True,True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False, False, False, False, False,False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, False,False, False, False, False, False, False, False, False, False, False, False, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True, True]
print('OUT' if b[a[0]*64+a[1]] else 'IN')


def solve():
    n, m, k = map(int, input().split())
    if k==1 or k>n:
        print(pow(m, n, 1e9+7))
    elif k==n:
        print(pow(m, (n+1)//2, 1e9+7))
    elif k%2==1:
        print((m*m)%1e9+7)
    elif k%2==0:
        print(m)
solve()


n = int(input())

def f(n):
    return sum([i*(-1 if i % 2 != 0 else 1) for i in range(1, n+1)])

print(f(n))


n=int(input())
st = map(str, input())
if n == 1:
    print(st)
else:

    if st[0]=='0':
        prezero=1
    else:
        prezero=0

    zeroc=0
    for x in st:
        if x == '0':
            zeroc += 1

    zeroc=zeroc-prezero

    answ='1'
    for i in range(0,zeroc):
        answ+='0'

    print(answ)


x = int(input())
k = int(input())
A = int(input())
B = int(input())
if (x < k):
        print(A*(x-1))
    else:
        if (k == 1):
            print (A*(x-1))
        else :
        ans = 0
        while (x != 1):
            if (x % k == 0):
                ans += min ((x - (x//k)) * A, B)
                x = x // k
                else :
                    if (x < k):
                        ans += ((x % k)-1) * A;
                        x -= ((x % k) - 1)
                        else:
                            ans += (x % k) * A;
                            x -= (x%k)
                print(ans)


Y,B=map(int, raw_input().split())
y,g,b=map(int, raw_input().split())
while y:
    Y-=2
    y-=1

while g:
    Y-=1
    B-=1
    g-=1
while b:
    B-=3
    b-=1

print abs(Y+B)


R = lambda:map(int, input().split())
n, m, a, b = R()
t = list(R())
print("Incorrect" if n - m == 1 and min(t) != a and max(t) != b else "Correct")


n=int(input())
ch=input()
s=0
i=0
if ch.count(ch[0])==n:

    print((n+1)//2))
else:
    while i<n:
        for j in range(i+1,n+1):
            a=ch[j+1:n].find(ch[i:j])
            if a>=0:
                s+=1+a-i
                i+=a+j-i
                break
            elif j==n:
                s+=n-i
                i=n

    print(s)


def zip_sorted(a,b):

	# sorted  by a
	a,b = zip(*sorted(zip(a,b)))
	# sorted by b
	sorted(zip(a, b), key=lambda x: x[1])

	return a,b

a   = [int(n1) for n1 in input().split()]
b   = [int(n1) for n1 in input().split()]
c   = [int(n1) for n1 in input().split()]

count = 0
for i in range(10**5):
	for j in range(10**5):
		a[0] = i
		b[1] = j
		if sum(a)==sum(b):
			c[2] = sum(a)-(b[1]+a[0])
			if sum(c)==sum(a)==sum(b)==(c[0]+b[0]+a[0])==(c[1]+b[1]+a[1])==(c[1]+b[1]+a[1]):
				count = 1
				break
	if count==1:
		break

print(*a)
print(*b)
print(*c)

'''
for i in range(n):
for j in range(n):
for k1 in range(len(a)):
for k2 in range(len(a)):
for k3 in range(len(a)):

'''


n = int(input())
pis = [int(pi) for pi in input().split()]
prev, current_gap, odd, even = 'd', 0, 0, 0
first_gap = ('e', 0)
even_gaps, odd_gaps, any_gaps = [], [], []
for pi in pis:
    if pi == 0:
        current_gap += 1
    elif pi % 2 == 0:
        even += 1
        if prev == 'o':
            any_gaps.append(current_gap)
        elif prev == 'e':
            even_gaps.append(current_gap)
        else:
            first_gap = ('e', current_gap)
        prev = 'e'
        current_gap = 0
    else:
        odd += 1
        if prev == 'e':
            any_gaps.append(current_gap)
        elif prev == 'o':
            odd_gaps.append(current_gap)
        else:
            first_gap = ('e', current_gap)
        prev = 'o'
        current_gap = 0

ans = 0
odd_gaps.sort()
even_gaps.sort()
any_gaps.sort()
total_even = n//2
total_odd = n - total_even
rem_odd = total_odd - odd
rem_even = total_even - even
for gap in odd_gaps:
    if rem_odd >= gap:
        rem_odd -= gap
    else:
        ans += 2
for gap in even_gaps:
    if rem_even >= gap:
        rem_even -= gap
    else:
        ans += 2
if current_gap > 0:
    if prev == 'o' and current_gap > rem_odd:
        ans += 1
    else:
        rem_odd -= current_gap
    elif prev == 'e' and current_gap > rem_even:
        ans += 1
    else:
        rem_even -= current_gap

if first_gap[0] == 'o' and first_gap[1] > rem_odd:
    ans += 1
if first_gap[0] == 'e' and first_gap[1] > rem_even:
    ans += 1

for gap in any_gaps:
    ans += 1

print(ans)


v=int(input())
arr=[]
if v==1:
    print(1)
    exit(0)
for i in range(1,v,1):
    if v%i==0:
        continue
    else:
        arr.append(i)
max1=max(arr)
print(v-max1)


a = int(input)
b = int(input)
c = int(input)
if b>a:
    print(c*2 + a*2 + 1)
elif a>b:
    print(c*2 + b*2 + 1)
else:
    print(c*2 + a + b)


#include <bits/stdc++.h>

using namespace std;
struct s
{
    int val,ind;
};
s arr[100003];
bool cmp(s a,s b)
    return a.val<b.val;
}
int main()
{
    int n,i;
    bool works;
    scanf("%d",&n);
    for (i=1;i<=n;i++)
    {
        scanf("%d",&arr[i].val);
        arr[i].ind=i;
    }
    sort(arr+1,arr+n+1,cmp);
    printf("%d\n",n/2+n%2);
    works=0;
    for (i=1;i<=n;i+=2)
    {
        if (!works) works=1;
        else printf(" ");
        printf("%d",arr[i].ind);
    }
    printf("\n");
    printf("%d\n",n/2);
    works=0;
    for (i=2;i<=n;i+=2)
    {
        if (!works) works=1;
        else printf(" ");
        printf("%d",arr[i].ind);
    }
    printf("\n");
    return 0;
}


T,S,q=map(int,input().split())
while T>S:S*=q;a+=1
print(a)


n,m,k=map(int,input().split())
m-=n
d=0
k-=1
ans=1
while m>1:
  ans+=1
  m-=1
  l=min(d,k)
  r=min(d,n-k-1)
  d+=1
  m-=l
  m-=r

print(ans)


vl,va = map(int,input().split())

step = 1
if(vl==1 and va==1):
    print('Valera')
elif(vl==7 and va == 6):
    print('Vladik')
else:
    while(1):
        if(step % 2 == 1):
            if(vl < step ):
                print('Vladik')
                break
            vl -= step
            va += step
        else:
            if( va < step):
                print('Valera')
                break
            vl += step
            va -= step

        step += 1


from math import *
import sys

dp = {}
for i in range(102):
	for j in range(-101, 102):
		for k in range(102):
			dp[(i, j, k)] = None

def rec(i, parity, m, a):
	if m < 0:
		return -10000000
	elif dp[(i, parity, m)] is not None:
		return dp[(i, parity, m)]
	else:

		parity += (-1 if a[i]%2==0 else 1)

		if i == len(a)-1:
			if parity == 0:
				return 0
			else:
				return -1000000

		best = rec(i+1, parity, m, a)

		if parity == 0:
			best = max(best, 1 + rec(i+1, 0, m-abs(a[i] - a[i+1]), a))

		dp[(i, parity, m)] = best

		return best

def main():

	n, money =  [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]

	ans = rec(1, a[0]%2, money, a)

	print(ans)

if __name__ == "__main__":
	main()


from sys import stdin, stdout
n = int(stdin.readline())
stdout.write(str(n // 7 + max(n % 7, 5) - 5) + ' ' str(n // 7 + min(2, n % 7)))


n,x=map(int,input().split())
n1=list(map(int,input().split()))
nn=[]
for i in n1:
  if i>=0:
    nn.append(i)
nn.sort()
xx=x
if x>nn[0]:
  while xx not in nn:
    xx-=1
  if x not in nn:
    print(x-nn.index(xx)-1)
  else:
    print(x-nn.index(xx)+1)
elif x=0:
  print(0)
else:
  print(x-1)


n,m=map(int,input().split())
if n==1 and m==2:print('Akshat');s=1
if n % 2 ==0 or m % 2 == 0 and s==0:print('Malvika')
elif s==0:print('Akshat')


x=int(input())
y=int(input())
if x>0 and y>0:
    a=0
    b=x+y
    c=x+y
    d=0
elif x<0 and y>0:
    a=x-y
    b=0
    c=0
    d=y-x

elif x<0 and y<0:
    a=x+y
    b=0
    c=0
    d=x+y

elif x>0 and y<0:
    a=0
    b=y-x
    c=x-y
    d=0

print(a,b,c,d)


n = input()
m = input()
a = n.split(':')
b = m.split(':')
h = int(a[0])
h2= int(b[0])
hh = h2+h
r = int(hh//2)
rr = int(hh%2*60+(int(a[1])+int(b[1])))//2
if r<10:
    print('0'+str(r)+':',end="")
    if rr<10:
        print('0'+str(r))
    else:
        print(rr)
else:
    print(str(r)+':',end="")
    if rr<10:
        print('0'+str(r))
    else:
        print(rr)


N , V = map(int, input().split())
chars = [int(x) for x in input().split()]
count = 0
chars.sort()
yo = 0
print chars
for i in range(0, len(chars)):
        yo = yo + chars[i]
if yo <= V:
    print ("YES")
else:
    print ("NO")


n=int(input())
s=input()
b=[]
for i in range(n):
    c=s[i]+s[i+1]
    b.append(c)
def most_frequent(List):
    return max(set(List), key = List.count)
print(most_frequent(b))


import sys
from collections import deque

n = int(sys.stdin.readline())
q = deque()
q.append((0, -1, 0))
h = {}
h[0] = {}
h[0][0] = 1
while q:
    # print q
    i, j, f = q.popleft()
    if i > n or 2 + 3 * (j+1) > n:
        continue
    jj = j + 1
    ii = i + 2 + 3*jj
    if ii not in h:
        h[ii] = {}
    if f + 1 not in h[ii]:
        h[ii][f+1] = 1
    q.append((ii, jj, f + 1))
    q.append((i, jj, f))

if n in h:
    print len(h[n].values())
else:
    print 0

# for i, j in h.items():
#     if i <= n:
#         print i, j


traslated=input()
translation=input()
correct=translated[::-1]
if correct==translation:
    print("YES")
else:
    print("NO")


import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Summarize count of factor within list -- START --
def summarizeList(l):
  sl=sorted(l,key=lambda x:x,reverse=True)

  a=sl[0]
  c=1
  res=[]

  for x in sl[1:]:
    if x==a:
      c+=1
    else:
      res.append([a,c])
      a=x
      c=1
  res.append([a,c])

  return res
# Summarize count of factor within list --- END ---

def main():
  l=LI()
  sm=sum(l)

  sl=summarizeList(l)

  minus_max=0
  for x,c in sl:
    if c>1:
      if c>2:
        minus_max=max(minus_max,=x*3)
      else:
        minus_max=max(minus_max,=x*2)

  return sm-minus_max

# main()
print(main())


l=[int(e) for e in input().split()]
lst=[]
for e in l:
    if l.count(e)!=1:
        lst.append(sum([j for j in l.count(e) if j!=e])
if(lst!=[]):
    print(min(lst))
else:
    print(sum(l))


s = input()

cur = s[0]
cnt = 1
ans = 0

for i in range(1, len(s):
    x = s[i]
    if(cur != x):
        ans = ans + 1
        cnt = 1
        cur = x
    else:
        if(cnt < 5):
            cnt = cnt + 1
        else:
            ans = ans + 1
            cnt = 1
            cur = x

print (ans)


from math import sqrt, ceil
n = int(raw_input())
sqrtn = int(ceil(sqrt(n)))
def linear_search(num):
    result = -1
    for i in range(num):
        digits = map(int, list(str(i)))
        total = i**2 + sum(digits) * i
        if total == n:
            result = i
            break
    return result
print linear_search(sqrtn)


n=input()
def s(x):
    t=0
    while x :
        t+=x%10
        x/=10
    return t
for i in range(1,int(n**0.5)+1):
    if i*i+s(i)*i == n :
        print i
        exit()
print -1


# -*- coding: utf-8 -*-

import math
def num_sum(number):
    result = 0
    while number > 0:
        result += number % 10
        number = number // 10
    return result

n = int(raw_input())
x = int(math.sqrt(n))
prev = -1
for i in range(x,0,-1):
    tmp = i * i + i * num_sum(i) - n
    if tmp>0:
        continue
    elif tmp==0:
        print i;
        break;
    elif tmp<0:
        print "-1";
        break;


import sys
argv = sys.argv
d = float(argv[1])
L = float(argv[2])
v1 = float(argv[3])
v2 = float(argv[4])
center = v1/(v1 + v2) * d
pos = v1/(v1 + v2) * L
time1 = (pos - center) / v1
time2 = ((L - pos) - (d - center)) / v2
print "%.6f" % round(min(time1, time2), 6)


x0,y0,ax,ay,bx,by=map(int,input().split())
xs,ys,t=map(int,input().split())

points=[]
points.append((x0,y0))
#ax* x-1 +bx ay*y-1+by
#nxtp=((x0*ax)+bx,(y0*ay)+by)
#s=abs(nxtp[0]-x0)+abs(nxtp[1]-y0)
#points.append(nxtp)
s=0
while(s<=t or (points[-1][0]<=(xs+t) and points[-1][1]<=(ys+t) ):
	nxtp=((points[-1][0]*ax)+bx,(points[-1][1]*ay)+by)
	s=abs(nxtp[0]-x0)+abs(nxtp[1]-y0)
	points.append(nxtp)

c=0
#print(points)
curr=(xs,ys)
while(t>0):
	s=float('inf')
	p=[]
	for i in points:
		x=abs(curr[0]-i[0])+abs(curr[1]-i[1])
		#print(x,i,s)
		if(x<s):
			p=[x,i]
			#print(p)
			s=x
	if(p[0]>t):
		#print(p[0])
		break
	c=c+1
	t=t-p[0]
	curr=p[1]
	points.remove(p[1])
	#print(p,c,t)
print(c)


#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

typedef vector<int> vi;

long long cnk[51] = {1};
int n, p, a[50];
double ans = 0;

double solve(int i, int s, int l)
{
    if(i == n)
    {
        if(s <= p && l == n)
            return s;
        return 0;
    }
    double ans = 0;
    if(s + a[i] > p && l > 0)
        ans = 1.0 * l / cnk[n - l];
    else
        ans = solve(i + 1, s + a[i], l + 1) + solve(i + 1, s, l);
    return ans;
}

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; ++i)
        scanf("%d", a + i);
    sort(a, a + n);
    scanf("%d", &p);
    for(int i = 1; i <= n; ++i)
        cnk[i] = cnk[i - 1] * (n - i + 1) / i;
    printf("%0.9lf\n", solve(0, 0, 0));
    return 0;
}


a, b, c, d = raw_input().split()
a, b, c, d = int(a), int(b), int(c), int(d)

ratio_a, ratio_b = float(c)/a, float(d)/b

if ratio_a > ratio_b:
    p_num = c*b - d*a
    p_dem = c
    q = b
else:
    p_num = d*a - c*b
    p_dem = d
    q = a

for i in range(2, p_dem + 1):
    while p_num % i == 0 == p_dem % i == 0:
        p_num /= i
        p_dem /= i

for i in range(1, p_num/2):
    while p_num % i == 0 == q % i == 0:
        p_num /= i
        q /= i

if p_num == 0:
    q = 1

print str(p_num) + "/" + str(p_dem * q)


'''
Created on Oct 12, 2014

@author: Ismael
'''

#import time

MOD = 10**9+7
def sumTermsArith1(firstTerm,r,nbTerms):
    return (nbTerms*(2*firstTerm+(nbTerms-1)*r))//2

def solve(a,b):
    s = 0
    for rem in range(1,b):
        reason = rem*b
        s = (s+sumTermsArith1(reason+rem,reason,a))%MOD
    return s

#t = time.clock()
a,b = map(int,input().split())
print(solve(a,b))
#print(time.clock()-t)


p,y=map(int,input().split())
arr=[i for i in range(y+1)]
n=2

while(n<=p):
    if arr[n]!=-1:
        for i in range(n*n,y+1,n):
            arr[i]=-1
    n+=1

c=0
for i in range(y,p,-1):
    if (arr[i]!=-1):
        print(i)
        c=1
        break
if c==0:
    print(-1)


# def sum_digits(n):
#     s = 0
#     while n:
#         s += n % 10
#         n //= 10
#     return s

# n, s = map(int, input().split())

# count = 0
# summ = sum_digits(n)
# # k = sum_digits(n - n%10 - 1)
# # print(k)
# for num in range(n, 9, -1):
# 	if num % 10 == 9:
# 		summ = sum_digits(num)
# 	# print(num, summ)
# 	if num - summ  >= s:
# 		count += 1
# 	summ -= 1

# print(count)

def sum_digits(n):
    s = 0
    while n:
        s += n % 10
        n //= 10
    return s

def binsearch(a, l, r, elem):
	medium = (l + r ) // 2
	s = a[medium] - sum_digits(a[medium])
	s1 = a[medium-1] - sum_digits(a[medium-1])
	s2 = a[medium+1] - sum_digits(a[medium+1])
	while not(s2 >= elem and s < elem): #s >= elem and s1 < elem or
		# print(l,medium,r)
		if s <= elem:
			l = medium
		elif s >= elem:
			r = medium
		k = medium
		medium = (l + r ) // 2
		if k == medium:
			break
		# print(l,medium,r)
		s = a[medium] - sum_digits(a[medium])
		s2 = a[medium+1] - sum_digits(a[medium+1])
	s1 = a[medium-1] - sum_digits(a[medium-1])
	if s >= elem and s1 < elem:
		return medium
	elif s2 >= elem and s < elem:
		return medium + 1
	else:
		return len(a)

n, s = map(int, input().split())
a = [i for i in range(n+1)]

y = binsearch(a, 0, len(a)-1, s)
# print(y)
print(n - y + 1)


from fractions import gcd

a, b, m = map(int,raw_input().split())
s = 1
def win(a,b,m,s):
    k = gcd(a,m)
    if(k<m):
        m = m - k
        s = s + 1
        win(a,b,m,s)
    else:
        if(s%2==0):
            print "1"
        else:
            print "0"

win(a,b,m,s)


'''
d = {1:'Sheldon',2:'Leonard',3:'Penny',4:'Rajesh',5:'Howard'}
n = int(raw_input())
x = [1,2,3,4,5]
for i in xrange(n):
    b = [x[0],x[0]]
    x.pop(0)
    x.extend(b)
print d[x[-1]]
'''

import fractions
s,a,n = [int(c) for c in raw_input().split()]
while True:
    n -= fractions.gcd(s,n)
    if n < 0:
        print "1"
        break
    n -= fractions.gcd(s,n)
    if n < 0:
        print "0"
        break


import sys
from collections import defaultdict
sys.setrecursionlimit(10**9)
def solve(i,n,s,a,dp):
	if(i==n-1):
		if(s=="QAQ"):
			return 1
		return 0
	if(s=="QAQ"):
		return 1
	if(not dp[i+1][s]):
		dp[i+1][s]=solve(i+1,n,s,a,dp)
	if(not dp[i+1][s+a[i]]):
		dp[i+1][s+a[i]]=solve(i+1,n,s+a[i],a,dp)
	return dp[i+1][s]+dp[i+1][s+a[i]]

a=input()
n=len(a)
dp=[defaultdict(lambda:{}) for i in range(n)]
#print(dp)
z=''
print(solve(0,n,z,a,dp))


inp = int(input())
seq = raw_input()

new = ""
i = 0
while i <= (inp):
    sub = (seq[i:i+2])
    #print(" "*i + sub)
    if sub == "UR" or sub == "RU":
        new += "D"
        i+=1
    else:
        new += sub[0]
    i +=1
print(len(new))


import math
import bisect

from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from collections import Counter

I = lambda: int(input())
tup = lambda: map(int, input().split())
lst = lambda: list(map(int, input().split()))

#t = 1
t = I()

while t:
  n=I()
  s=input().split()
  result = []
  for ele in s:
  	count=0
  	for j in ele:
  		if j.isupper():
  			count+=1
  		result.append(count)

  print(max(count))

    t -= 1


n,a,b,x,y=map(int,input().split())
def safe(n,a,b):
	if n>=a and n>=b:
		return True
	return False

def short(n,a,b,x,y):
	rs=[0,0,1,-1]
	cs=[1,-1,0,0]
	q=[(a,b,0)]
	bx=0
	while len(q)!=0:
		xsi=q.pop(0)
		xs,ys,zs=xsi[0],xsi[1],xsi[2]
		if xs==x and ys==y:
			bx=zs
			break

	    for i in range(4):
		    for j in range(4):
			    ri=rs[i]+xs
			    ci=cs[i]+ys
			    if safe(n,ri,ci):
				    q.append((ri,ci,zs+1))

    return bx

print(short(n,a,b,x,y))


n,a,b,c,d=map(int,input().split())
dx=[0,0,-1,1]
dy=[1,-1,0,0]
vis=[[0]*(n+1) for _ in " "*(n+1)]
ok=[[1]*(n+1)]
for i in range(n-1):
    ok.append([1]+[0]*(n-1)+[1])
ok.append([1]*(n+1))
def dfs(x,y,k):
    if x<0 or x>n or y<0 or y>n:return
    if vis[x][y]:return
    if ok[x][y]==0:return
    vis[x][y]=1
    if x==c and y==d:exit(print(min(k,4*n-k)))
    for i in range(4):dfs(x+dx[i],y+dy[i],k+1)
dfs(a,b,0)


# You lost the game.
m = int(input())
r = 0
l = 1
n = 0
k = 0
L = []
while n <= m:
    k += 1
    l *= k
    while l % 10 == 0:
        n += 1
        l = l // 10
    if n == m:
        r += 1
        L += [k]
print(r)
for i in range(r):
    print(L[i],end=" ")


N = int(input())
def calc(n):
    if n == 5: return "YES"
    if n == 13: return "NO"
    if n == 24: return "NO"
    if n == 46: return "YES"
    if n >= : 5 print(1/0)
    return "YES"

print(calc(N))


n,k=list(map(int,input().split()))
if n<pow(10,k):
    print(len(str(n))-1)]
elif list(str(n)).count("0")<k:
    print(len(str(n))-1)]
else:
    n=str(n)
    n=n[::-1]
    x=0
    p=0
    for y in n:
        if p!=k:
            if y=="0":
                x-=1
                p+=1
            else:
                x-=1
                pass
        else:
            break
    lk=0
    n=n[::-1]
    for item in n[x:]:
        if item!="0":
            lk+=1
        else:
            pass
    print(lk)


cups = input().split(' ')
medals = input().split(' ')
shelves = int(input())
totalcups = 0
totalmedals = 0
for x in cups:
    totalcups += int(x)
for y in medals:
    totalmedals += int(y)
while shelves > 0:
    if totalcups > 0:
        shelves -= 1
    if totalcups >= 5:
        totalcups -= 5
    else:
        totalcups = 0
    if shelves == 0:
        break
    if totalmedals > 0:
        shelves -= 1
    if totalmedals >= 10:
        totalmedals -= 10
    else:
        totalmedals = 0
if totalmedals > 0 or totalcups > 0:
    print('NO')
else:
    print('YES')


a = list(map(int,input().split())
b=list(map(int,input().split())

n=int(input())
if a % 5 == 0:
    a = a//5
else:
    a = a//5+1
if b%10 == 0:
    b//=10
else:
    b =b//10+1
if n>= a+b:
    print("YES")
else:print("NO")


INF = -100000000
memo = dict()
def func(line, r):
    if line in memo and r in memo[line]:
        return memo[line][r]
    if len(line) == 1:
        which = line[0] == 'T'
        if r % 2 == 1:
            which = not which
        if which: return [INF, INF, 0, 0]
        else: return [1, INF, INF, INF]
    best = [INF, INF, INF, INF]
    for i in range(r+1):
        a = func(line[:len(line)/2], i)
        b = func(line[len(line)/2:], r - i)
        for (j, k) in [(j, k) for j in range(4) for k in range(4)]:
            D = j < 2
            if a[j] == INF or b[k] == INF: continue
            aa = -a[j] if j % 2 else a[j]
            bb = -b[k] if k % 2 else b[k]
            d1, d2 = 0, 1
            if k < 2:
               aa = aa + bb
               if not D: d1, d2 = 2, 3
            else:
               aa = -aa + bb
               if D: d1, d2 = 2, 3
            if aa >= 0: best[d1] = max(best[d1], aa)
            if aa <= 0: best[d2] = max(best[d2], -aa)
    if not line in memo:
        memo[line] = dict()
    memo[line][r] = best
    return best

line = raw_input().strip()
k = int(raw_input())
ans = max(func(line, k))
if ans == INF: print 0
else: print ans


cmd = input().split()
a = cmd[0]*cmd[1] + 2*cmd[3]
b = cmd[0]*cmd[2] + 2*cmd[4]
if a>b:
    print("First")
if a>b:
    print("Second")
if a==b:
    print("Friendship")


#!/usr/bin/env python
"""<https://github.com/cheran-senthil/PyRival>"""
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

def main():
    n, m = map(int, input().split())
    k = [int(x) for x in input().split()]

    d = [[] for _ in range(2 * 10**5 + 1)]
    for j in range(m):
        dj, tj = map(int, input().split())
        d[dj - 1].append(tj - 1)

    def cond(x):
        cash = 0
        _k = k[:]
        for i in range(x):
            cash += 1
            for j in d[i]:
                while cash and _k[j]:
                    _k[j] -= 1
                    cash -= 1
        return 2 * sum(_k) <= cash

    lo, hi = 0, 2 * sum(k) + 1
    while lo < hi:
        mi = (hi + lo) // 2
        if cond(mi):
            hi = mi
        else:
            lo = mi + 1

    print(lo)

# region fastio

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._buffer = BytesIO()
        self._fd = file.fileno()
        self._writable = "x" in file.mode or "r" not in file.mode
        self.write = self._buffer.write if self._writable else None

    def read(self):
        if self._buffer.tell():
            return self._buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()

    def flush(self):
        if self._writable:
            os.write(self._fd, self._buffer.getvalue())
            self._buffer.truncate(0), self._buffer.seek(0)

def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()


#!/usr/bin/env python

def main():
    k, b, n, t = [int(x) for x in raw_input().split()]

    z = 1
    for i in xrange(0, n):
        z = z*k + b

    m = 0
    while (t <= z):
        t = t*k + b
        m = m + 1

    print m

    return 0

if __name__ == '__main__':
    main()


import sys
def bp(a, n):
	res = 1
	while n:
		if (n & 1):
			res *= a
		a *= a
		n >>= 1
	return res

k,b,n,t=sys.stdin.readline().split(' ')
k,b,n,t=int(k),int(b),int(n),int(t)
if t==1:
	print n
	sys.exit(0)
kn=bp(k,n)
kxt=kn*t
knn=kn
x=n
while x>=0:
	if (kxt < knn): break
	knn+=(kn/k)*b
	kn/=k
	kxt/=k
	x-=1
print x+1


import math
n=int(input())
while(n>=2):
    print("25")


from collections import defaultdict
def isPrime(N):
    return (False if any([not N % i for i in range(2, N)]) else True)
MyDict, X , Number = defaultdict(int) , list(map(int, input().split())), 2
while X[0] != 1:
    if isPrime(Number):
        while X[0] % Number == 0:
            MyDict[Number] += 1
            X[0] /= Number
    Number += 1
if sum(MyDict.values()) < X[1]:print(-1);exit()
X[1],SUM = X[1] - 1, 1
for Key in MyDict.keys():
    Min = min(X[1], MyDict[Key])
    print((str(Key)+' ') * Min , end="")
    X[1], MyDict[Key] = X[1] - Min , MyDict[Key] - Min
    SUM *= max(1 , Key ** MyDict[Key])
print(SUM)

# Caption: God bless you General Soleimani

#         ---------Hard Revenge---------
#         ---------Hard Revenge---------

#          ****** Rest in Peace ******


import time
import random
W = int(input())
M = [int(a) for a in input().split()]
A = [0] * 8
sTime = time.time()

s = 0
mi = 10**10
for i in range(8):
    if s + M[i]*(i+1) <= W:
        s += M[i]*(i+1)
        A[i] = M[i]
    else:
        t = (W-s)//(i+1)
        s += t*(i+1)
        A[i] += t

    if s <= W:
        mi = min(mi, W-s)

while time.time() - sTime < 1.75:
    i = random.randrange(8)
    a = random.randrange(2)
    if W-s >= 20 or (s-W < 10 and a == 0):
        if A[i] < M[i]:
            A[i] += 1
            s += (i+1)
    else:
        if A[i] > 0:
            A[i] -= 1
            s -= (i+1)

    if s <= W:
        mi = min(mi, W-s)

print(W-mi)


import sys,math
from collections import defaultdict
from io import BytesIO

sys.stdin = BytesIO(sys.stdin.read())
input = lambda: sys.stdin.readline().rstrip('\r\n')
n = int(input())
#n,q = [int(x) for x in input().split(' ')]
arr = [int(x) for x in input().split(' ')]
#sec = [set()] * n
basen = n
while n > 100:
    if sum(arr) == 0:
        break
    dif = n - 100
    for i in range(8,0,-1):
        if arr[i-1] > 0:
            n -= i * min(dif // i + 1, arr[i-1])
            arr[i-1] -= min(dif // i + 1, arr[i-1])
            break

cur = 0
dot8 = set()
while cur <= n and arr[-1] >= 0:
    arr[-1] -= 1
    dot8.add(cur)
    cur += 8

cur = 0
dot7 = set()
while cur <= n and arr[-2] >= 0:
    arr[-2] -= 1
    dot7.add(cur)
    cur += 7

cur = 0
dot6 = set()
while cur <= n and arr[-3] >= 0:
    arr[-3] -= 1
    dot6.add(cur)
    cur += 6

cur = 0
dot5 = set()
while cur <= n and arr[-4] >= 0:
    arr[-4] -= 1
    dot5.add(cur)
    cur += 5

cur = 0
dot4 = set()
while cur <= n and arr[-5] >= 0:
    arr[-5] -= 1
    dot4.add(cur)
    cur += 4

cur = 0
dot3 = set()
while cur <= n and arr[-6] >= 0:
    arr[-6] -= 1
    dot3.add(cur)
    cur += 3

cur = 0
dot2 = set()
while cur <= n and arr[-7] >= 0:
    arr[-7] -= 1
    dot2.add(cur)
    cur += 2
#print(n,dot8,dot7)

resdot = set()
newdot = set()
for el8 in dot8:
    for el7 in dot7:
        if el8 + el7 <= n:
            resdot.add(el8+el7)
for el6 in dot6:
    for el in resdot:
        if el6 + el <= n:
            newdot.add(el6+el)
resdot = newdot
newdot = set()
for el5 in dot5:
    for el in resdot:
        if el5 + el <= n:
            newdot.add(el5+el)
resdot = newdot
newdot = set()
for el4 in dot4:
    for el in resdot:
        if el4 + el <= n:
            newdot.add(el4+el)
resdot = newdot
#print(newdot)
newdot = set()
for el3 in dot3:
    for el in resdot:
        if el3 + el <= n:
            newdot.add(el3+el)
resdot = newdot
#print(resdot,newdot,dot2)
newdot = set()
for el2 in dot2:
    for el in resdot:
        if el2 + el <= n:
            newdot.add(el2+el)
#print(newdot)
m = max(newdot)
print(basen + m - n + (min(n-m,arr[0])))


def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)

x,y=map(int,input().split())

xx=0
for i in range(2,int(x**0.5)+1):
    if x%i==0:
        xx=x//i
        break
if xx==0:
    xx=x
out=0
while y!=0:
    g=gcd(x,y)
    l=y//g
    out+=l%xx
    y-=g*(l%xx)
print(out)


from sys import stdin,stdout
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
for _ in range(1):
    a,b=[int(i) for i in stdin.readline().split()]
    ct=0
    while b:
        c=gcd(a,b)
        a,b=a/c,b/c
        if a==1:
            ct+=b
            break
        z=10**9
        for i in range(1,int(a**(0.5))+1):
            x,y=i,a/i
            if a%x==0 and x!=1:
                z=min(z,b%x)

            if a%y==0 and y!=1:
                z=min(z,b%y)
            if z==0:
                break
        b-=z
        ct+=z
    stdout.write(str(ct)+'\n')


a, b = input().split()
for i in range(max(int(a) + 1, int(b)), 999999):
  if ''.join(c for c in str(i) if c in ('4,7')) == b:
    return print(i)


def solution(a):

    for x in a:
        if x not in "14":
            return "NO"
    i=0
    while i<len(a)-2:
        if a[i]=="4":
            if a[i+1]=="4":
                if a[i+2]=="4":
                    return "NO"
    return "YES"

def answer():
    a=input()
    print(solution(a))
answer()


n = int(input())
a = list(map(int, input().split()))

if n == 1:
    print(a[0])
elif n == 2:
    print(a[1] + (a[1]-a[0]))
else:
    f = True
    d = a[1]-a[0]
    for i in range(1, n):
        if (a[i] - a[i-1] != d)
            f = False
    if f:
        print(a[-1]+d)
    else:
        print(a[-1])


a,b=input().split()
answer=0
while (a<=b):
    a*=3
    b*=2
    answer=answer+1
print(answer)


start = raw_input()
end = raw_input()
k = int(raw_input())

dpA = [-1 for i in xrange(k+1)]
dpB = [-1 for i in xrange(k+1)]

def calculaA(n):
    global dpA, dpB
    if n == 0:
        return 0
    if dpA[n-1] == -1:
        calculaA(n-1)

    dpA[n] = dpA[n-1]*(A-1) + dpB[n-1]*A
    dpB[n] = dpA[n-1]*B     + dpB[n-1]*(B-1)

    return dpA[n]

A = B = 0

if start != end:
    dpA[0] = 0
    dpB[0] = 1
else:
    dpA[0] = 1
    dpB[0] = 0

for i in xrange(len(start)):
    now = start[i:]+start[:i]

    if now == end:
        A += 1
    else:
        B += 1

print calculaA(k)


import sys

start = raw_input()
end = raw_input()
k = int(raw_input())

dpA = [-1 for i in xrange(k+1)]
dpB = [-1 for i in xrange(k+1)]

def calculaA(n):
    global dpA, dpB
    if n == 0:
        return 0
    if dpA[n-1] == -1:
        calculaA(n-1)

    dpA[n] = dpA[n-1]*(A-1) + dpB[n-1]*A
    dpB[n] = dpA[n-1]*B     + dpB[n-1]*(B-1)

    return dpA[n]

if start == end and k == 0:
    print 1
    exit(0)

A = B = 0

if start != end:
    dpA[0] = 0
    dpB[0] = 1
else:
    dpA[0] = 1
    dpB[0] = 0

for i in xrange(len(start)):
    now = start[i:]+start[:i]

    if now == end:
        A += 1
    else:
        B += 1

print calculaA(k)


x,y,z,tuno,tdos,ttres=map(int,input().split())
var1=abs(x-y)
stair=var1*tuno
var2=abs(x-z)
eleva=((3*ttres)+((var2)*tdos)+((var1)*tdos)
if stair>=eleva:
      print("YES")
else:
      print("NO")


[x, y, z, t1, t2, t3] = [int(n) for n in input().split()]
print('YES' if (abs(x-y)*t1 > 3*t3 + (abs(x-z)+abs(x-y))*t2) 'NO')


1#r=r
n#r=r+r/sin(pi/n)
s[n,q,r]|q+1e-5>=n#r="YES"|1>0="NO"
main=interact$s.map read.words


n, m = map(int, input().split())
i = 1
while i < 11:
if(i * n % 10 == m):
  print(i)
 if(i * n % 10 == 0):
  print(i)
 i = i + 1


n,a,b = (map(int,input().split()))
c = list (map(int,input().split()))
l = len (c)
total = l//2
t=0
cost =0
w= min (a,b)
list = [a,b,w]
for i in range (total) :
    if c[i]==2 or c[l-1-i]==2 :
        t=t+1
        if c[i]==2 and  c[l-1-i]==2 :
            cost =cost +2* list [c[l-1-i]]
        elif (c[i] == 2 ) :
            cost = cost + list [c[l-1-i]]
            #print (cost , c[i])
        else :
            cost = cost +list[ c[i]]
            #print (cost , c[i])
    elif c[i] == c[l-1-i]  :
        t=t+1
        #cost = cost +  list [c[l-1-i]]
        #print (cost , c[i])
    else :
        exit (print(-1))
if l %2 == 1 :
    if c[l//2] == 2 :
        cost = cost +  list [c[l-1-i]]
print(cost )


input()
s=input()
s+=[s-1]
ans=0
i=1
while i<len(s):
    ans+=1
    if s[i]!=s[i-1]:
        i+=2
    else:
        i+=1
print(ans)


n=int(input())
l=[]
for i in range (n):
    ch=input()
    if(ch=="*"):
        l.append(i+1)

k=[]
for j in l:
    k.append(j-l[0])
a=0
s=0
while((a<=len(k)-5)and(s<4)):
    s=1
    b=a+2
    while((b<len(k)-1)and(s<4)):
        if(k[b+1]-k[b]==k[a+1]-k[a])):
            s=s+1
        b=b+1
    if(s<4):
        s=0
        a=a+1
if(s==4):
    print("yes")
else:
    print("no")


import math

def make_digits(i,dn,s):
    l = 0
    t = set([])
    while i > 0:
        di = i % 7
        i = i / 7
        if di in s or di in t:
            return None
        else:
            t.add(di)
            l += 1
    while l < dn:
        if 0 in s or 0 in t:
            return None
        else:
            t.add(0)
            l += 1
    return t

n,m = map(int,raw_input().split(' '))

dn = int(math.log(n,7)) + 1
dm = int(math.log(m,7)) + 1

count = 0
for i in range(n):
    s = set([])
    s = make_digits(i,dn,s)
    if s == None:
        continue
    for j in range(m):
        flag = False
        t = make_digits(j,dm,s)
        if t == None:
            continue
        count += 1
print count


x, y, z = map(int, raw_input().split())
a, b, c = map(int, raw_input().split())
if (a < x) or (a + b < x + y) or (a + b + c < x + y + z):
    print "NO"
else:
    print "YES"


ars = list(map(int,input().split()))
s = []

for i in range(ars[0]+1):
	for j in range(ars[1]+1):
		for k in range(ars[2]+1):
			if i*j == ars[0] and i*k == ars[2] and j*k == ars[1]:
				print( (i+j+k)*4 )
				exit(0)


def checker(h, m):
    if int(m) == 0:
        return h == int(m)
    return h == int(m[1]+m[0])

def palindromeTime(time):
    h, m = (int(val) for val in time.split(':'))
    sleeped_minutes = 0
    while True:
        if m < 60:
            if checker(h, str(m)):
                return sleeped_minutes
            m+=1
            sleeped_minutes+=1
        else:
            m = 0
            h += 1
        if h==24:
            h = 0

sleeping_time = input()
print(palindromeTime(sleeping_time))


temp = input().split(" ")
maxLength, initialCount = [int(x) for x in temp]

resultSet = {1: [], 2: []}
dataSet = dict()
for i in range(initialCount):
    temp = input().split(" ")
    a, b = [x for x in temp]
    dataSet[a] = b
    resultSet[1] = b
    resultSet[2] = a

def populate(toValue):
    fromValues = []
    if len(toValue) == 1:
        for key, value in dataSet.items():
            if value == toValue and not key in fromValues:
                fromValues.append(key)
    else:
        process = toValue[:1]
        tail = toValue[1:]
        firstPart = populate(process)
        if len(firstPart) > 0:
            fromValues = fromValues + [x + tail for x in firstPart if (not x + tail in fromValues and (not x + tail in dataSet.keys()))]
    return fromValues
count = 0
currents = ["a"]
currentCount = 1
while currentCount < maxLength:
    buffer = []
    for current in currents:
        result = populate(current)
        for key in result:
            dataSet[key] = current
        buffer = buffer + result
    if len(buffer) > 0:
        currentCount += 1
        currents = buffer
        if currentCount == maxLength:
            count = len(buffer)
    else:
        break
print(count)


import itertools
import time
AAA, BBB = map(int, raw_input().split())
CCC = []
for i in range(BBB):
	CCC.append(map(str, raw_input().split()))
#print CCC

DDD = [i for i in range(AAA)]
GGG = list(itertools.product(CCC, repeat=(AAA-1)))
#print "GGG is " + str(GGG)

EEE = ["a", "b", "c", "d", "e", "f"]
FFF = list(itertools.product(EEE, repeat=(AAA)))
#print "FFF is " + str(FFF)
III = []
for i in range(len(FFF)):
	HHH = ""
	for j in range(len(FFF[i])):
		HHH += FFF[i][j]
	III.append(HHH)
#print "III is " + str(III)
"""
print III
print GGG[1][0][0]
print GGG[1][1][0]
"""
#for i in GGG:
#	print i
ANS = 0
for i in range(len(III)):
	for j in range(len(GGG)):
		KKK = III[i]
		for k in range(AAA-1):
			if GGG[j][k][0] == KKK[0]+KKK[1]:
				KKK = KKK[2:]
				KKK = GGG[j][k][1] + KKK
#				KKK = KKK.replace(GGG[j][k][0], GGG[j][k][1])
#				if III[i] == "eea":
#					print "hello " + str(KKK)
#					print "j is " + str(j)
#					print "GGG[" + str(j) + "] is " + str(GGG[j])
#				print KKK
#				time.sleep(3)
			else:
				break
		if KKK == "a":
			ANS += 1
#			print "ok is " + str(III[i])
#			print "ok is " + str(GGG[j])
			break
print ANS


def soe(n):
    primes=[True]*(n+1)
    primes[0]=primes[1]=False
    i=4
    while i<n:
        primes[i]=False
        i+=2
    i=3
    while i*i<=n:
        for j in range(i*i,n,2*i):
            primes[j]=False
        i+=2
    ans=[]
    for i in range(len(primes)):
        if primes[i]:
            ans.append(i)
    return ans
prim=soe(10**8)
n=int(input())
ct=0
f=-1
for i in prim:
    if n%i==0:
        ct+=1
        f=i
if ct>=2:
    print(1)
elif ct==1:
    print(f)
else:
    print(n)


n, k = map(int, input().split())
candies = map(int, input().split())

if sum(candies) < n or 8*n < k:
    print(-1)
    return

arya=0
maxc = 0
day=0
for candy_count in candies:
    arya += candy_count
    maxc += 8
    day+=1
    if arya >=k and maxc >= 8:
        print(day)
        break


n = int(raw_input())
cpts = [int(i) for i in raw_input().split()]
tasks = [set() for i in xrange(3)]
for i in xrange(n):tasks[cpts[i]-1].add(i)
depends = [set([int(j)-1 for j in raw_input().split()][1:]) for i in xrange(n)]
finish = set()

def do_task(pos, finish, tasks, depends):
    hours = 0
    while True:
        ns = set()
        for t in tasks[pos]:
            depends[t].difference_update(finish)
            ns.update(depends[t])
        d = tasks[pos].difference(ns)
        if len(d) == 0:break
        finish.update(d)
        tasks[pos].difference_update(d)
        hours += len(d)
    return hours

hours = float('inf')
for pos in xrange(3):
    h = 0
    t = [s.copy() for s in tasks]
    d = [d.copy() for d in depends]
    f = set()
    while True:
        h += do_task(pos, f, t, d)
        if len(f) >= n:break
        h += 1
        pos = (pos + 1) % 3
    hours = min(hours, h)
print hours


def r(): return raw_input().strip()
def ri(): return int(r().strip())
def riv(): return map(int, r().split())

diff = {
    (1,1): 0,
    (2,2): 0,
    (3,3): 0,
    (1,2): 1,
    (1,3): 2,
    (2,1): 2,
    (2,3): 1,
    (3,1): 1,
    (3,2): 2
}

def main():
    n = ri()
    c = riv()

    a = []
    start, start_comp = None, 0
    down = set()
    for i in range(n):
        line = riv()[1:]
        a.append(line)
        if len(line) == 0 and start is None:
            start = i+1
            start_comp = c[i]

    hours = 1
    down.add(start)
    while len(down) < n:
        possible = {}
        for i, stage in enumerate(a):
            if i+1 not in down and all([s in down for s in stage]):
                comp = c[i]
                if comp not in possible:
                    possible[comp] = []
                possible[comp].append(i+1)

        if start_comp in possible:
            for l in possible[start_comp]:
                hours += 1
                down.add(l)
        else:
            nz = min(possible.items(), key=lambda z: diff[(start_comp, z[0])])
            hours += diff[(start_comp, nz[0])]
            start_comp = nz[0]
            for l in nz[1]:
                hours += 1
                down.add(l)

    print hours

if __name__ == "__main__":
    main()


s = input()
d = s.count("-")
o = s.count("o")
if d == 0 || o == 0:
    print("YES")
elif d % o == 0:
    print("YES")
else:
    print("NO")


def four(a, k):
    return min(abs(ord(a[k]) - ord('A')), abs(ord(a[k]) - (ord('A') + 26))) + \
           min(abs(ord(a[k + 1]) - ord('C')), abs(ord(a[k + 1]) - ord('C') - 26)) + \
           min(abs(ord(a[k + 2]) - ord('T')), abs(ord(a[k + 2]) - ord('T') - 26)) + \
           min(abs(ord(a[k + 3]) - ord('G')), abs(ord(a[k + 3]) - ord('G') - 26))

n = int(input())
s = input()
mx = 100000000
for i in range(len(s) - 3):
    m = four(s, i)
    if mx > m:
        mx = m

print(mx)


from collections import deque

n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
c50 = sum([1 for i in a if i == 50])
c100 = sum([1 for i in a if i == 100])
c = [[0] * 51 for i in range(51)]
c[0][0] = 1
c[1][0] = 1
c[1][1] = 1
for x in range(2, 51):
    for y in range(x + 1):
        c[x][y] = c[x - 1][y - 1] + c[x - 1][y]
d = [[[[0, float('inf')] for l in range(2)] for i in range(c100 + 1)] for j in range(c50 + 1)]
# d[i][j][c] ответ, когда мы переправили i по 50 кг и j по 100 кг и лодка на берегу c
d[0][0][0][0] = 1
d[0][0][0][1] = 0
q = deque()
q.append([0, 0, 0])
while len(q) > 0:
    i, j, shore = q.popleft()
    if d[i][j][shore][1] == float('inf'):
        continue
    for fifty in range(c50 - i + 1 if shore == 0 else i + 1):
        for hundreds in range(c100 - j + 1 if shore == 0 else j + 1):
            if fifty * 50 + hundreds * 100 > k or fifty + hundreds == 0:
                continue
            i1 = i + fifty if shore == 0 else i - fifty
            j1 = j + hundreds if shore == 0 else j - hundreds
            if d[i1][j1][1 ^ shore][1] > d[i][j][shore][1] + 1:
                d[i1][j1][1 ^ shore][1] = d[i][j][shore][1] + 1
                d[i1][j1][1 ^ shore][0] = 0
                q.append((i1, j1, 1 ^ shore)    )
            if d[i1][j1][1 ^ shore][1] < d[i][j][shore][1] + 1:
                continue
            koeff = (c[c50 - i][fifty] if shore == 0 else c[i][fifty]) * (
                c[c100 - j][hundreds] if shore == 0 else c[j][hundreds])
            d[i1][j1][1 ^ shore][0] += d[i][j][shore][0] * koeff
if d[c50][c100][1][1] == float('inf'):
    print(-1)
    print(0)
else:
    print(d[c50][c100][1][1])
    print(d[c50][c100][1][0])


#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import sys

MAXN = 110
MOD = 10 ** 9 + 7
INF = MOD

def MakeCom():
    global com
    com = [[1]]
    for i in xrange(1, MAXN + 1):
        line = [1]
        for j in xrange(1, i):
            line.append((com[-1][j - 1] + com[-1][j]) % MOD)
        line.append(1)
        com.append(line)

def ReadIn():
    data = [int(x) for x in sys.stdin.read().split()]
    offset = 0
    while offset < len(data):
        n, cap = data[offset : offset + 2]
        offset += 2
        friends = [0] * 2
        for x in data[offset : offset + n]:
            friends[x / 50 - 1] += 1
        offset += n
        yield cap, tuple(friends)

def merge(x, y):
    if y[0] < x[0]:
        return y
    elif y[0] > x[0]:
        return x
    else:
        return tuple([x[0], (x[1] + y[1]) % MOD])

def DFS(remain, cap, f, total):
    if remain in f:
        return f[remain]
    if remain[0] + 2 * remain[1] <= cap:
        f[remain] = (1, 1)
        return f[remain]
    f[remain] = (INF, 0)
    for x in xrange(remain[0] + 1):
        if x > cap: break;
        for y in xrange(remain[1] + 1):
            if x + y < 1: continue;
            if x + 2 * y > cap: break;
            tmp = [remain[0] - x, remain[1] - y]
            for i in xrange(2):
                if tmp[i] == total[i]: continue
                tmp[i] += 1
                nextRem = tuple(tmp)
                if nextRem != remain:
                    ret = DFS(nextRem, cap, f, total)
                    global com
                    ret = tuple([ret[0] + 2,
                        com[remain[0]][x] * com[remain[1]][y] * (total[i] - nextRem[i] + 1) * ret[1] % MOD])
                    f[remain] = merge(f[remain], ret)
                tmp[i] -= 1
    return f[remain]

def Solve(cap, friends):
    cap /= 50
    f = {(0, 0) : (0, 1)}
    ans = list(DFS(friends, cap, f, friends))
    if ans[0] == INF: ans[0] = -1
    for x in ans: print x

if __name__ == '__main__':
    MakeCom()
    for cap, friends in ReadIn():
        Solve(cap, friends)


n,m = list(map(int,input().split()))
def binomialCoeff(n , k):
    C = [0 for i in range(k+1)]
    C[0] = 1
    for i in range(1,n+1):
        j = min(i ,k)
        while (j>0):
            C[j] = C[j] + C[j-1]
            j -= 1
    return C
num = max(n,m)
mod = 10**9+7
b = binomialCoeff(num,num)
boxes = b[1:m+1]
boxes = sum(boxes)%mod
gift = sum(b[:n])%mod
print((boxes*gift)%mod)


from sys import stdin

def scal(typ=int):
  return typ(stdin.readline())

def vec(typ=int):
  if isinstance(typ, list):
    inp = stdin.readline().split()
    return [typ[i](inp[i]) for i in range(len(inp))]
  else:
    return list(map(typ, stdin.readline().split()))

n, m = vec()
print(((1 << m) - 1) ** n)


x, y = map(int, input().split())
p=1000000007
d = pow(2, x)-1
e = pow(2, y)-1
d=d*e
d=d%p
print(d)


import os, sys

# zeilen = [l.strip() for l in sys.stdin.readlines()]

n, m = map(int, sys.stdin.readline().strip().split())
print(((1<<m) - 1)**n % 1000000007)


a, b = map(int, input().split())
po = int(2**b - 1)
po = int(po**a)
M = 1000000007
print(po%M)


n,m = map(int,input().split());
print((2**m-1)**n)


import sys
import math
import itertools
import collections

def getdict(n):
    d = {}
    if type(n) is list or type(n) is str:
        for i in n:
            if i in d:
                d[i] += 1
            else:
                d[i] = 1
    else:
        for i in range(n):
            t = ii()
            if t in d:
                d[t] += 1
            else:
                d[t] = 1
    return d
def cdiv(n, k): return n // k + (n % k != 0)
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(map(int, input().split()))
def lcm(a, b): return abs(a*b) // math.gcd(a, b)
def wr(arr): return '\n'.join(map(str, arr))
def revn(n): return int(str(n)[::-1])
def prime(n):
    if n == 2: return True
    if n % 2 == 0 or n <= 1: return False
    sqr = int(math.sqrt(n)) + 1
    for d in range(3, sqr, 2):
        if n % d == 0: return False
    return True

n, m = mi()
print((2 ** m - 1) ** n)


#  n,m = input().split
import sys
n,m = map(int,sys.stdin.readline().split())
print(((2 ** m - 1) ** n) % 1000000007)


n=int(input())
que=[]
for i in range(n):
    a,b=[int(x) for x in input().split()]
    que.append((a-b,a,b))
que.sort(reverse=True)
counter=0
for i in range(n):
    counter+=que[i][1]*i+que[i][2]*(n-i-1)
print(counter)


#!python3
x,y,z = [int(i) for i in input().strip().split(' ')]
a,b,c = [int(i) for i in input().strip().split(' ')]
a -= x
if a >= 0
    a_b = a+b - y
    if a_b >= 0:
        a_b_c = a_b + c - z
        if a_b_c >= 0:
            print("YES")
            exit()
print("NO")


s = input()
if len(s)>2:
    s_right = s[0:len(s)//2]
    s_left = (s[len(s) - len(s)//2::])[::-1]
    if s_right == s_left and len(s)%2==0:
        print("NO")
    else:
        for i in range(len(s_right)):
            if s_right[0:i] + s_right[i+1::] == s_left[0:i] + s_left[i+1::]:
                print("YES")
                breakwd
        else:
            print("NO")
else:
    print("YES")


xp, yp, xv, yv = map(int, raw_input().split())

if xp<=xv and yp<=yv:
    print "Polycarp"
else:
    print "Vasiliy"


def int2base(num, base):
	c = "0123456789ABCDEF"
	if num<base:
		return c[num]
	else:
		return  int2base(num//base, base) + c[num%base]
def happy(num, g = 0):
	g += num%10
	if num != 0:
		return happy(num//10, g)
	return g

n = int(input())
l = []
for i in range(2, n):
	p = int2base(n, i)
	l.append(happy(int(p)))
k = sum(l)
print(f"{k}/{n-2}")


def title(s, k):
    s = list(s)

    # list of first k latin letters
    letters = list(string.lowercase[:k])
    # remove letters in s
    for l in s:
        if l != '?' and l in letters:
            letters.remove(l)

    # check palindromic property, fill in if necessary
    i, j = 0, len(s)-1
    while i<=j:
        # s[i] == s[j] -> ok
        # either s[i] or s[j] is '?' -> copy
        # both '?' -> pop missing letter
        if s[i] != s[j]:
            if s[i] == '?':
                s[i] = s[j]
            elif s[j] == '?':
                s[j] = s[i]
            else:
                return 'IMPOSSIBLE'
        elif s[i] == '?':
            # pop
            if len(letters) == 0:
                s[i] = s[j] = 'a'
            else:
                s[i] = s[j] = letters.pop(0)
        i += 1
        j -= 1

    if len(letters)>0:
        return 'IMPOSSIBLE'

    return ''.join(s)

k = int(raw_input())
s = raw_input()
print k, s
print title(s, k)


f __name__=="__main__":
	n,k = map(int,input().split())
	prime = [2]

	for i in range(3,n):
		#check if i is prime
		i_is_prime = True
		for j in range(2,int(i**0.5)+1):
			if i%j==0:
				i_is_prime = False
				break
		if i_is_prime:
			prime.append(i)
		#check if i can be express as sum of two prime
	#print(prime)
	count = 0
	for i in range(5,n):
		for j in range(len(prime)):
			if prime[j]<int(i/2):
				#print(prime[j]," + ",prime[j+1])
				if prime[j]+prime[j+1]+1 == i:
					#print(prime[j],"+",prime[j+1],"+1 =",i,"!!!")
					count+=1
					break
			else:
				break
	if(count>=k):
		print("YES")
	else:
		print("NO")


def pucci(n):
    if n < 9:
        return [2, 3, 5, 7, 11, 13]
    n *= 2
    l = [1] * n
    for i in range(2, int(n ** 0.5) + 1):
        if l[i - 1] == 1:
            for j in range(i ** 2, n + 1, i):
                if j % i == 0:
                    l[j - 1] = 0
    l[0] = 0
    l1 = []
    for i in range(n):
        if l[i] == 1:
            l1.append(i + 1)
    return l1

def mih(l, n):
    s = 0
    i = 0
    while l[i] <= 27:
        if l[i] + l[i + 1] + 1 in l[i + 2: ]:
            s += 1
        i += 1
    return s

n, k = map(int, input().split())
l = pucci(n)
if mih(l, n) >= k:
    print("YES")
else:
    print("NO")


a,b,c,d = map(int,input().split())

ans = 0
for x in range(a,b+1):
    for y in range(b,c+1):
        z = x + y - 1
        if z < c:continue
        ans += min(d,z) - c + 1
print(ans)


A,B,C,D = map(int,input().split())
arr = []
for i in range(A,B+1):
    for j in range(B,C+1):
        arr.append(i+j)
arr.sort(reverse=True)
Sum = 0
for i in range(C,D+1):
    ans = -1
    l = 0
    r = len(arr)-1
    while(l<=r):
        mid = (l+r)//2
        if (arr[mid]>i):
            ans = mid
            l = mid+1
        else:
            r = mid-1
    # print(ans)
    if (ans!=-1):
        Sum += ans+1
print(Sum)


a,b,c,d=map(int,input().split())
l=[]
for i in range(a,b+1):
    for j in range(b,c+1):
        for k in range(c,d+1):
            l.append((i+j,k))
c=0
for i in range(len(l)):
    if(l[i][0]>l[i][1]):
        c+=1
print(c)


n,a,b,p,q = map(int,raw_input().split(' '))
if p<q:
	a,b,p,q = b,a,q,p
t = n//a*p
for i in range(b,n+1,b):
	if i%a:
		t += q
print(t)


def read_row(s):
    row = []
    for item in s:
        if item == "W":
            row.append(1)
        elif item == "B":
            row.append(0)
        else:
            row.append(None)
    return row

table = []
for i in range(8):
    table.append(read_row(input()))

columns = []
for i in range(8):
    column = []
    for j in range(8):
        column.append(table[j][i])
    columns.append(column)

min_moves_for_a = 8
min_moves_for_b = 8

for col in columns:
    if (0 in col) & (1 in col):
        continue
    elif (0 in col) & not(1 in col):
        moves_for_b = 8 - col.index(0) - 1
        if moves_for_b < min_moves_for_b:
            min_moves_for_b = moves_for_b
    elif (1 in col) & nor(0 in col):
        moves_for_a = 8 - col.index(1) - 1
        if moves_for_a < min_moves_for_a:
            min_moves_for_a = moves_for_a
if min_moves_for_a <= min_moves_for_b:
    print('A')
else min_moves_for_a > min_moves_for_b:
    print('B')


"""
    This template is made by Satwik_Tiwari.
    python programmers can use this template :)) .
"""

#===============================================================================================
#importing some useful libraries.

import sys
import bisect
import heapq
from math import *
from collections import Counter as counter  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb # if a = [1,2,3] then print(list(comb(a,2))) -----> [(1, 2), (1, 3), (2, 3)]
from itertools import permutations as permutate
from bisect import bisect_left as bl #
from bisect import bisect_right as br
from bisect import bisect

#===============================================================================================
#some shortcuts

mod = pow(10, 9) + 7
def inp(): return sys.stdin.readline().strip() #for fast input
def out(var): sys.stdout.write(str(var))  #for fast output, always take string
def lis(): return list(map(int, inp().split()))
def stringlis(): return list(map(str, inp().split()))
def sep(): return map(int, inp().split())
def strsep(): return map(str, inp().split())
def graph(vertex): return [[] for i in range(0,vertex+1)]
def zerolist(n): return [0]*n
def nextline(): out("\n")  #as stdout.write always print sring.
def testcase(t):
    for p in range(t):
        solve()
def printlist(a) :
    for p in range(0,len(a)):
        out(str(a[p]) + ' ')
def lcm(a,b): return (a*b)//gcd(a,b)

#===============================================================================================
# code here ;))
def sieve(a): #O(n loglogn) nearly linear
    #all odd mark 1
    for i in range(3,((10**6)+1),2):
        a[i] = 1
    #marking multiples of i form i*i 0. they are nt prime
    for i in range(3,((10**6)+1),2):
        for j in range(i*i,((10**6)+1),i):
            a[j] = 0
    a[2] = 1 #special left case
    return (a)

a = [0]*((10**8)+1)
a = sieve(a)

def func(d):
    ans = 1
    if(d%2 == 0):
        x = 1
        while(d%(2**x) == 0):
            x+=1
        ans *= x
    for i in range(3,d+1,2):
        if(a[i] == 0 or d%i == 1):
            continue
        elif(d%i == 0):
            x = 1
            while(d%(i**x)==0):
                x+=1
            ans *=x
    return ans

def solve():
    a,b,c = sep()
    ans = 0
    for i in range(1,a+1):
        for j in range(1,b+1):
            for k in range(1,c+1):
                ans += (func(i*j*k))%1073741824
    print(ans%1073741824)

testcase(1)


a, b, c = map(int, input().split())

uniquenums = {}
ret = 0

def dfunc(n):
    score = 0
    for i in range(1,n+1):
        if n%i == 0:
            score += 1
    #print(n, score)
    return score

for i in range(1,a+1):
    for j in range(1,b+1):
        for k in range(1,c+1):
            mult = i * j * k
            if mult not in uniquenums:
                uniquenums[mult] = dfunc(mult)
            ret += uniquenums[mult]
#print(uniquenums)
print(ret%1073741824)


m='codeforce'
m=m.lower()
inp=int(input())
m=m+inp*'s'
print(m)


k=int(input())
s='codeforces'
s2='s'*(k-1)
print(s+s2)


def solve(k):
    return 'codeforces' + 's' * (k - 1)

K = int(input())
print(solve(K))


n = int(input())
s = [int(i) for i in input().split()]
a = sum(s)
t = max(s)
c = 0

while c<sum(s):
	for i in range(n):
		c+=max(s)-s[i]
	if c<sum(s):
		t+=1
	else:
		pass

print(t)


def run():
    n = long(raw_input())
    if n <= 127: return "byte"
    if n <= 32767: return "short"
    if n <= 2147483647: return "int"
    if n <= 9223372036854775807: return "long"
    return "BigInteger"

print run()


n = int(input())
li = []
lio = []
lie = []
for i in range(1,n+1):
    li.append(i)
for i in li:
    if i%2 != 0:
        lio.append(-i)
    else:
        lie.append(i)
print(sum(lio)+sum(lie))


n = int(input())
disp = []
for i in range(1,n+1):
    disp.append(i)
sum = 0
for i in disp:
    if i == 1 or i%2!=0:
        sum += -(i)
    else:
        sum += i
print(sum)


n = int(input()) +1
a = sum(list(range(0,n,2)))
b = sum(list(range(1,n,2)))
print(a-b)


n = int(input(""))
ans = 0

even = [i for i in range(1,n+1) if i % 2 == 0]
odd = [i for i in range(1,n+1) if i % 2 != 0]

for num in even:
    ans += num
for num in odd:
    ans -= num

print(ans)


n = int(input())
l=[]
for i in range(1,n+1):
    if i%2!=0:
        l.append(-i)
    else:
        l.append(i)
print(sum(l))


#http://codeforces.com/problemset/problem/831/A
def main(lst):
	if(lst[0]>lst[1]):
		return "NO"
	#0-increasing, 1-staying, 2-decreasing
	status=0
	for i in range(len(lst)-1):
		if(status==0):
			if(lst[i]==lst[i+1]):
				status+=1
			if(lst[i]>lst[i+1]): #assuming it MUST go constant
				status+=2
		if(status==1):
			if(lst[i]>lst[i+1]):
				status+=1
			if(lst[i]<lst[i+1]):
				return "NO"
		if(status==2):
			if(lst[i]>lst[i+1]):
				pass
			else:
				return "NO"
	return "YES"

input()
lst=input().split()
lst=[eval(i) for i in lst]
print(main(lst))


import math
n,k=map(int,input().split())
if(n%2==0):
    if(k>2):
        print('NO')
    else:
        print('YES')
else:
    c=0
    for i in range(3,int(math.sqrt(n))+1,2):
        if(n%i==0):
            if(k<i):
                print('YES')
            else:
                print('NO')
            c=1
            break
    if(c==0):
        print('YES')


x, y = map(int, input().split())
R = x*x + y*y
r = 1 + int((R-1)**.5)

print('black' if r*r==R or (r%2)^(x*y<=0) else 'white')


import sys
from math import *

w = 'white'
b = 'black'

def gcl(x, y):
    fc = sqrt(x**2 + y**2)
    c = int(fc)
    if c % 2 == 0:
        result = b
    else:
        result = w
    if not ((x > 0 and y > 0) or (y < 0 and x < 0)):
        if result == b:
            result = w
        else:
            result = b

    if c == fc:
        result = b
    return result

def main(argv=None):
    if argv is None:
        argv = sys.argv
    if len(sys.argv) != 3:
        return -1

    print( gcl(int(argv[1]), int(argv[2])) ),
    return 0

if __name__ == "__main__":
    sys.exit(main())


or i in range(int(input())):
    n, k, d = map(int, input().split())
    a = list(map(int, input().split()))
    mn = 1000000000000
    for i in range(n - d + 1):
        b = set(a[i : i + d])
        if len(b) < mn:
            mn = len(b)
    print(mn)


def getpos(digit):
    digit = int(digit)
    if digit == 0:
        return (3,1)
    digit -= 1
    return (digit // 3, digit % 3)

def main():
    ndig = int(input())
    number = input().strip()
    assert ndig == len(number)
    rlo = clo = 4
    rhi = chi = 0
    for digit in number:
        row, col = getpos(digit)
        rlo = min(row, rlo)
        rhi = max(row, rhi)
        clo = min(col, clo)
        chi = max(col, chi)
    rdiff = rhi-rho
    if rdiff == 3:
        print('YES')
    elif rdiff < 2:
        print('NO')
    elif chi - clo < 2:
        print('NO')
    elif '0' in number:
        print('NO')
    else if '7' in number or '9' in number:
        print('YES')
    else:
        print('NO')

main()


h,m,s,x,y=map(int,input().split())
h=h+m/60+s/3600
m=m/5
s=s/5
l=[h,m,s,x,y]
l.sort()
z=(l.index(x)-l.index(y))
if(z==1 or z==4):
	print("YES")
else:
	print("NO")

    h,m,s,x,y=map(int,input().split())
    h=h+m/60+s/60
    m=m/5
    s=s/5
    l=[h,m,s,x,y]
    l.sort()
    z=(l.index(x)-l.index(y))
    if(z==1 or z==4):
    	print("YES")
    else:
    	print("NO")


ls -l | python -c "import sys;[sys.stdout.write(' '.join([line.split(' ')[-1]])) for line in sys.stdin]"


#!/usr/bin/env python

from sys import stdin

def main():
   x, y, z = map(int, stdin.readline().split())
   x1, y1, z1 = map(int, stdin.readline().split())
   A = map(int, stdin.readline().split())
   res = 0
   if y < 0:  res += A[0]
   if y > y1: res += A[1]
   if z < 0:  res += A[2]
   if z > z1: res += A[3]
   if x < 0:  res += A[4]
   if x > z1: res += A[5]
   print res
   return 0

if __name__ == '__main__': main()


def subtract(p1, p2):
    return [a-b for a, b in zip(p1, p2)]

def add(p1, p2):
    return [a+b for a, b in zip(p1, p2)]

def within(p, mid):
    withi = True
    for x in xrange(3):
        if not(p[x]/2.0 <= mid[x] and p[x] >= 0):
            withi = False
            break
    return withi

def intersect(p1, p2, p3, N):
    denominator = sum([a*b for a, b in zip(N, subtract(p2, p1))])
    if denominator == 0:
    #    print denominator
        return True
    numerator = sum([a*b for a, b in zip(N, subtract(p3, p1))])
    u = numerator*1.0/denominator
    #print u
    p = add(p1, map(lambda(x): x*u, subtract(p2, p1)))
    if u > 0 and u < 1 and within(p, p3):
        return True
    return False

def start():
    p = map(int, raw_input().split())
    x, y, z = map(int, raw_input().split())
    faceValue = map(int, raw_input().split())
    N = [[0,1,0],[0,1,0],[0,0,1],[0,0,1],[1,0,0],[1,0,0]]
    P = [[x/2.0, 0, z/2.0],[x/2.0, y, z/2.0],[x/2.0, y/2.0, 0],[x/2.0, y/2.0, z],[0, y/2.0, z/2.0],[x, y/2.0, z/2.0]]
    sumFaces = 0
    for x in xrange(6):
        poss = True
        #print 'face %s' % (x)
        for y in xrange(6):
            if x != y:
                intersct = intersect(p, P[x], P[y], N[y])
        #        print 'point %s, intersects with plane %s, %s' %(x+1, y+1, intersct)
                poss = poss and not intersct
        if poss:
            sumFaces += faceValue[x]
    print sumFaces

start()


import sys
#input = sys.stdin.buffer.readline

INF = 100000000
n1 , n2 , K1 , K2 = [int(i) for i in input().split()]
dp = [ [[ [0 for k2 in range(K2 +1)] for k1 in range(K1 + 1)] for j in range(n2+1) ] for i in range(n1+1) ]
def rep(i,j,k1,k2,K1,K2):
    if k1 > K1 or k2 > K2:return 0
    if i == 0 and j == 0 :return 1
    if i == -1 or j == -1:return 0
    if dp[i][j][k1][k2] != 0:return dp[i][j][k1][k2]

    # Select elephant
    ansE = rep( i - 1 , j      , k1 + 1 , 0      , K1 , K2 ) % INF

    # Select dog
    ansD = rep( i     , j - 1  , 0      , k2 + 1 , K1 , K2) % INF

    ans = (ansE + ansD) % INF
    dp[i][j][k1][k2] = ans
    return ans

print(rep(n1,n2,0,0,K1,K2))


s = input()
in1 = s.split(' ')

R = int(in1[0])
B = int(in1[1])

print(R==B)


n=int(input())
while(n>0):
    an=map(int,input().split())
    n=n-1
count=0
for(i in range(n)):
    for(j in range(n)):
        if(ai[0]==aj[1]):
            count+=1
print(count)


import time
h,m = input().split(":")
mins = int(input())
h=int(h)
m=int(m)
h += int((mins+m)/60)
h= h%24
m = (mins+m)%60
if h<10: print("0"+h,end=":")
else: print(h,end=":")
if m<10: print("0"+m)
else: print(m)


 n=int(input())
l=[]
k=0
for i in range(n):
    l.append(list(map(int,input().split())))
for i in range(n):
    for j in range(n):
        if l[i][0]==l[j][1]:
            k+=1
print((k))


arr = list(map(int, input().split()))
t1 = 0
t2 = 0
def main():
	global t1
	global t2
	global arr
	i = 0
	arr = sorted(arr)
	tmp = arr
	while i < len(tmp):
		t1 += tmp[i]
		tmp.pop(i)
		t1 += tmp[i]
		tmp.pop(i)
		j = 0
		while j < tmp:
			t1 += tmp[j]
			tmp.pop(j)
			for c in tmp:
				t2 += c
			j+=1
		i+=1

	while i < len(arr):
		t1 += arr[i]
	if t1 == t2:
		print("YES")
	else:
		print("NO")
if __name__ == "__main__":
	main()


a=int(input())
b=int(input())
c=int(input())
a=a//1
b=b//2
c=c//4
s=0
if a<b and a<c:
   s=a*7
if a<=b and a<=c:
    s=a*7
if b<a and b<c:
   s=(b+1)*7
if b<=a and b<=c:
    s=b*7
if c<a and c<b:
   s=c*7
if c<=a and c<=b:
    s=c*7
print(s)


l = [input() for _ in range(4)]

m = list(map(lambda x : len(x[2:]),l))

res = []

for i in l :
  y = 1
  r1 = True
  r2 = True
  for j in l :
    if i != j :
      if (len(i[2:]) >= len(j[2:])*2) and  r1 :
        y *= 1
        r2 = False
      elif (len(i[2:]) <= len(j[2:])/2) and r2:
        r1 = False
        y *= 1
      else :
        y *= 0
        break

  res.append(y)

if res.count(0) == 4 :
  print('C')
elif res.count(1) > 1 :
  print('C')

else:


import math

def lucky_gen():
    current = ['4']
    while True:
        yield int(''.join(current))
        for i in range(len(current)-1, -1, -1):
            if current[i] == '4':
                current[i] = '7'
                break
            else:
                current[i] = '4'
                if i == 0:
                    current.insert(0, '4')

def sub_str(num):
    n_str = str(num)
    for i in range(1, len(n_str)+1):
        for j in range(len(n_str) - i + 1):
            yield n_str[j:j+i]

num = int(input())
str_num = str(num)
while num % 10 == 0:
    num //= 10

result = {}

for sub in sub_str(num):
    if sub in result.keys():
        continue
    success = False
    for i in sub:
        if not i in ['4', '7']:
            success = False
            break
    else:
        success = True
    if not success:
        continue

    i = 0
    sub_str_amount = 0
    while i < len(str_num):
        try:
            i = str_num.index(sub, i) + 1
            sub_str_amount += 1
        except ValueError:
            break
    result[sub] = sub_str_amount

answer = (0, '777')
for key in result.keys():
    if answer[0] < result[key] or (answer[0] == result[key] and answer[1] > key):
            answer = (result[key], key)
if answer[0] == 0:
    print(-1)
else:
    print(answer[1])


s=input()
l=''
n=len(s)
n-=1
m=0
if n==0:
    print(s)
else:
    while len(l)!=len(s):
        l=s[n]+l
        n-=1
        l=s[m]+l
        m+=1

    print(l)


for i in range(4):
	st = input()
	lista[i] = st.split(" ")

print(lista)
def ff(n):
	if n ==0 :
		return 3
	if n%2==0:
		return n+1
	else:
		return n-1

def rec(lista):
	for i in range(len(lista)):
		for j in range(len(lista[i])):
			if lista[i][3] == lista[i][j] == 1:
			   print("YES")
                break
			if lista[i][j] == lista[ff(j)][3] == '1' :
				print("YES")
				break

rec(lista)


from collections import deque

w, d = map(int, raw_input().split())

def is_princess(x, y):
  return (w + d - x - y) % 3 == 0

dp = [[0.0 for j in range(d + 1)] for i in range(w + 1)]
dp[w][d] = 1.0

Q = deque([(w, d)])
P = 0.0

while Q:
  x, y = Q.popleft()

  if is_princess(x, y):
    if dp[x][y] < 1e-10:
      if x < w and y < d:
        dp[x][y] += dp[x+1][y+1] * (y + 1) / (x + 1 + y + 1) * (x + 1) / (x + 1 + y)
      if y + 1 < d:
        dp[x][y] += dp[x][y+2] * (y + 2) / (x + y + 2) * (y + 1) / (x + y + 1)

    if y > 0:
      Q.append((x, y - 1))

  else:
    if dp[x][y] < 1e-10:
      if y < d:
        dp[x][y] += dp[x][y + 1] * (y + 1) / (x + y + 1)
    if y > 0:
      Q.append((x - 1, y - 1))
    if y > 1:
      Q.append((x, y - 2))

  # print x, y, dp[x][y]

for x in range(1, w + 1):
  for y in range(d + 1):
    if is_princess(x, y):
      P += dp[x][y] * x / (x + y)

# print dp
print P


n, a, b, c = map(int, input().split())
count = 0
for ci in range(c + 1):
  x = n - 2 * ci
  if x < 0:
    break
  for bi in range(b + 1):
    y = x - bi
    if y < 0:
      break
    if 2 * y <= a:
      count += 1

print(count)


n, a, b, c = map(int, input().split())
print(sum(n - i // 2 - 2 * j in range(0, b + 1) for i in range(0, a + 1, 2) for j in range(c + 1)))


def really_big(k, s):
    return k - sum([int(x) for x in str(k)]) >= s

def find_big(n, k):
    if not really_big(n, k):
        return 0

    min = n
    while True:
        if really_big(min, k):
            if not really_big(min - 1, k):
                break
            min = min/2
        else:
            min += (n - min)/2

    return n - min + 1

ip = raw_input().split(' ')
print find_big(int(ip[0]), int(ip[1]))


from itertools import permutations
n, L = list(map(lambda x: int(x), input().split()))
k = list(map(lambda x: int(x), input().split()))
s = list(map(lambda x: int(x), input().split()))
j = 1
for i in range(L):
    for x in range(len(s)):
        s[x] += 1
        if s[x] == L:
            s[x] = 0
    if any(tuple(k) == y for y in list(permutations(s))):
        print('YES')
        j = 0
        break
if j == 1:
    print('NO')


input1=(list(map(int,input().split())))
K=(list(map(int,input().split())))
S=(list(map(int,input().split())))
n=input1[0]
l=input1[1]
Klist=[]
for i in range(1,len(K)):
Klist.append(K[i]-K[i-1])
max=0
for i in range(0,len(Klist)):
max+=Klist[i]
Klist.append(l-max)
Slist=[]
for i in range(1,len(S)):
Slist.append(S[i]-S[i-1])
max=0
for i in range(0,len(Slist)):
max+=Slist[i]
Slist.append(l-max)
count=0
T=False
var=0
while count<len(Klist)+1:
if Slist==Klist:
T=True
break
else:
count+=1
var=Klist[0]
del Klist[0]
Klist.append(var)
if T:
print('YES')
else:
print('NO')


#!/usr/bin/env python
"""
This file is part of https://github.com/Cheran-Senthil/PyRival.

Copyright 2018 Cheran Senthilkumar all rights reserved,
Cheran Senthilkumar <hello@cheran.io>
Permission to use, modify, and distribute this software is given under the
terms of the MIT License.

"""
from __future__ import division, print_function

import cmath
import itertools
import math
import operator as op
# import random
import sys
from atexit import register
from bisect import bisect_left, bisect_right
# from collections import Counter, MutableSequence, defaultdict, deque
# from copy import deepcopy
# from decimal import Decimal
# from difflib import SequenceMatcher
# from fractions import Fraction
# from heapq import heappop, heappush

if sys.version_info[0] < 3:
    # from cPickle import dumps
    from io import BytesIO as stream
    # from Queue import PriorityQueue, Queue
else:
    # from functools import reduce
    from io import StringIO as stream
    # from pickle import dumps
    # from queue import PriorityQueue, Queue

if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)

        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)

        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)

    input = raw_input
    range = xrange

    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip

def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.

    Args:
        sync (bool, optional): The new synchronization setting.

    """
    global input, flush

    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')

        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def gcd(x, y):
    """greatest common divisor of x and y"""
    while y:
        x, y = y, x % y
    return x

def ntt(a, invert=False):
    j = 0
    for i in range(1, len(a)):
        bit = len(a) >> 1
        while j & bit:
            j ^= bit
            bit >>= 1
        j ^= bit

        if i < j:
            a[i], a[j] = a[j], a[i]

    length, cnt = 2, 1
    while length <= len(a):
        wlen = pow(3, 998244353 - 1 - (998244353 - 1 >> cnt) if invert else 998244353 - 1 >> cnt, 998244353)

        for i in range(0, len(a), length):
            w = 1
            for j in range(i, i + length // 2):
                u = a[j]
                v = (a[j + length//2] * w) % 998244353

                a[j] = u + v if u + v < 998244353 else u + v - 998244353
                a[j + length//2] = u - v if u - v >= 0 else u - v + 998244353

                w = (w * wlen) % 998244353

        cnt += 1
        length <<= 1

    if invert:
        n_1 = pow(len(a), 998244351, 998244353)
        for i in range(len(a)):
            a[i] = (a[i] * n_1) % 998244353

def main():
    n, _ = map(int, input().split(' '))

    d = [0] * 1048576
    for i in map(int, input().split(' ')):
        d[i] = 1

    ntt(d)
    d = list(map(lambda x: pow(x, n//2, 998244353), d))
    ntt(d, True)

    print(sum(i*i for i in d) % 998244353)

if __name__ == '__main__':
    sync_with_stdio(False)
    main()