p, q, y0, p0, q0, y = read_line.split.map(&.to_i) p0 = (p0 - 1 + (y - y0)) % p + 1 q0 = (q0 - 1 + (y - y0)) % q + 1 puts "#{p0} #{q0}"