PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000289. Xóa bảng và khôi phục hai số (Wipe Your Whiteboards)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Xóa bảng và khôi phục hai số (Wipe Your Whiteboards)

Wipe Your Whiteboards

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

A whiteboard shows an incomplete calculation from the extended Euclidean algorithm. Its two original positive integer inputs AA and BB have been erased. Three remaining integers R,S,QR,S,Q are known to satisfy

AR+BS=Q.AR+BS=Q.

Find positive integers A,BA,B satisfying the equality. Among all such pairs, minimize AA; then minimize BB if necessary. The input guarantees a positive integer solution exists.

Input

One line containing three integers R,S,QR,S,Q in that order.

Output

Print two positive integers A,BA,B, the required optimal pair, separated by one space.

Subtasks

  • Subtask 1 (20 points): 2≤R≤1002\le R\le100; −100≤S≤−2-100\le S\le-2; 1≤Q≤10001\le Q\le1000; QQ is divisible by gcd⁡(R,∣S∣)\gcd(R,|S|).
  • Subtask 2 (30 points): 2≤R≤1052\le R\le10^5; −105≤S≤−2-10^5\le S\le-2; 1≤Q≤1051\le Q\le10^5; QQ is divisible by gcd⁡(R,∣S∣)\gcd(R,|S|).
  • Subtask 3 (50 points): 2≤R≤1082\le R\le10^8; −108≤S≤−2-10^8\le S\le-2; 1≤Q≤1081\le Q\le10^8; QQ is divisible by gcd⁡(R,∣S∣)\gcd(R,|S|).

Examples

Input

3 -5 15

Output

10 3

Explanation

For A=10,B=3A=10,B=3, we get 3⋅10−5⋅3=153\cdot10-5\cdot3=15. No smaller positive value of AA can yield a positive integer BB satisfying the equation, so the pair is optimal.