P,Q,Y,p,q,Z=map(int,input().split()) print((p+~Y+Z)%P+1,(q+~Y+Z)%Q+1)