PivotOJ

Fixing Fractions

시간 제한: 1000ms메모리 제한: 1024MB출처: NWERC 2023BOJ 30903

문제

Maths is hard.[citation needed] But it could be easier! And the internet™ has found some excellent ways to make it easier. Take a look at the following true equations:

Following the patterns, we come to the conclusion that the following equation should also be true:\vspace{-0.75\baselineskip}

However, this is actually wrong in boring old standard maths. Therefore, we define a new kind of funky maths where it is allowed to cancel out digits on the left side of the equality sign. This surely will make everyone's life easier. Except yours, since you have to evaluate if two given fractions are equal in our new funky maths.

입력

The input consists of:

  • One line with four integers aa, bb, cc, and dd (1a,b,c,d<10181\leq a,b,c,d<10^{18}), describing the two fractions ab\frac{a}{b} and cd\frac{c}{d}.

출력

If there exist integers aa' and bb' obtained from aa and bb by cancelling out the same digits and with ab=cd\frac{a'}{b'} = \frac{c}{d} in standard mathematics, output "possible", followed by aa' and bb'. Otherwise, output "impossible".

If there are multiple valid solutions, you may output any one of them.

Note that neither aa' nor bb' is allowed to contain leading zeroes after cancelling digits.

예제

예제 1

입력
163 326 1 2
출력
possible
1 2

예제 2

입력
871 1261 13 39
출력
possible
87 261

예제 3

입력
123 267 12339 23679
출력
impossible
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.