scale = input().split('|')
untouched_weight = list(input())
left_scale = list(scale[0])
right_scale = list(scale[1])
for x in untouched_weight:
switch = 'r' if len(left_scale) > len(right_scale) else 'l'
if switch == 'r':
right_scale.append(x)
else:
left_scale.append(x)
print("".join(left_scale) + "|" + "".join(right_scale) if len(left_scale) == len(right_scale) else 'Impossible')
#include<iostream>
#include<algorithm>
#include<string>
#include "vector"
#include<stack>
using namespace std;
int main()
{
vector<string>list1,list2;
string word1,word2,t,m;
long long num,c=0,v=0,a=0,b=0,max=1;
char l;
bool test=false;
cin>>word1>>word2;
while(1)
{
if (word1[c]!='|')
{
a++;
t+=word1[c];
c++;
}
else break;
}
for (int i =c+1 ; i <word1.size(); i++)
{
b++;
m+=word1[i];
}
if (a<b)
{
if (a+word2.size()==b)
{
t+=word2;
cout<<t<<"|"<<m<<endl;
}else if (a+word2.size()>b)
{
for (int i = 0; i < b-a; i++)
{
t+=word2[0];
word2.erase(word2.begin());
}
if (word2.size()%2==0)
{
for (int i = 0; i < word2.size(); i+=2)
{
t+=word2[i];
m+=word2[i+1];
}
cout<<t<<"|"<<m<<endl;
}
else cout<<"Impossible"<<endl;
}else cout<<"Impossible"<<endl;
}
else if(b<a)
{
if (b+word2.size()==a)
{
m+=word2;
cout<<t<<"|"<<m<<endl;
}else if (b+word2.size()>a)
{
for (int i = 0; i < a-b; i++)
{
m+=word2[0];
word2.erase(word2.begin());
}
if (word2.size()%2==0)
{
for (int i = 0; i < word2.size(); i+=2)
{
t+=word2[i];
m+=word2[i+1];
}
cout<<t<<"|"<<m<<endl;
}
else cout<<"Impossible"<<endl;
} else cout<<"Impossible"<<endl;
}
else
{
if (word2.size()%2==0)
{
for (int i = 0; i < word2.size(); i+=2)
{
t+=word2[i];
m+=word2[i+1];
}
cout<<t<<"|"<<m<<endl;
}
else cout<<"Impossible"<<endl;
}
}
1395A - Boboniu Likes to Color Balls | 1637C - Andrew and Stones |
1334B - Middle Class | 260C - Balls and Boxes |
1554A - Cherry | 11B - Jumping Jack |
716A - Crazy Computer | 644A - Parliament of Berland |
1657C - Bracket Sequence Deletion | 1657B - XY Sequence |
1009A - Game Shopping | 1657A - Integer Moves |
230B - T-primes | 630A - Again Twenty Five |
1234D - Distinct Characters Queries | 1183A - Nearest Interesting Number |
1009E - Intercity Travelling | 1637B - MEX and Array |
224A - Parallelepiped | 964A - Splits |
1615A - Closing The Gap | 4C - Registration System |
1321A - Contest for Robots | 1451A - Subtract or Divide |
1B - Spreadsheet | 1177A - Digits Sequence (Easy Edition) |
1579A - Casimir's String Solitaire | 287B - Pipeline |
510A - Fox And Snake | 1520B - Ordinary Numbers |