P21427 [HackerEarth] Alice likes digits very much. She thinks some digits are lucky digits. She also calls numbers consisting ALL the lucky digits at least once as lucky numbers. Please note that the lucky n
提高-
题目描述

Alice likes digits very much. She thinks some digits are lucky digits. She also calls numbers consisting ALL the lucky digits at least once as lucky numbers. Please note that the lucky number should contain no digits other than lucky digits, but the lucky digits can appear any number of times in the lucky number.

Now your task is given a positive number x and a list of lucky digits, find the least positive multiple
of x which is a lucky number.

Input

The first line of the input is an integer N, the number of test cases. N is not larger than 100. Each test case contains 2 lines.

The first line of each test case is the list of lucky digits.It contains no more than 10 different digits.

The second line of each test cases is the number x. x is not larger than 999.

Output

For each test case if you can find the answer y, please output something like "y = x * n" in a single line. Otherwise output "Impossible" in a single line. See the sample for more
detailed information.

Explanation for Sample Input/Output

22 = 11 * 2 is not valid solution for test case as 22 is not a lucky number. A lucky number should contain all the lucky digits. Hence, 2233 is a lucky number while 22 is not.

SAMPLE INPUT
5
2 3
11
0 1
2
4 3 2 1
5
0
10
9
9

SAMPLE OUTPUT
2233 = 11 * 203
10 = 2 * 5
Impossible
Impossible
9 = 9 * 1

输入格式

见题面

输出格式

见题面

样例输入
100 4 5 8 3 561 6 9 3 8 4 5 734 7 3 5 6 274 8 1 3 7 148 9 4 3 1 0 2 8 809 6 4 9 3 1 0 544 9 5 6 516 9 1 5 5 1 9 6 0 3 821 8 6 44 2 4 5 3 0 686 7 8 2 3 6 254 6 3 5 593 5 0 9 8 3 2 931 8 6 633 4 6 3 5 936 6 4 531 8 2 4 5 7 670 9 7 0 6 8 24 6 2 7 5 4 779 7 0 3 9 6 5 8 840 6 0 9 4 212 9 5 6 1 2 4 8 931 2 7 6 0 1 8 4 248 7 6 0 8 5 528 3 2 8 1 5 7 0 4 979 8 1 9 7 951 7 9 5 6 2 494 3 9 8 1 7 6 588 9 8 1 6 5 550 5 8 4 0 2 3 28 2 4 0 5 9 3 598 3 9 1 257 8 5 1 0 9 3 57 8 3 1 5 9 4 2 768 9 6 7 717 9 6 2 0 4 3 870 9 7 1 6 5 395 5 0 4 1 9 3 8 172 2 5 0 697 3 6 0 4 1 2 669 5 4 7 3 8 0 1 336 9 0 1 8 2 7 4 301 2 6 0 3 360 4 3 8 9 1 5 2 23 5 4 1 2 614 2 7 4 5 8 1 3 6 273 5 4 0 3 652 3 4 9 1 703 8 4 2 9 3 883 5 9 0 7 236 6 8 1 3 4 788 8 9 0 3 7 393 3 6 1 7 9 4 280 7 5 6 3 1 2 969 5 9 2 0 6 178 9 7 3 2 5 980 6 3 0 7 2 536 5 7 8 4 159 8 5 7 0 1 2 117 3 6 2 1 9 5 486 7 4 8 5 2 0 1 6 617 8 1 5 742 3 810 8 2 4 864 7 0 5 6 461 1 7 0 3 110 4 8 9 3 1 7 442 1 7 0 8 3 881 6 9 0 4 1 3 2 824 7 0 4 6 538 9 6 8 2 7 4 737 4 7 9 2 3 0 932 3 6 7 9 0 4 133 1 7 0 743 9 1 457 5 7 0 703 3 5 7 1 9 2 4 342 9 7 8 129 5 1 2 6 7 4 271 9 3 6 7 488 5 8 9 2 929 2 3 9 1 6 4 3 9 6 7 4 2 0 919 6 1 8 2 898 3 1 8 6 2 4 574 7 8 5 2 3 6 1 840 4 6 5 7 0 8 1 382 4 0 6 3 8 2 120 9 0 8 202 9 6 3 5 872 9 8 4 2 0 3 323 9 1 8 777 7 9 6 3 8 4 5 0 610 7 6 0 2 308 5 6 7 4 999 7 1 3 5 754 9 0 2 4 7 881 5 2 9 3 15 9 7 2 0 5 4 749
样例输出
8898448 = 716 * 12428 3192076 = 866 * 3686 1330879 = 647 * 2057 22939 = 29 * 791 136789000 = 250 * 547156 1198470 = 910 * 1317 497015 = 535 * 929 759 = 11 * 69 23489568 = 864 * 27187 207984 = 28 * 7428 9999900 = 492 * 20325 4449949999 = 769 * 5786671 29946 = 713 * 42 3088098 = 318 * 9711 70656 = 276 * 256 555555555555555555 = 665 * 835421888053467 671908 = 164 * 4097 158288 = 761 * 208 784312 = 632 * 1241 10654827 = 379 * 28113 10459867 = 367 * 28501 Impossible 1066968 = 126 * 8468 Impossible 45440 = 355 * 128 550172 = 686 * 802 12479880 = 840 * 14857 4668795 = 765 * 6103 10795234 = 662 * 16307 1067922 = 237 * 4506 2905874 = 382 * 7607 10215348 = 858 * 11906 47334 = 147 * 322 201894 = 483 * 418 440747 = 613 * 719 12236478 = 402 * 30439 2002200 = 376 * 5325 268780 = 178 * 1510 13858 = 41 * 338 69230 = 602 * 115 10245483 = 477 * 21479 94848 = 456 * 208 95030000 = 688 * 138125 Impossible 1056704 = 836 * 1264 71932 = 196 * 367 Impossible 10123466859 = 621 * 16301879 10229112 = 639 * 16008 216048 = 112 * 1929 744744 = 104 * 7161 107912 = 376 * 287 Impossible Impossible 25704 = 153 * 168 13466925 = 225 * 59853 203754896 = 424 * 480554 497260 = 940 * 529 58968 = 84 * 702 30957 = 607 * 51 3601598 = 539 * 6682 463128 = 839 * 552 9480 = 632 * 15 1004275 = 289 * 3475 1367905 = 595 * 2299 3459778 = 587 * 5894 Impossible 447447744 = 576 * 776819 102245895 = 405 * 252459 957899 = 493 * 1943 59920 = 856 * 70 463935 = 785 * 591 3049780 = 620 * 4919 735980 = 980 * 751 15225 = 203 * 75 10148976 = 246 * 41256 1011345678 = 9 * 112371742 3398465 = 445 * 7637 5138973 = 813 * 6321 2066386 = 721 * 2866 1174344 = 668 * 1758 97584 = 228 * 428 121699 = 929 * 131 636636 = 371 * 1716 33355344 = 484 * 68916 91191991 = 869 * 104939 751482 = 503 * 1494 6776 = 242 * 28 498100 = 425 * 1172 555555555555555555555555555 = 999 * 556111667222778333889445 Impossible 41262 = 529 * 78 122764 = 188 * 653 Impossible Impossible 1495802 = 847 * 1766 96432 = 112 * 861 340458 = 951 * 358 1425089 = 313 * 4553 4444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444 = 257 * 17293558149589277993947254647643752702118460873324686554258538694336359706009511456982274102896670990056204063986165153480328577604842196281884997838305231301340250756593169044530912235192390834414180717682663207955036748811067877215737137916126242974492