382A.md (1837B)
1 Source: https://codeforces.com/problemset/problem/382/A 2 3 A. Ksenia and Pan Scales 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 Ksenia has ordinary pan scales and several weights of an equal mass. Ksenia has already put some weights on the scales, while other weights are untouched. Ksenia is now wondering whether it is possible to put all the remaining weights on the scales so that the scales were in equilibrium. 22 23 The scales is in equilibrium if the total sum of weights on the left pan is equal to the total sum of weights on the right pan. 24 25 Input 26 27 The first line has a non-empty sequence of characters describing the scales. In this sequence, an uppercase English letter indicates a weight, and the symbol "|" indicates the delimiter (the character occurs in the sequence exactly once). All weights that are recorded in the sequence before the delimiter are initially on the left pan of the scale. All weights that are recorded in the sequence after the delimiter are initially on the right pan of the scale. 28 29 The second line contains a non-empty sequence containing uppercase English letters. Each letter indicates a weight which is not used yet. 30 31 It is guaranteed that all the English letters in the input data are different. It is guaranteed that the input does not contain any extra characters. 32 33 Output 34 35 If you cannot put all the weights on the scales so that the scales were in equilibrium, print string "Impossible". Otherwise, print the description of the resulting scales, copy the format of the input. 36 37 If there are multiple answers, print any of them. 38 39 Examples 40 41 Input 42 43 ``` 44 AC|T 45 L 46 ``` 47 48 Output 49 50 ``` 51 AC|TL 52 ``` 53 54 Input 55 56 ``` 57 |ABC 58 XYZ 59 ``` 60 61 Output 62 63 ``` 64 XYZ|ABC 65 ``` 66 67 Input 68 69 ``` 70 W|T 71 F 72 ``` 73 74 Output 75 76 ``` 77 Impossible 78 ``` 79 80 Input 81 82 ``` 83 ABC| 84 D 85 ``` 86 87 Output 88 89 ``` 90 Impossible 91 ```