logo AlgoBeat OnlineJudge
登录 注册

#213785. [NWERC 2023] Fixing Fractions

内存限制:2048 MiB 时间限制:5000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Maths is hard. But it could be easier! And the internet™ has found some excellent ways to make it easier.

:::align{center} Source: The Internet™. :::

Take a look at the following true equations:

Following the patterns, we come to the conclusion that the following equation should also be true:

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 , , , and (), describing the two fractions and .

输出格式

If there exist integers and obtained from and by cancelling out the same digits and with in standard mathematics, output "", followed by and . Otherwise, output "".

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

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

样例

样例输入 1

163 326 1 2

样例输出 1

possible
1 2

样例输入 2

871 1261 13 39

样例输出 2

possible
87 261

样例输入 3

123 267 12339 23679

样例输出 3

impossible