p,q,dy,dp,dq,y = map(int,input().split()) ansp = ((y-dy)%p + dp)%p ansq = ((y-dy)%q + dq)%q print(ansp,ansq)