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. 

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.


-----Input-----

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. 

The second line contains a non-empty sequence containing uppercase English letters. Each letter indicates a weight which is not used yet. 

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.


-----Output-----

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.

If there are multiple answers, print any of them.


-----Examples-----
Input
AC|T
L

Output
AC|TL

Input
|ABC
XYZ

Output
XYZ|ABC

Input
W|T
F

Output
Impossible

Input
ABC|
D

Output
Impossible

Difficulty: EASY
Tags: Implementation

Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
nm = list(map(str, input().split('|')))
s = list(input())
n = nm[0]
m = nm[1]
while s:
	if len(n) <= len(m):
		n = n + s.pop(0)
	else:
		m = m + s.pop(0)
if len(n) == len(m):
	print(n + '|' + m)
else:
	print('Impossible')


(a, b) = input().split('|')
c = input()
t = abs(len(a) - len(b))
C = len(c)
if (C - t) % 2 or C < t:
	print('Impossible')
	exit()
while len(a) < len(b):
	a += c[0]
	c = c[1:]
while len(b) < len(a):
	b += c[0]
	c = c[1:]
print(a + c[::2] + '|' + b + c[1::2])


a = input().split('|')
b = input()
x = len(a[0])
y = len(a[1])
z = len(b)
if x == y and z % 2 == 0:
	r = a[0] + b[:z // 2] + '|' + a[1] + b[z // 2:]
	print(r)
elif x == y and z % 2 != 0:
	print('Impossible')
elif x > y and x - y <= z and ((z - (x - y)) % 2 == 0):
	r = a[0] + b[:(z - (x - y)) // 2] + '|' + a[1] + b[(z - (x - y)) // 2:]
	print(r)
elif y > x and y - x <= z and ((z - (y - x)) % 2 == 0):
	r = a[0] + b[(z - (y - x)) // 2:] + '|' + a[1] + b[:(z - (y - x)) // 2]
	print(r)
else:
	print('Impossible')


(scale_1, scale_2) = map(str, input().split('|'))
remain_weight = str(input())
if len(scale_1) == len(scale_2) and len(remain_weight) & 1 != 0 or len(scale_1) + len(remain_weight) < len(scale_2) or len(scale_2) + len(remain_weight) < len(scale_1):
	print('Impossible')
elif len(scale_1) + len(scale_2) == len(remain_weight):
	weight_dist = list(remain_weight)
	for i in range(len(weight_dist)):
		if len(scale_1) < len(scale_2):
			scale_1 += weight_dist[i]
		else:
			scale_2 += weight_dist[i]
	print(scale_1 + '|' + scale_2)
elif len(scale_1) + len(scale_2) == 0 and len(remain_weight) & 1 == 0:
	weight_dist = list(remain_weight)
	for i in range(len(weight_dist)):
		if len(scale_1) < len(scale_2):
			scale_1 += weight_dist[i]
		else:
			scale_2 += weight_dist[i]
	print(scale_1 + '|' + scale_2)
elif len(scale_1) > len(scale_2):
	weight_dist = list(remain_weight)
	for i in range(len(weight_dist)):
		if len(scale_1) > len(scale_2):
			scale_2 += weight_dist[i]
		else:
			scale_1 += weight_dist[i]
	if len(scale_2) == len(scale_1):
		print(scale_1 + '|' + scale_2)
	else:
		print('Impossible')
else:
	weight_dist = list(remain_weight)
	for i in range(len(weight_dist)):
		if len(scale_2) > len(scale_1):
			scale_1 += weight_dist[i]
		else:
			scale_2 += weight_dist[i]
	if len(scale_2) == len(scale_1):
		print(scale_1 + '|' + scale_2)
	else:
		print('Impossible')


s = input()
w = list(input())
n = len(s)
m = len(w)
if (n + m - 1) % 2:
	print('Impossible')
else:
	a = s.index('|')
	l = a
	r = n - l - 1
	if l == r:
		if m % 2:
			print('Impossible')
		else:
			while m > 0:
				if m % 2 == 0:
					s = s + w[-1]
					w.pop()
				else:
					s = w[-1] + s
					w.pop()
				m = m - 1
			print(s)
	else:
		while l < r and w != []:
			s = w[-1] + s
			w.pop()
			l = l + 1
		while r < l and w != []:
			s = s + w[-1]
			w.pop()
			r = r + 1
		if len(w) % 2:
			print('Impossible')
		else:
			m = len(w)
			while m > 0:
				if m % 2:
					s = s + w[-1]
					w.pop()
				else:
					s = w[-1] + s
					w.pop()
				m = m - 1
			a = s.index('|')
			if a == len(s) // 2 and (len(s) - 1) % 2 == 0:
				print(s)
			else:
				print('Impossible')


s = str(input())
left = True
f = True
l = ''
r = ''
news = str(input())
for d in s:
	if d != '|':
		if left is True:
			l += d
		else:
			r += d
	elif d == '|':
		left = False
D = abs(len(l) - len(r))
if D > len(news):
	print('Impossible')
	f = False
elif d != 0:
	if len(l) > len(r):
		r += ''.join(news[0:D])
		news = news[D:]
	elif len(r) > len(l):
		l += ''.join(news[0:D])
		news = news[D:]
	if len(news) % 2 == 0:
		r += ''.join(news[0:int(len(news) / 2)])
		l += ''.join(news[int(len(news) / 2):])
	elif len(news) % 2 == 1:
		print('Impossible')
		f = False
elif d == 0:
	if len(news) % 2 == 0:
		r += ''.join(news[0:int(len(news) / 2)])
		l += ''.join(news[int(len(news) / 2):])
	elif len(news) % 2 == 1:
		print('Impossible')
		f = False
if f:
	print(l + '|' + r)


(s, l) = (input().split('|'), input())
d = len(s[1]) - len(s[0])
if abs(d) > len(l) or (len(l) - abs(d)) % 2 == 1:
	print('Impossible')
else:
	p = (len(l) + d) // 2
	print(s[0], l[:p], '|', s[1], l[p:], sep='')


(l, r) = input().split('|')
w = input()
(l1, l2) = (len(l), len(r))
for i in w:
	if l1 > l2:
		r += i
		l2 += 1
	elif l2 > l1:
		l += i
		l1 += 1
	else:
		l += i
		l1 += 1
(l1, l2) = (len(l), len(r))
if l1 == l2:
	print(l + '|' + r)
else:
	print('Impossible')


s = list(input())
z = list(input())
x = list()
for i in range(len(s)):
	if s[i] == '|':
		inx = i
x = s[0:inx]
for i in range(inx + 1):
	del s[0]
for i in range(len(z)):
	if len(x) < len(s):
		x += z[i]
	else:
		s += z[i]
if len(x) != len(s):
	print('Impossible')
	exit()
for i in range(len(x)):
	print(x[i], end='')
print('|', end='')
for i in range(len(s)):
	print(s[i], end='')


n = input()
r = input()
l = n.split('|')
min_l = min(len(l[0]), len(l[1]))
max_l = max(len(l[0]), len(l[1]))
if len(l[0]) == len(l[1]) + len(r):
	print(n + r)
elif len(l[0]) + len(r) == len(l[1]):
	print(r + n)
elif min_l == max_l and len(r) % 2 == 2:
	d = len(r) // 2
	print(r[:d] + n + r[d:])
elif min_l + (max_l - min_l) == max_l and len(r) > max_l - min_l:
	if (len(r) - (max_l - min_l)) % 2 == 0:
		d = (len(r) - (max_l - min_l)) // 2
		if max_l == len(l[0]):
			print(r[:d] + l[0] + '|' + l[1] + r[d:])
		else:
			print(r[d:] + l[0] + '|' + l[1] + r[:d])
	else:
		print('Impossible')
else:
	print('Impossible')


(l, r) = input().split('|')
q = input()
for i in q:
	if len(l) > len(r):
		r += i
	elif len(l) < len(r):
		l += i
	else:
		l += i
if len(l) == len(r):
	print(l + '|' + r)
else:
	print('Impossible')


(s1, s2) = input().split('|')
s = input()
(l1, l2, n) = map(len, (s1, s2, s))
diff = abs(l1 - l2)
if n - abs(l1 - l2) >= 0 and (n - abs(l1 - l2)) % 2 == 0:
	d = (n - diff) // 2
	if l1 <= l2:
		print(s1 + s[:d] + s[d:d + diff] + '|' + s2 + s[d + diff:])
	else:
		print(s1 + s[:d] + '|' + s2 + s[d:d + diff] + s[d + diff:])
else:
	print('Impossible')


str1 = list(input())
str2 = list(input())
left = []
right = []
found_sperator = False
for i in str1:
	if i != '|' and (not found_sperator):
		left.append(i)
	elif i == '|':
		found_sperator = True
	else:
		right.append(i)
for i in str2:
	if len(left) < len(right):
		left.append(i)
	else:
		right.append(i)
if len(left) != len(right):
	print('Impossible')
else:
	print(*left, '|', *right, sep='')


s = input()
l = list(s.split('|'))
s1 = input()
m = len(l[0])
n = len(l[1])
b = len(s1)
t = 0
i = 0
if m != n:
	while b != 0:
		if m > n:
			n = n + 1
			l[1] = l[1] + s1[i]
			b = b - 1
		else:
			m = m + 1
			l[0] = l[0] + s1[i]
			b = b - 1
		i = i + 1
elif b % 2 == 0:
	while b != 0:
		if b % 2 != 0:
			l[0] = l[0] + s1[i]
			b = b - 1
		else:
			l[1] = l[1] + s1[i]
			b = b - 1
		i = i + 1
else:
	t = t + 1
w = ''
if m == n and t == 0:
	w = l[0] + '|' + l[1]
	print(w)
else:
	print('Impossible')


(a, b) = input().split('|')
w = a + input() + b
h = len(w) // 2
print('Impossible' if h < len(a) or h < len(b) or h + h != len(w) else w[:h] + '|' + w[h:])


(left, right) = input().split('|')
s = input()
total = len(left) + len(right) + len(s)
if total % 2 != 0 or len(left) > total // 2 or len(right) > total // 2:
	print('Impossible')
else:
	k = total // 2 - len(left)
	left = left + s[:k]
	right = right + s[k:]
	print(left, '|', right, sep='')


s = input().split('|')
c = input()
q = len(s[0]) + len(s[1]) + len(c)
if q % 2 != 0:
	print('Impossible')
elif len(s[0]) * 2 > q or len(s[1]) * 2 > q:
	print('Impossible')
else:
	print(s[0] + c[:q // 2 - len(s[0])], end='|')
	print(s[1] + c[q // 2 - len(s[0]):])


s = input().split('|')
s2 = input()
for i in s2:
	if len(s[0]) > len(s[1]):
		s[1] += i
	else:
		s[0] += i
if len(s[1]) != len(s[0]):
	print('Impossible')
else:
	print(s[0] + '|' + s[1])


(t, p) = (input(), input())
(k, n, m) = (t.find('|'), len(t) - 1, len(p))
s = n + m
i = s // 2 - k
if s & 1 or i < 0 or i > m:
	print('Impossible')
else:
	print(p[:i] + t + p[i:])


s = input()
add = input()
x = s.find('|')
ls = s[:x]
rs = s[x + 1:]
l = len(ls)
r = len(rs)
fl = 0
if l == r:
	if len(add) % 2 == 0:
		ls += add[:len(add) // 2]
		rs += add[len(add) // 2:]
		ans = ls + '|' + rs
	else:
		fl = 1
elif l < r:
	d = r - l
	if d == len(add):
		ls += add
		ans = ls + '|' + rs
	elif d < len(add):
		if (len(add) - d) % 2 != 0:
			fl = 1
		else:
			al = d + (len(add) - d) // 2
			ls += add[:al]
			rs += add[al:]
			ans = ls + '|' + rs
	elif d > len(add):
		fl = 1
elif r < l:
	d = l - r
	if d == len(add):
		rs += add
		ans = ls + '|' + rs
	elif d < len(add):
		if (len(add) - d) % 2 != 0:
			fl = 1
		else:
			al = d + (len(add) - d) // 2
			rs += add[:al]
			ls += add[al:]
			ans = ls + '|' + rs
	elif d > len(add):
		fl = 1
if fl == 1:
	print('Impossible')
else:
	print(ans)


scale = input()
rem = list(input())
ctr = scale.index('|')
if ctr == 0:
	left = []
	right = scale[ctr + 1:] if len(scale) > 1 else []
elif ctr == len(scale) - 1:
	right = []
	if ctr == 0:
		left = []
	else:
		left = scale[:ctr]
else:
	left = scale[:ctr]
	right = scale[ctr + 1:]
diff = len(left) - len(right)
if diff % 2 != len(rem) % 2:
	print('Impossible')
	exit()
else:
	try:
		if diff > 0:
			for _ in range(diff):
				right += rem.pop()
		elif diff < 0:
			for _ in range(-diff):
				left += rem.pop()
		while rem:
			left += rem.pop()
			right += rem.pop()
	except:
		print('Impossible')
		exit()
res = ''.join(left) + '|' + ''.join(right)
print(res)


import sys
s = input()
sx = input()
for i in range(len(s)):
	if s[i] == '|':
		p = i
first = s[0:p]
second = s[p + 1:]
for i in range(len(sx)):
	if len(first) < len(second):
		first += sx[i]
	else:
		second += sx[i]
if len(first) != len(second):
	print('Impossible')
else:
	print(first + '|' + second)


def checkScaleEquilibrium(leftScale, rightScale, unusedMasses):
	leftScaleQuantity = len(leftScale)
	rightScaleQuantity = len(rightScale)
	unusedMassesQuantity = len(unusedMasses)
	scalesDifferential = abs(leftScaleQuantity - rightScaleQuantity)
	if unusedMassesQuantity >= scalesDifferential:
		for mass in unusedMasses:
			if leftScaleQuantity > rightScaleQuantity:
				rightScale += mass
				rightScaleQuantity += 1
			else:
				leftScale += mass
				leftScaleQuantity += 1
		if len(leftScale) == len(rightScale):
			return leftScale + '|' + rightScale
		else:
			return 'Impossible'
	else:
		return 'Impossible'
twoScales = input().strip().split('|')
unusedMasses = input().strip()
leftScale = twoScales[0]
rightScale = twoScales[1]
res = checkScaleEquilibrium(leftScale, rightScale, unusedMasses)
print(res)


__copyright__ = ''
__author__ = 'Son-Huy TRAN'
__email__ = 'sonhuytran@gmail.com'
__doc__ = ''
__version__ = '1.0'

def main() -> int:
	scales = input().split('|')
	remaining = input()
	sum_length = len(scales[0]) + len(scales[1]) + len(remaining)
	if sum_length % 2 != 0:
		print('Impossible')
	else:
		temp = sum_length // 2
		if len(scales[0]) > temp or len(scales[1]) > temp:
			print('Impossible')
		else:
			for i in range(2):
				remainingi = temp - len(scales[i])
				scales[i] += remaining[:remainingi]
				remaining = remaining[remainingi:]
			print(scales[0], scales[1], sep='|')
	return 0
exit(main())


scales = input().strip().split('|')
left = input().strip()
s = [len(wts) for wts in scales]
if max(s) - min(s) > 0 and max(s) - min(s) <= len(left):
	if max(s) - min(s) < len(left):
		add = left[:max(s) - min(s)]
		left = left[max(s) - min(s):]
		if len(left) % 2 == 0:
			add1 = left[:len(left) // 2]
			add2 = left[len(left) // 2:]
			if s[0] > s[1]:
				print('{0}{1}|{2}{3}{4}'.format(scales[0], add1, add2, scales[1], add))
			else:
				print('{0}{1}{2}|{3}{4}'.format(scales[0], add1, add, add2, scales[1]))
		else:
			print('Impossible')
	else:
		add = left
		if s[0] > s[1]:
			print('{0}|{1}{2}'.format(scales[0], scales[1], add))
		else:
			print('{0}{1}|{2}'.format(scales[0], add, scales[1]))
elif s[0] == s[1] and len(left) % 2 == 0:
	add1 = left[:len(left) // 2]
	add2 = left[len(left) // 2:]
	print('{0}{1}|{2}{3}'.format(scales[0], add1, add2, scales[1]))
else:
	print('Impossible')


(x, y) = list(map(str, input().split('|')))
z = list(input())
a = len(x)
b = len(y)
c = len(z)
if a > b:
	if (c - (a - b)) % 2 == 1 or c - (a - b) < 0:
		print('Impossible')
	else:
		c = c - (a - b)
		f = a - b
		m = a - b + c // 2
		l = a - b + c
		print(x + ''.join(z[m:]) + '|' + y + ''.join(z[:f]) + ''.join(z[f:m]))
elif b > a:
	if (c - (b - a)) % 2 == 1 or c - (b - a) < 0:
		print('Impossible')
	else:
		c = c - (b - a)
		f = b - a
		m = b - a + c // 2
		l = b - a + c
		print(x + ''.join(z[:f]) + ''.join(z[f:m]) + '|' + y + ''.join(z[m:]))
elif c % 2 == 1:
	print('Impossible')
else:
	f = c // 2
	print(x + ''.join(z[f:]) + '|' + y + ''.join(z[:f]))


(s, sx) = (input(), input())
(s1, s2) = ('', '')
flag = False
for i in range(0, len(s)):
	if s[i] == '|':
		flag = True
		continue
	if flag:
		s2 += s[i]
	else:
		s1 += s[i]
for i in range(0, len(sx)):
	if len(s1) > len(s2):
		s2 += sx[i]
	elif len(s1) < len(s2):
		s1 += sx[i]
	else:
		s1 += sx[i]
if len(s1) == len(s2):
	print(s1 + '|' + s2)
else:
	print('Impossible')


def checkG(g):
	return g % 2 == 0
x = input()
g = input()
n = len(g)
l = x.find('|')
r = len(x) - x.find('|') - 1
if r == l:
	if checkG(n):
		print(x[:l] + g[:int(n / 2)] + '|' + x[l + 1:] + g[int(n / 2):])
	else:
		print('Impossible')
else:
	d = abs(r - l)
	if n < d:
		print('Impossible')
		exit()
	if checkG(n - abs(l - r)):
		if l < r:
			print(x[:l] + g[:d + int((n - d) / 2)] + '|' + x[l + 1:] + g[d + int((n - d) / 2):])
		else:
			print(x[:l] + g[:int((n - d) / 2)] + '|' + x[l + 1:] + g[int((n - d) / 2):])
	else:
		print('Impossible')


n = input().split('|')
b = input()
b = list(b)
a = len(n[0])
c = len(n[1])
d = abs(a - c)
f = len(b) - d
l = min(a, c)
j = 0
if l == a:
	j = 0
else:
	j = 1
if f % 2 != 0 and f > 0:
	print('Impossible')
elif f < 0:
	print('Impossible')
else:
	for i in range(d):
		n[j] = n[j] + b[-1]
		b.remove(b[-1])
	for i in range(len(b)):
		if i % 2 == 0:
			n[0] = n[0] + b[i]
		else:
			n[1] = n[1] + b[i]
	print(n[0] + '|' + n[1])


n = input()
i = n.find('|')
l = input()
s1 = n[:i]
s2 = n[i + 1:]
for j in range(len(l)):
	if len(s1) >= len(s2):
		s2 += l[j]
	else:
		s1 += l[j]
if len(s1) == len(s2):
	print(s1 + '|' + s2)
else:
	print('Impossible')


import sys
s = input()
s1 = input()
for i in range(len(s)):
	if s[i] == '|':
		break
a = s[:i]
b = s[i + 1:]
x = len(a)
y = len(b)
d = len(s1)
if (y + d - x) % 2 != 0:
	print('Impossible')
	sys.exit()
k = (y + d - x) // 2
if k < 0 or k > d:
	print('Impossible')
	sys.exit()
print(a + s1[:k], end='')
print('|', end='')
print(b + s1[k:])


(n, k) = map(str, input().split('|'))
l = input()
a = n + l + k
if (len(n) - len(k)) % 2 != len(l) % 2 or abs(len(n) - len(k)) > len(l):
	print('Impossible')
else:
	print(f'{a[:int(len(a) / 2)]}|{a[int(len(a) / 2):]}')


(a, b) = input().split('|')
z = a + input() + b
m = len(z) // 2
print([z[:m] + '|' + z[m:], 'Impossible'][max(map(len, [a, b, z[m:]])) > m])


__author__ = 'Adela'

def main():
	w = [k for k in input().split('|')]
	l = len(w[0])
	r = len(w[1])
	rem = input()
	total = l + r + len(rem)
	if total % 2 == 0:
		if l <= total / 2 and r <= total / 2:
			total = int(total / 2)
			print(w[0], rem[:total - l], '|', w[1], rem[total - l:], sep='')
			return
	print('Impossible')
main()


class CodeforcesTask382ASolution:

	def __init__(self):
		self.result = ''
		self.pans = []
		self.weights = ''

	def read_input(self):
		self.pans = input().split('|')
		self.weights = input()

	def process_task(self):
		if (sum([len(x) for x in self.pans]) + len(self.weights)) % 2:
			self.result = 'Impossible'
		else:
			r = (sum([len(x) for x in self.pans]) + len(self.weights)) // 2
			if max([len(x) for x in self.pans]) <= r:
				if r - len(self.pans[0]):
					self.pans[0] += self.weights[:r - len(self.pans[0])]
				if r - len(self.pans[1]):
					self.pans[1] += self.weights[-r + len(self.pans[1]):]
				self.result = '|'.join(self.pans)
			else:
				self.result = 'Impossible'

	def get_result(self):
		return self.result
Solution = CodeforcesTask382ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


from sys import stdin, stdout
INF = 100000000000.0

def get_int():
	return int(stdin.readline().strip())

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_string():
	return stdin.readline().strip()

def op(c):
	return stdout.write(c)
s = get_string()
s2 = get_string()
l = []
r = []
a = [c for c in s2]
f = 0
ans = ''
for i in s:
	if i == '|':
		f = 1
		continue
	if f == 0:
		l.append(i)
	if f == 1:
		r.append(i)
if len(l) < len(r):
	if len(a) < len(r) - len(l):
		print('Impossible')
	else:
		for i in range(len(r) - len(l)):
			l.append(a.pop(0))
if len(l) > len(r):
	if len(a) < len(l) - len(r):
		print('Impossible')
	else:
		for i in range(len(l) - len(r)):
			r.append(a.pop(0))
if len(l) == len(r):
	if len(a) % 2 != 0:
		print('Impossible')
	else:
		while len(a) > 0:
			l.append(a.pop(0))
			r.append(a.pop())
		for c in l:
			ans += c
		ans += '|'
		for c in r:
			ans += c
		print(ans)


(m, n) = input().split('|')
k = input()
for i in range(0, len(k)):
	if len(m) >= len(n):
		n += k[i]
	else:
		m += k[i]
if len(m) == len(n):
	print(m + '|' + n)
else:
	print('Impossible')


(l, r) = map(lambda s: s.strip(), input().split('|'))
o = input().strip()
(ll, lr, lo) = (len(l), len(r), len(o))
s = ll + lr + lo
if s % 2 == 0 and max(ll, lr) <= s // 2:
	o_l = s // 2 - ll
	print(f'{l + o[:o_l]}|{r + o[o_l:]}')
else:
	print('Impossible')


lt = list(input().split('|'))
s = input()
(l1, l2, k) = (len(lt[0]), len(lt[1]), len(s))
r = abs(l1 - l2)
if r == k:
	if l1 < l2:
		lt[0] += s
	else:
		lt[1] += s
	print(lt[0] + '|' + lt[1])
elif r > k:
	print('Impossible')
else:
	i = 0
	while len(s) != i:
		if l1 > l2:
			lt[1] += s[i]
			i += 1
			l2 += 1
		else:
			lt[0] += s[i]
			i += 1
			l1 += 1
	if len(lt[0]) == len(lt[1]):
		print(lt[0] + '|' + lt[1])
	else:
		print('Impossible')


s = input()
s1 = input()
l = s.split('|')
for i in range(len(s1)):
	if len(l[0]) > len(l[1]):
		l[1] += s1[i]
	else:
		l[0] += s1[i]
if len(l[0]) != len(l[1]):
	print('Impossible')
else:
	print(f'{l[0]}|{l[1]}')


s = input().split('|')
d = input()
for item in d:
	if len(s[0]) < len(s[1]):
		s[0] += item
	else:
		s[1] += item
if len(s[0]) == len(s[1]):
	print(s[0] + '|' + s[1])
else:
	print('Impossible')


x = input().split('|')
x[0] = list(x[0])
x[1] = list(x[1])
v = list(input())
if len(x[0]) > len(x[1]):
	z = len(x[0]) - len(x[1])
else:
	z = len(x[1]) - len(x[0])
if (len(v) - z) % 2 == 0 and len(v) - z >= 0:
	for c in range(len(v)):
		if len(x[0]) > len(x[1]):
			x[1].append(v[c])
		elif len(x[0]) < len(x[1]):
			x[0].append(v[c])
		elif c % 2 == 0:
			x[0].append(v[c])
		else:
			x[1].append(v[c])
	b = x[0] + x[1]
	b.insert(int(len(b) / 2), '|')
	b = ''.join(map(str, b))
	print(b)
else:
	print('Impossible')


def main():
	mode = 'filee'
	if mode == 'file':
		f = open('test.txt', 'r')
	get = lambda : [str(x) for x in (f.readline()[:-1] if mode == 'file' else input()).split('|')]
	scale = get()
	q = input()
	if abs(len(scale[0]) - len(scale[1])) % 2 != len(q) % 2 or abs(len(scale[0]) - len(scale[1])) > len(q):
		print('Impossible')
		return
	if len(scale[0]) < len(scale[1]):
		mid = len(scale[1]) - len(scale[0])
		scale[0] += q[:mid]
	else:
		mid = len(scale[0]) - len(scale[1])
		scale[1] += q[:mid]
	for z in range(mid, len(q), 2):
		scale[1] += q[z]
		scale[0] += q[z + 1]
	print('|'.join(scale))
	if mode == 'file':
		f.close()
main()


(l, r) = input().split('|')
s = input()
if len(l) == len(r):
	if len(s) & 1 == 0:
		f = 0
		for i in s:
			if not f:
				f = 1
				l += i
			else:
				f = 0
				r += i
		print(l + '|' + r)
	else:
		print('Impossible')
else:
	t = abs(len(l) - len(r))
	if t > len(s):
		print('Impossible')
	elif (len(s) - t) % 2 != 0:
		print('Impossible')
	else:
		if len(l) < len(r):
			i = 0
			while t:
				l += s[i]
				i += 1
				t -= 1
			f = 0
			for i in s[i:]:
				if not f:
					f = 1
					l += i
				else:
					f = 0
					r += i
		else:
			i = 0
			while t:
				r += s[i]
				i += 1
				t -= 1
			f = 0
			for i in s[i:]:
				if not f:
					f = 1
					l += i
				else:
					f = 0
					r += i
		print(l + '|' + r)


[left, right] = input().split('|')
weight = input().strip()
(l, r, w) = (len(left), len(right), len(weight))
d = abs(l - r)
if w < d or (w - d) % 2 == 1:
	print('Impossible')
else:
	if l < r:
		left = left + weight[:d]
	else:
		right = right + weight[:d]
	weight = weight[d:]
	d = len(weight)
	print(left + weight[:d // 2] + '|' + right + weight[d // 2:])


(left, right) = input().split('|')
weights = input()
r = 'Impossible'
if len(left) > len(right):
	q = len(left) - len(right)
	if q <= len(weights):
		right = right + weights[:q]
		weights = weights[q:]
elif len(right) > len(left):
	q = len(right) - len(left)
	if q <= len(weights):
		left = left + weights[:q]
		weights = weights[q:]
if len(left) == len(right):
	if len(weights) % 2 == 0:
		r = left + weights[:len(weights) // 2] + '|' + right + weights[len(weights) // 2:]
print(r)


def main():
	(l, r) = input().split('|')
	rest = input()
	ll = len(l)
	lr = len(r)
	lrest = len(rest)
	a = ll + lr + lrest
	if a & 1:
		print('Impossible')
	else:
		mid = a // 2
		if ll > mid or lr > mid:
			print('Impossible')
			return
		l = l + rest[:mid - ll]
		r = r + rest[mid - ll:]
		print(f'{l}|{r}')
main()


first = input()
second = input()
right = ''
left = ''
for (idx, letter) in enumerate(first):
	if letter == '|':
		right = first[idx + 1:]
		break
	else:
		left = left + letter
sizeSecond = len(second)
i = 0
while sizeSecond > 0:
	if len(left) > len(right):
		right = right + second[i]
		i += 1
		sizeSecond -= 1
	elif len(right) > len(left):
		left = left + second[i]
		i += 1
		sizeSecond -= 1
	else:
		if sizeSecond % 2 == 0:
			right = right + second[i]
			left = left + second[i + 1]
		i += 2
		sizeSecond -= 2
if sizeSecond == 0 and len(left) == len(right):
	print(left + '|' + right)
else:
	print('Impossible')


s = input()
g = input()
n = len(g)
i = 0
ans = n + len(s) - 1
while s[i] != '|':
	i += 1
j = len(s) - i - 1
if max(i, j) > min(i, j) + n or (i + j + n) % 2 != 0:
	print('Impossible')
else:
	print(s[:i] + g[:ans // 2 - i] + s[i:] + g[ans // 2 - i:])


(a, b) = map(str, input().split('|'))
c = input()
for i in c:
	if len(a) < len(b):
		a += i
	else:
		b += i
if len(a) == len(b):
	print('{0}|{1}'.format(a, b))
else:
	print('Impossible')


a = list(input().split('|'))
b = input()
for i in b:
	if len(a[0]) < len(a[1]):
		a[0] += i
	else:
		a[1] += i
if len(a[0]) == len(a[1]):
	print(a[0] + '|' + a[1])
else:
	print('Impossible')


(a, b) = input().split('|')
c = input()
i = 0
while len(c) > 0:
	if len(a) < len(b):
		a += c[0]
	else:
		b += c[0]
	c = c[1:]
if len(a) == len(b):
	print(a + '|' + b)
else:
	print('Impossible')


(a, b) = input().split('|')
s = input()
for c in s:
	if len(a) < len(b):
		a += c
	else:
		b += c
if len(a) == len(b):
	print(a + '|' + b)
else:
	print('Impossible')


s = [str(j) for j in input().split('|')]
t = str(input())
p = 0
while p < len(t):
	if len(s[0]) < len(s[1]):
		s[0] += t[p]
	elif len(s[0]) > len(s[1]):
		s[1] += t[p]
	elif p + 1 < len(t):
		s[0] += t[p]
		s[1] += t[p + 1]
		p += 1
	else:
		break
	p += 1
if p == len(t) and len(s[0]) == len(s[1]):
	print(s[0] + '|' + s[1])
else:
	print('Impossible')


def readdata():
	global vesy, ost
	vesy = input().strip()
	ost = input().strip()

def solve():
	left = len(vesy[:vesy.index('|')])
	right = len(vesy) - left - 1
	summ = len(ost) + left + right
	if len(ost) < abs(left - right) or summ % 2 == 1:
		print('Impossible')
	else:
		ans = vesy[:left] + ost[:summ // 2 - left] + '|' + vesy[left + 1:] + ost[summ // 2 - left:]
		print(ans)
readdata()
solve()


def inp():
	return map(str, input().split('|'))
(left, right) = inp()
(l, r) = (len(left), len(right))
(rem, sum) = (input(), l + r)
total = (sum + len(rem)) // 2
(s1, s2) = (left + rem[0:total - len(left)], right + rem[total - len(left):])
if len(s1) == len(s2):
	exit(print(s1 + '|' + s2))
print('Impossible')


sequence = str(input()).split('|')
w = str(input())
first = sequence[0]
second = sequence[1]
for i in w:
	if len(first) < len(second):
		first = first + i
	else:
		second = second + i
if len(first) == len(second):
	print('{}|{}'.format(first, second))
else:
	print('Impossible')


string1 = input()
string2 = input()
for i in range(len(string1)):
	if string1[i] == '|':
		break
n = len(string1)
if abs(len(string1) - 2 * i - 1) > len(string2) or (len(string2) - abs(len(string1) - 2 * i) + 1) % 2 == 1:
	print('Impossible')
	exit()
leftstring = ''
rightstring = '|'
if i > n - i - 1:
	leftstring = string1[:i]
	rightstring = string1[i:] + string2[:abs(len(string1) - 2 * i - 1)]
if n - i - 1 > i:
	leftstring = string1[:i] + string2[:abs(len(string1) - 2 * i - 1)]
	rightstring = string1[i:]
if i == n - i - 1:
	leftstring = string1[:i] + string2[:len(string2) // 2]
	rightstring = string1[i:] + string2[len(string2) // 2:]
elif len(string2) - abs(len(string1) - 2 * i - 1) > 0:
	rightstring = rightstring + string2[abs(len(string1) - 2 * i - 1):abs(len(string1) - 2 * i - 1) + (len(string2) - abs(len(string1) - 2 * i - 1)) // 2]
	leftstring = leftstring + string2[abs(len(string1) - 2 * i - 1) + (len(string2) - abs(len(string1) - 2 * i - 1)) // 2:]
print(leftstring + rightstring)


(l, r) = input().split('|')
x = input()
temp = len(l + x + r) / 2
if len(l + x + r) % 2 == 0:
	for i in x:
		if len(l) <= len(r):
			l += i
		else:
			r += i
	if len(l) == len(r):
		print(l + '|' + r)
	else:
		print('Impossible')
else:
	print('Impossible')


import heapq
a = input().strip().split('|')
w = input().strip()
if (len(a[0]) + len(a[1]) + len(w)) % 2 == 0:
	balance = int((len(a[0]) + len(a[1]) + len(w)) / 2)
	n = balance - len(a[0])
	a[0] = a[0] + w[:n]
	a[1] = a[1] + w[n:]
	if len(a[1]) == len(a[0]):
		print('|'.join(a), end='')
	else:
		print('Impossible', end='')
else:
	print('Impossible', end='')


a = input()
b = a[:a.find('|')]
c = a[a.find('|') + 1:]
d = input()
if (len(b) + len(c) + len(d)) % 2 == 0 and abs(len(b) - len(c)) <= len(d):
	if len(b) > len(c):
		e = len(b) - len(c)
		c += d[:e] + d[e:(len(d) - e) // 2 + e]
		b += d[(len(d) - e) // 2 + e:]
	else:
		e = len(c) - len(b)
		b += d[:e] + d[e:(len(d) - e) // 2 + e]
		c += d[(len(d) - e) // 2 + e:]
	print(b + '|' + c)
else:
	print('Impossible')


w = input()
o = input()
(left, right) = w.split('|')
minW = min(len(left), len(right))
maxW = max(len(left), len(right))
if (len(left) + len(right) + len(o)) % 2 != 0 or minW + len(o) < maxW:
	print('Impossible')
else:
	if (len(w) - 1 + len(o)) % 2 == 0:
		while o:
			if len(left) > len(right):
				right += o[0]
			else:
				left += o[0]
			o = o[1:]
	print(left + '|' + right)


from math import *
(str1, str2) = input().split('|')
dif = abs(len(str1) - len(str2))
str3 = input()
tot = len(str3) - dif
if tot < 0 or tot % 2 == 1:
	print('Impossible')
else:
	if len(str1) <= len(str2):
		for i in range(len(str3)):
			if i < tot // 2:
				str2 += str3[i]
			else:
				str1 += str3[i]
	else:
		for i in range(len(str3)):
			if i < tot // 2:
				str1 += str3[i]
			else:
				str2 += str3[i]
	print(str1 + '|' + str2)


s1 = input()
s2 = input()
i = 0
left = ''
right = ''
i = s1.find('|')
left = left + s1[0:i]
right = right + s1[i + 1:len(s1)]
dif = len(left) - len(right)
if len(s2) < abs(dif):
	print('Impossible')
else:
	if dif > 0:
		right = right + s2[0:abs(dif)]
	else:
		left = left + s2[0:abs(dif)]
	dif = abs(dif)
	if (len(s2) - dif) % 2:
		print('Impossible')
	else:
		index = int((len(s2) - dif) / 2)
		left = left + s2[dif:dif + index]
		right = right + s2[dif + index:len(s2)]
		result = ''
		slash = '|'
		result = left + slash + right
		print(result)


(left, right) = input().split('|')
weight = input()
left += weight

def test(left, right):
	for i in range(len(weight) + 1):
		if len(left[:len(left) - i]) == len(right + weight[::-1][:i]):
			print(left[:len(left) - i] + '|' + right + weight[::-1][:i])
			return
	print('Impossible')
test(left, right)


scale = input().split('|')
s = input()
for c in s:
	if len(scale[0]) < len(scale[1]):
		scale[0] += c
	elif len(scale[1]) < len(scale[0]):
		scale[1] += c
	else:
		scale[0] += c
if len(scale[0]) != len(scale[1]):
	print('Impossible')
else:
	print(scale[0] + '|' + scale[1])


s = input()
t = input()
(l, p) = s.split('|')
(dl, dp, dt) = (len(l), len(p), len(t))
x = abs(dl - dp)
if x > dt:
	print('Impossible')
else:
	y = dt - x
	if y % 2 == 1:
		print('Impossible')
	else:
		y //= 2
		xx = t[:x + y]
		yy = t[x + y:]
		if dl < dp:
			l = l + xx
			p = p + yy
		else:
			p = p + xx
			l = l + yy
		print(l, '|', p, sep='')


pan = input()
side = pan.split('|')
left = side[0]
right = side[1]
remain = input()
if (len(remain) + len(left) + len(right)) % 2 != 0:
	print('Impossible')
else:
	light = min(len(left), len(right))
	heavy = max(len(left), len(right))
	other = len(remain)
	dif = heavy - light
	if other - dif < 0 or (other - dif) % 2 != 0:
		print('Impossible')
	else:
		same = True
		if light == len(left):
			comp = left
			stro = right
		else:
			comp = right
			stro = left
			same = False
		comp += remain[:dif]
		remain = remain[dif:]
		semi = len(remain) // 2
		comp += remain[:semi]
		stro += remain[semi:]
		if same:
			print(comp, '|', stro, sep='')
		else:
			print(stro, '|', comp, sep='')


(s1, s2) = input().split('|')
s3 = input()
m1 = len(s1)
m2 = len(s2)
m3 = len(s3)
m4 = abs(m1 - m2)
if m3 - m4 >= 0 and (m4 - m3) % 2 == 0:
	index = (m4 + m3) // 2
	if m1 > m2:
		print(s1 + s3[index:] + '|' + s2 + s3[:index])
	else:
		print(s1 + s3[:index] + '|' + s2 + s3[index:])
else:
	print('Impossible')


from sys import stdin

def main():
	inp = stdin
	(IZQ, DER) = inp.readline().strip().split('|')
	new = inp.readline().strip()
	for i in new:
		if len(IZQ) < len(DER):
			IZQ += i
		else:
			DER += i
	if len(IZQ) == len(DER):
		print(IZQ + '|' + DER)
	else:
		print('Impossible')
main()


from sys import stdin, stdout

def solve(curr, free):
	wages = curr.split('|')
	left = len(wages[0])
	right = len(wages[1])
	result = None
	if (left + right + len(free)) % 2 == 0 and len(free) >= abs(left - right):
		while len(wages[0]) > len(wages[1]) and len(free) > 0:
			wages[1] += free[0]
			free = free[1:]
		while len(wages[1]) > len(wages[0]) and len(free) > 0:
			wages[0] += free[0]
			free = free[1:]
		if len(free) % 2 == 0:
			while len(free) > 1:
				wages[0] += free[0]
				wages[1] += free[1]
				free = free[2:]
			result = wages[0] + '|' + wages[1]
		else:
			result = 'Impossible'
	else:
		result = 'Impossible'
	return result
curr = stdin.readline()[:-1]
free = stdin.readline()[:-1]
result = solve(curr, free)
print(result)


a = list(input().split('|'))
s = list(input())
flag = False
if len(a[0]) > len(a[1]):
	(a[0], a[1]) = (a[1], a[0])
	flag = True
while len(a[0]) != len(a[1]) and len(s) != 0:
	a[0] += s[-1]
	s.pop()
if len(a[0]) != len(a[1]) or len(s) % 2 != 0:
	print('Impossible')
	exit()
for i in range(len(s)):
	if i % 2 == 0:
		a[0] += s[i]
	else:
		a[1] += s[i]
if flag:
	print(a[1] + '|' + a[0])
else:
	print(a[0] + '|' + a[1])


from sys import setrecursionlimit, exit, stdin
from math import ceil, floor, acos, pi
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from functools import reduce
import itertools
setrecursionlimit(10 ** 7)
RI = lambda x=' ': list(map(int, input().split(x)))
RS = lambda x=' ': input().rstrip().split(x)
dX = [-1, 1, 0, 0, -1, 1, -1, 1]
dY = [0, 0, -1, 1, 1, -1, -1, 1]
mod = int(1000000000.0 + 7)
eps = 1e-06
MAX = 1000
(A, B) = RS('|')
s = RS()[0]
d = len(A) - len(B)
if abs(d) % 2 != len(s) % 2 or abs(d) > len(s):
	print('Impossible')
else:
	if d < 0:
		d = -d
		i = d + (len(s) - d) // 2
		A = A + s[:i]
		B = B + s[i:]
	else:
		i = d + (len(s) - d) // 2
		B = B + s[:i]
		A = A + s[i:]
	print(A + '|' + B)


import sys
a = input().split('|')
b = input()
if len(a[0]) == len(a[1]):
	if len(b) % 2 == 1:
		print('Impossible')
		sys.exit(0)
	else:
		x = len(b) // 2
		print(a[0] + b[:x] + '|' + a[1] + b[x:])
		sys.exit(0)
n = abs(len(a[0]) - len(a[1])) - len(b)
if n > 0:
	print('Impossible')
	sys.exit(0)
elif n == 0:
	if len(a[0]) < len(a[1]):
		print(a[0] + b + '|' + a[1])
		sys.exit(0)
	else:
		print(a[0] + '|' + a[1] + b)
		sys.exit(0)
elif abs(n) % 2 == 1:
	print('Impossible')
	sys.exit(0)
else:
	i = 0
	while len(a[0]) < len(a[1]) and i < len(b):
		a[0] = a[0] + b[i]
		i += 1
	while len(a[1]) < len(a[0]) and i < len(b):
		a[1] = a[1] + b[i]
		i += 1
	temp = b[i:]
	print(a[0] + temp[:len(temp) // 2] + '|' + a[1] + temp[len(temp) // 2:])
	sys.exit(0)


(l, r) = input().split('|')
p = input()
ll = len(l)
lr = len(r)
lp = len(p)
mi = min(ll, lr)
ma = max(ll, lr)
if (ll + lr + lp) % 2 != 0 or mi + lp < ma or (mi == ma and lp % 2 > 0):
	print('Impossible')
elif mi + lp == ma:
	if mi == ll:
		print(l + p + '|' + r)
	else:
		print(l + '|' + r + p)
else:
	q = (ll + lr + lp) // 2
	print(l + p[:q - ll] + '|' + r + p[q - ll:])


(n, m) = input().split('|')
l = list(input())
for x in l:
	if len(n) < len(m):
		n += x
	else:
		m += x
if len(n) == len(m):
	print('|'.join([n, m]))
else:
	print('Impossible')


initial = input().split('|')
after = input()
diff = abs(len(initial[0]) - len(initial[1]))
ans = True
if len(after) < diff:
	print('Impossible')
	exit(0)
temp = len(after) - diff
alpha = temp // 2
if temp & 1:
	print('Impossible')
	exit(0)
if len(initial[0]) < len(initial[1]):
	initial[0] += after[:diff]
else:
	initial[1] += after[:diff]
if alpha:
	initial[0] += after[diff:alpha + diff]
	initial[1] += after[alpha + diff:]
print('|'.join(initial))


def main():
	(left, right) = input().split('|')
	remaining = input()
	left_length = len(left)
	right_length = len(right)
	rem_length = len(remaining)
	if left_length > right_length:
		max_length = left_length
		min_length = right_length
		max_word = left
		min_word = right
		flag = True
	else:
		max_length = right_length
		min_length = left_length
		max_word = right
		min_word = left
		flag = False
	diff_length = max_length - min_length
	if rem_length < diff_length:
		print('Impossible')
		return
	min_word += remaining[:diff_length]
	remaining = remaining[diff_length:]
	rem_length -= diff_length
	if rem_length % 2 == 1:
		print('Impossible')
		return
	if flag:
		print(max_word + remaining[:rem_length // 2] + '|' + min_word + remaining[rem_length // 2:])
	else:
		print(min_word + remaining[:rem_length // 2] + '|' + max_word + remaining[rem_length // 2:])
main()


a = list(map(str, input().split('|')))
b = input()
(l1, l2) = (len(a[0]), len(a[1]))
l = abs(l1 - l2)
if l == len(b):
	if l1 < l2:
		print(a[0] + b + '|' + a[1])
	else:
		print(a[0] + '|' + a[1] + b)
elif l < len(b):
	if l1 < l2:
		a[0] = a[0] + b[:l]
	else:
		a[1] = a[1] + b[:l]
	if (len(b) - l) % 2 == 0:
		l3 = len(b) - l
		a[0] = a[0] + b[l:l + l3 // 2]
		a[1] = a[1] + b[l + l3 // 2:]
		print(a[0] + '|' + a[1])
	else:
		print('Impossible')
else:
	print('Impossible')


weights = input().split('|')
newWeights = input()
while len(newWeights) > 1:
	if len(weights[0]) < len(weights[1]):
		weights[0] += newWeights[0]
		newWeights = newWeights[1:]
	else:
		weights[1] += newWeights[0]
		newWeights = newWeights[1:]
if len(weights[0]) < len(weights[1]):
	weights[0] += newWeights[0]
else:
	weights[1] += newWeights[0]
print('|'.join(weights) if len(weights[0]) == len(weights[1]) else 'Impossible')


from math import fabs
(ls, ly) = map(str, input().split('|'))
inp = input()
if len(inp) < fabs(len(ls) - len(ly)):
	print('Impossible')
elif (len(inp) - fabs(len(ls) - len(ly))) % 2 != 0:
	print('Impossible')
else:
	ls = list(ls)
	ly = list(ly)
	inp = list(inp)
	for i in inp:
		if len(ls) > len(ly):
			ly.append(i)
		else:
			ls.append(i)
	out = ls
	out.append('|')
	out += ly
	print(*out, sep='')


import sys
import math
import itertools
import functools
import collections
import operator

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
(l, r) = input().split('|')
s = input()
if (len(l) + len(r) + len(s)) % 2 == 1 or min(len(l), len(r)) + len(s) < max(len(r), len(l)):
	print('Impossible')
else:
	pos = (len(l) + len(r) + len(s)) // 2 - min(len(l), len(r))
	if len(l) < len(r):
		l += s[:pos]
		r += s[pos:]
	else:
		r += s[:pos]
		l += s[pos:]
	print(l + '|' + r)


(a, b) = input().split('|')
words = input()
for i in range(len(words)):
	if len(a) > len(b):
		b = b + words[i]
	else:
		a = a + words[i]
if len(a) == len(b):
	print(a + '|' + b)
else:
	print('Impossible')


from sys import stdin

def can_equilibrate(initial: str, remaining: str) -> None:
	if (len(initial) - 1 + len(remaining)) % 2 != 0:
		print('Impossible')
		return
	(left, right) = initial.split('|')
	(min_side, max_side) = (left, right) if len(left) < len(right) else (right, left)
	while len(min_side) < len(max_side):
		if not remaining:
			print('Impossible')
			return
		(remaining, c) = (remaining[:-1], remaining[-1])
		min_side += c
	(left, right) = (min_side, max_side) if len(left) < len(right) else (max_side, min_side)
	while remaining:
		(remaining, c) = (remaining[:-1], remaining[-1])
		left += c
		(remaining, c) = (remaining[:-1], remaining[-1])
		right += c
	print(left + '|' + right)
initial = stdin.readline().rstrip()
remaining = stdin.readline().rstrip()
can_equilibrate(initial, remaining)


l = [ele for ele in input().split('|')]
s = input()
for i in range(0, len(s)):
	(left, right) = (len(l[0]), len(l[1]))
	if left > right:
		l[1] += s[i]
	elif right > left:
		l[0] += s[i]
	else:
		l[0] += s[i]
if len(l[0]) != len(l[1]):
	print('Impossible')
else:
	opt = ''
	l.insert(1, '|')
	for e in l:
		opt += e
	print(opt)


from sys import stdin, stdout, exit
import math
from fractions import gcd

def sin():
	return stdin.readline().rstrip()

def listInput():
	return list(map(int, sin().split()))

def printBS(li):
	if not li:
		return
	for i in range(len(li) - 1):
		stdout.write('%d ' % li[i])
	stdout.write('%d\n' % li[-1])
(a, b) = sin().split('|')
c = sin()
k = int(abs(len(a) - len(b)))
if k > len(c):
	print('Impossible')
	exit(0)
n = len(a) + len(b) + len(c)
if n % 2 == 1:
	print('Impossible')
	exit(0)
k = n // 2 - len(a)
a = a + c[:k]
b = b + c[k:]
print(a + '|' + b)


(a, b) = input().split('|')
cnt = input()
for i in cnt:
	if len(a) < len(b):
		a += i
	else:
		b += i
if len(a) == len(b):
	print(a + '|' + b)
	exit()
print('Impossible')


(a, b) = input().split('|')
c = input()
sz1 = abs(len(a) - len(b))
sz2 = len(c)
if (sz2 - sz1) % 2 > 0 or sz2 < sz1:
	print('Impossible')
	exit()
while len(a) < len(b):
	a += c[0]
	c = c[1:]
while len(b) < len(a):
	b += c[0]
	c = c[1:]
print(a + c[::2] + '|' + b + c[1::2])


(a, b) = input().split('|')
c = input()
for x in range(len(c)):
	if len(a) > len(b):
		b += c[x]
	else:
		a += c[x]
if len(a) == len(b):
	print(a + '|' + b)
else:
	print('Impossible')


s1 = list(input())
s2 = list(input())
k1 = 0
k2 = 0
l1 = []
l2 = []
f = 0
for i in range(len(s1)):
	if s1[i] == '|':
		f = 1
	elif f == 0:
		k1 = k1 + 1
		l1.append(s1[i])
	elif f == 1:
		k2 = k2 + 1
		l2.append(s1[i])
k3 = len(s2)
r = abs(k2 - k1)
k3 = k3 - r
if k3 % 2 == 0 and k3 >= 0:
	c1 = 0
	c2 = 0
	if k1 >= k2 and r > 0:
		for i in range(r):
			l2.append(s2[i])
			c1 = c1 + 1
	else:
		for i in range(r):
			l1.append(s2[i])
			c2 = c2 + 1
	f = 0
	for j in range(max(c1, c2), len(s2)):
		if f == 0:
			l1.append(s2[j])
			f = 1
		else:
			l2.append(s2[j])
			f = 0
	m = [*l1, '|', *l2]
	print(''.join(m))
else:
	print('Impossible')


import math
s = input()
g = input()
(l, r, w) = (0, 0, len(g))
j = 0
while s[j] != '|':
	l += 1
	j += 1
k = j
j += 1
while j < len(s):
	r += 1
	j += 1
ls = s[:l]
rs = s[l + 1:]
for i in g:
	if l <= r:
		l += 1
		ls += i
	else:
		r += 1
		rs += i
if l == r:
	print(ls + '|' + rs)
else:
	print('Impossible')


s = input()
remain = input()
two = False
left = ''
right = ''
for x in s:
	if x == '|':
		two = True
		continue
	if two == False:
		left += x
	else:
		right += x
all_number = len(left) + len(right) + len(remain)
same_number = all_number // 2
if all_number % 2 == 0 and same_number >= len(left) and (len(left) + len(remain) >= same_number):
	for x in remain:
		if same_number > len(left):
			left += x
		else:
			right += x
	print(left + '|' + right)
else:
	print('Impossible')


(l, r) = input().split('|')
m = input()
ll = len(l)
lr = len(r)
imp = False
if ll > lr:
	if len(m) >= ll - lr:
		r += m[:ll - lr]
		m = m[ll - lr:]
	else:
		imp = True
elif len(m) >= lr - ll:
	l += m[:lr - ll]
	m = m[lr - ll:]
else:
	imp = True
if len(m):
	if len(m) & 1 == 0:
		while m:
			l += m[0]
			r += m[1]
			m = m[2:]
	else:
		imp = True
print('{}|{}'.format(l, r) if not imp else 'Impossible')


s = input()
i = s.index('|')
h = input()
left = i
right = len(s) - left
right -= 1
if abs(left - right) > len(h) or (len(h) - abs(left - right)) % 2 == 1:
	print('Impossible')
else:
	for i in range(len(h)):
		if left > right:
			s += h[i]
			right += 1
		else:
			s = h[i] + s
			left += 1
	print(s)


s = input()
s2 = input()
lc = 0
rc = 0
for i in range(len(s)):
	if s[i] == '|':
		lc = i
		break
rc = len(s) - lc - 1
n = len(s2) - abs(lc - rc)
flag = 0
if n % 2 != 0 or n < 0:
	print('Impossible')
else:
	s11 = s[:lc]
	s12 = s[lc:]
	if lc > rc:
		n1 = lc - rc
		s12 = s12 + s2[:n1]
		flag = 0
	else:
		n1 = rc - lc
		s11 = s11 + s2[:n1]
	while n1 < len(s2):
		if flag == 0:
			s11 = s11 + s2[n1]
			flag = 1
		else:
			s12 = s12 + s2[n1]
			flag = 0
		n1 += 1
	print(s11 + s12)


l = input('')
w = input('')
scales = l.split('|')
while len(w) > 0:
	if len(scales[0]) < len(scales[1]):
		scales[0] += w[0]
	else:
		scales[1] += w[0]
	w = w[1:len(w)]
if len(scales[0]) != len(scales[1]):
	print('Impossible')
else:
	print(scales[0] + '|' + scales[1])


scale = input()
mass = input()
n = abs(len(scale.split('|')[0]) - len(scale.split('|')[1]))
scale_1 = scale.split('|')[0]
scale_2 = scale.split('|')[1]
for i in range(len(mass)):
	if len(scale_1) > len(scale_2):
		scale_2 += mass[i]
	else:
		scale_1 += mass[i]
if len(scale_1) == len(scale_2):
	print(scale_1 + '|' + scale_2)
else:
	print('Impossible')


s = input()
seq = input()
(left, right) = s.split('|')
l1 = len(left)
l2 = len(right)
l = 0
if len(left) < len(right):
	while len(left) < len(right) and l < len(seq):
		left += seq[l]
		l += 1
	while l < len(seq):
		if l < len(seq):
			left += seq[l]
			l += 1
		if l < len(seq):
			right += seq[l]
			l += 1
	if len(left) == len(right):
		print(left + '|' + right)
	else:
		print('Impossible')
elif len(left) > len(right):
	while len(left) > len(right) and l < len(seq):
		right += seq[l]
		l += 1
	while l < len(seq):
		if l < len(seq):
			left += seq[l]
			l += 1
		if l < len(seq):
			right += seq[l]
			l += 1
	if len(left) == len(right):
		print(left + '|' + right)
	else:
		print('Impossible')
elif l1 == l2 and len(seq) % 2 != 0:
	print('Impossible')
else:
	while l < len(seq):
		if l < len(seq):
			left += seq[l]
			l += 1
		if l < len(seq):
			right += seq[l]
			l += 1
	if len(left) == len(right):
		print(left + '|' + right)
	else:
		print('Impossible')


x = input().split('|')
z = input()
for i in z:
	if len(x[0]) > len(x[1]):
		x[1] += i
	else:
		x[0] += i
if len(x[0]) == len(x[1]):
	print(x[0] + '|' + x[1])
else:
	print('Impossible')


(left, right) = input().split('|')
ext = input()
for i in ext:
	if len(left) > len(right):
		right += i
	else:
		left += i
if len(right) == len(left):
	print(left + '|' + right)
else:
	print('Impossible')


(x, y) = input().split('|')
extra = input()
l = len(x)
r = len(y)
e = len(extra)
if l > r:
	greater = x
	small = y
else:
	greater = y
	small = x
if len(greater) - len(small) <= e:
	bal = e - (len(greater) - len(small))
	if bal % 2 == 0:
		g = bal / 2
		s = len(greater) - len(small) + bal / 2
		g_str = greater + extra[:int(g)]
		s_str = small + extra[int(g):]
		if greater == x:
			print(g_str + '|' + s_str)
		else:
			print(s_str + '|' + g_str)
	else:
		print('Impossible')
else:
	print('Impossible')


s = input()
l = input()
s = s.split('|')
if len(s[0]) == len(s[1]) and len(l) % 2 == 1 or max(len(s[0]), len(s[1])) - min(len(s[0]), len(s[1])) > len(l) or (max(len(s[0]), len(s[1])) - min(len(s[0]), len(s[1])) < len(l) and (len(l) - max(len(s[0]), len(s[1])) - min(len(s[0]), len(s[1]))) % 2 == 1):
	print('Impossible')
elif len(s[0]) == len(s[1]) and len(l) % 2 == 0:
	s[0] = l[:len(l) // 2] + s[0]
	s[1] += l[len(l) // 2:]
	print(s[0] + '|' + s[1])
elif len(s[0]) < len(s[1]):
	if len(s[1]) - len(s[0]) != len(l):
		b = len(s[0])
		s[0] += l[:len(s[1]) - len(s[0])]
		l = l[len(s[1]) - b:]
	else:
		s[0] = l[:len(s[1]) - len(s[0])] + s[0]
		l = []
	if len(l) != 0:
		s[0] += l[:len(l) // 2]
		s[1] += l[len(l) // 2:]
	print(s[0] + '|' + s[1])
else:
	if len(s[0]) - len(s[1]) != len(l):
		b = len(s[1])
		s[1] += l[:len(s[0]) - len(s[1])]
		l = l[len(s[0]) - b:]
	else:
		s[1] = l[:len(s[0]) - len(s[1])] + s[1]
		l = []
	if len(l) != 0:
		s[1] += l[:len(l) // 2]
		s[0] += l[len(l) // 2:]
	print(s[0] + '|' + s[1])


x = input()
w = input()
r = l = 0
for i in range(len(x)):
	if x[i] == '|':
		l = x[0:i]
		r = x[i + 1:len(x)]
		break
total = len(l) + len(r) + len(w)
min = min(len(r), len(l))
max = max(len(r), len(l))
diff = max - min
ctr = 0
impossibleFlag = False
if total % 2 != 0 or max > min + len(w):
	impossibleFlag = True
if min == len(l):
	while diff > 0:
		if impossibleFlag == True:
			break
		l = l + w[diff - 1]
		diff -= 1
		ctr += 1
if min == len(r):
	while diff > 0:
		if impossibleFlag == True:
			break
		r = r + w[diff - 1]
		diff -= 1
		ctr += 1
for i in range(ctr, len(w), 2):
	if impossibleFlag == True:
		break
	l = l + w[ctr]
	r = r + w[ctr + 1]
	ctr += 2
if impossibleFlag == True:
	print('Impossible')
else:
	print(l + '|' + r)


string = input()
ras = input()
index = string.find('|')
ch1 = string[0:index]
ch2 = string[index + 1:len(string)]
delt = len(ch1) - len(ch2)
flag = 1
if delt < 0:
	flag = 0
	delt = -delt
chet = len(ras) - delt
if chet % 2 == 0 and chet >= 0:
	if flag:
		ch1 = ch1 + ras[0:int(chet / 2)]
		ch2 = ch2 + ras[int(chet / 2):len(ras)]
	else:
		ch2 = ch2 + ras[0:int(chet / 2)]
		ch1 = ch1 + ras[int(chet / 2):len(ras)]
	print(ch1 + '|' + ch2)
else:
	print('Impossible')


(x, y) = map(str, input().split('|'))
a = list(input())
for i in a:
	if len(x) > len(y):
		y += i
	else:
		x += i
if len(x) == len(y):
	print(x, end='|')
	print(y)
else:
	print('Impossible')


scales = input().split('|')
weights = list(input())
balance = len(scales[0]) - len(scales[1])
while weights:
	if len(scales[0]) < len(scales[1]):
		scales[0] += weights[0]
		weights.pop(0)
	else:
		scales[1] += weights[0]
		weights.pop(0)
	balance = len(scales[0]) - len(scales[1])
if balance == 0:
	print('|'.join(scales))
else:
	print('Impossible')


s = input().split('|')
x = input()
a = len(s[0])
b = len(s[1])
c = len(x)
f = True
if a < b:
	d = b - a
	if c >= d:
		s[0] += x[:d]
		c -= d
		x = x[d:]
if a > b:
	d = a - b
	if c >= d:
		s[1] += x[:d]
		c -= d
		x = x[d:]
s[0] += x[:c // 2]
s[1] += x[c // 2:]
if len(s[0]) == len(s[1]):
	print('|'.join(s))
else:
	print('Impossible')


myStr = input()
target = input()
(left, right) = (myStr[:myStr.index('|')], myStr[myStr.index('|') + 1:])
if len(left) == len(right):
	if len(target) % 2 != 0:
		print('Impossible')
	else:
		temp = True
		for i in target:
			if temp == True:
				left += i
				temp = False
			else:
				right += i
				temp = True
		left += '|'
		print(left + right)
else:
	for i in range(len(target)):
		if len(left) > len(right):
			right += target[i]
		else:
			left += target[i]
	if len(left) != len(right):
		print('Impossible')
	else:
		left += '|'
		print(left + right)


mezan = input()
ba2y = list(input())
leftl = ''
rightl = ''
left = True
x = len(mezan) - 1 + len(ba2y)
for i in range(len(mezan)):
	if mezan[i] == '|':
		left = False
		continue
	if left:
		leftl += mezan[i]
	else:
		rightl += mezan[i]
if x % 2 != 0 or len(leftl) > x / 2 or len(rightl) > x / 2:
	print('Impossible')
	quit()
while len(rightl) < x / 2:
	rightl += ba2y.pop()
while len(leftl) < x / 2:
	leftl += ba2y.pop()
print(leftl + '|' + rightl)


x = input()
y = input()
(left, right) = x.split('|')
for i in y:
	if len(left) < len(right):
		left += i
	else:
		right += i
if len(left) == len(right):
	print('{}|{}'.format(left, right))
else:
	print('Impossible')


(left, right) = [list(i) for i in input().split('|')]
for i in input():
	if len(left) > len(right):
		right.append(i)
	else:
		left.append(i)
if len(left) == len(right):
	print(''.join(left) + '|' + ''.join(right))
else:
	print('Impossible')


s = input()
w = input()
for i in range(len(s)):
	if s[i] == '|':
		t = i
		break
n = min(t, len(s) - 1 - t) + len(w) - max(t, len(s) - 1 - t)
if n % 2 == 0 and n >= 0:
	if n == 0:
		if t < len(s) - 1 - t:
			print(w + s[:])
		else:
			print(s[:] + w)
	elif t == len(s) - 1 - t:
		print(w[:n // 2] + s[:] + w[n // 2:])
	elif t > len(s) - 1 - t:
		sub = t - (len(s) - 1 - t)
		print(w[sub:sub + (len(w) - sub) // 2] + s[:] + w[:sub] + w[sub + (len(w) - sub) // 2:])
	else:
		sub = len(s) - 1 - t - t
		print(w[sub:sub + (len(w) - sub) // 2] + w[:sub] + s[:] + w[sub + (len(w) - sub) // 2:])
else:
	print('Impossible')


(a, b) = input().split('|')
new = input()
for char in new:
	if len(a) < len(b):
		a += char
	else:
		b += char
if len(a) == len(b):
	print(a + '|' + b)
else:
	print('Impossible')


s1 = input()
s2 = input()
l = s1[:s1.index('|')]
r = s1[s1.index('|'):]
r = r.replace('|', '')
if abs(len(r) - len(l)) > len(s2) or (len(l) + len(r) + len(s2)) % 2:
	print('Impossible')
else:
	for i in s2:
		if len(r) > len(l):
			l += i
		else:
			r += i
	print(l + '|' + r)


(h1, h2) = input('').split('|')
l = input('')
for i in range(len(l)):
	if abs(len(h2) - len(h1)) <= len(l):
		if len(h1) < len(h2):
			h1 += l[i]
		elif len(h1) > len(h2):
			h2 += l[i]
		else:
			h1 += l[i]
if len(h1) == len(h2):
	print(h1 + '|' + h2)
else:
	print('Impossible')


string = input().split('|')
s = [len(x) for x in string]
t = input()
if (s[0] + s[1] + len(t)) % 2:
	print('Impossible')
	exit()
mid = (s[0] + s[1] + len(t)) // 2
if not (s[0] <= mid and s[1] <= mid):
	print('Impossible')
	exit()
string[0] += t[:mid - s[0]]
string[1] += t[mid - s[0]:]
print(string[0] + '|' + string[1])


balance = input()
list1 = balance.split('|')
chars = input()
difference = abs(len(list1[0]) - len(list1[1]))
if difference > len(chars):
	print('Impossible')
elif (difference - len(chars)) % 2 != 0:
	print('Impossible')
else:
	if len(list1[0]) > len(list1[1]):
		side = 0
		other = 1
		new_balance = list1[0] + '|' + chars[:difference] + list1[1]
	else:
		side = 1
		other = 0
		new_balance = list1[0] + chars[:difference] + '|' + list1[1]
	remains = len(chars) - difference
	new_word = chars[difference:]
	if not remains == 0:
		pos = new_balance.index('|')
		final_balance = new_balance[:pos] + new_word[:int(remains // 2)] + '|' + new_balance[pos + 1:] + new_word[int(remains // 2):]
		print(final_balance)
	else:
		print(new_balance)


(l, r) = input().split('|')
ws = input()
i = 0
for w in ws:
	if len(l) < len(r):
		l += w
	else:
		r += w
if len(l) == len(r):
	print(f'{l}|{r}')
else:
	print('Impossible')


myStr = input()
enteredStr = input()
myStr = myStr.split('|')
left = myStr[0]
right = myStr[1]
for i in range(len(enteredStr)):
	if len(left) < len(right):
		left = left + enteredStr[i]
	else:
		right = right + enteredStr[i]
if len(left) != len(right):
	print('Impossible')
else:
	print(left + '|' + right)


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def main():
	a = input().split('|')
	b = input()
	remain = len(b)
	left = len(a[0])
	right = len(a[1])
	total = remain + left + right
	if total % 2 != 0:
		print('Impossible')
	else:
		target = total // 2
		lneed = target - left
		rneed = target - right
		if lneed < 0 or rneed < 0:
			print('Impossible')
		else:
			a[0] += b[:lneed]
			a[1] += b[lneed:]
			print(a[0] + '|' + a[1])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


import sys
import math
input = sys.stdin.readline
s = input().strip().split('|')
t = input().strip()
for i in range(0, len(t) + 1):
	if len(t[:i]) + len(s[0]) == len(t[i:]) + len(s[1]):
		print(t[:i] + s[0] + '|' + s[1] + t[i:])
		exit(0)
print('Impossible')


(before, after) = input().split('|')
remaining = input()
for each in remaining:
	if len(before) > len(after):
		after += each
	else:
		before += each
if len(before) == len(after):
	print(before + '|' + after)
else:
	print('Impossible')


def putWeight(string, weight):
	leftPlate = ''
	rightPlate = ''
	plate = 'L'
	for i in string:
		if str(i) == '|':
			plate = 'R'
			continue
		if plate == 'L':
			leftPlate += str(i)
			continue
		if plate == 'R':
			rightPlate += str(i)
			continue
	while len(weight) != 0:
		if len(leftPlate) > len(rightPlate):
			rightPlate += weight.pop(0)
			continue
		if len(rightPlate) > len(leftPlate):
			leftPlate += weight.pop(0)
			continue
		if len(rightPlate) == len(leftPlate):
			leftPlate += weight.pop(0)
			continue
	if len(leftPlate) == len(rightPlate):
		return str(leftPlate) + '|' + str(rightPlate)
	else:
		return 'Impossible'
string = str(input())
weight = list(input())
print(putWeight(str(string), list(weight)))


import math

def main():
	s = input()
	delimiter = s.index('|')
	left = s[0:delimiter]
	right = s[delimiter + 1:len(s)]
	task = input()
	for i in range(len(task)):
		if len(left) <= len(right):
			left += task[i]
		else:
			right += task[i]
	if len(left) == len(right):
		print(left + '|' + right)
	else:
		print('Impossible')
main()


a = input()
l = input()
s = ''
r = ''
p = 0
for i in range(len(a)):
	if a[i] == '|':
		p = 1
	elif p == 1:
		s = s + a[i]
	else:
		r = r + a[i]
b = len(s)
c = len(r)
d = len(l)
if abs(b - c) % 2 != d % 2:
	print('Impossible')
elif abs(b - c) > d:
	print('Impossible')
elif b > c:
	r = r + l[:b - c]
	w = (d - (b - c)) // 2
	s = s + l[b - c:b - c + w]
	r = r + l[b - c + w:]
	print(r + '|' + s)
elif c > b:
	s = s + l[:c - b]
	w = (d - (c - b)) // 2
	s = s + l[c - b:c - b + w]
	r = r + l[c - b + w:]
	print(r + '|' + s)
else:
	w = d // 2
	s = s + l[:w]
	r = r + l[w:]
	print(r + '|' + s)


(a, b) = input().split('|')
c = input()
maxx = max(len(a), len(b))
minn = min(len(a), len(b))
s = int(maxx - minn)
if len(c) < s:
	print('Impossible')
elif (len(c) - s) % 2 != 0:
	print('Impossible')
else:
	i = 0
	if len(a) == len(b):
		while i != len(c):
			a += c[i]
			i += 1
			b += c[i]
			i += 1
	if len(a) > len(b):
		while len(a) != len(b):
			b += c[i]
			i += 1
		while i != len(c):
			a += c[i]
			i += 1
			b += c[i]
			i += 1
	if len(a) < len(b):
		while len(a) != len(b):
			a += c[i]
			i += 1
		while i != len(c):
			a += c[i]
			i += 1
			b += c[i]
			i += 1
	print(a + '|' + b)


def solve():
	(left, right) = input().split('|')
	b = input()
	diff = abs(len(left) - len(right))
	if not (len(b) >= diff and (len(b) - diff) % 2 == 0):
		return 'Impossible'
	each_len = (len(left) + len(right) + len(b)) // 2
	missing = abs(len(left) - each_len)
	return f"{''.join(left + b[:missing])}|{''.join(right + b[missing:])}"
print(solve())


pan = input().split('|')
free = input()
left = pan[0]
right = pan[1]
possible = False
if len(left) == len(right):
	if len(free) % 2 == 0:
		possible = True
else:
	diff = max(len(left) - len(right), len(right) - len(left))
	if len(free) >= diff and (len(free) - diff) % 2 == 0:
		possible = True
if possible:
	total = len(left) + len(right) + len(free)
	i = 0
	while len(left) < total / 2:
		left += free[i]
		i += 1
	for j in range(i, len(free)):
		right += free[j]
	print(left + '|' + right)
else:
	print('Impossible')


import sys

def find(x, y):
	for i in range(len(x)):
		if x[i] == y[0]:
			return i

def substr(x, y, z):
	a = ''
	for i in range(y, z):
		a += x[i]
	return a

def erase(x):
	a = ''
	for i in range(1, len(x)):
		a += x[i]
	return a
s = str(input())
t = str(input())
line = find(s, '|')
sa = substr(s, 0, line)
sb = substr(s, line + 1, len(s))
flag = False
if len(sa) < len(sb):
	(sa, sb) = (sb, sa)
	flag = True
if len(sb) + len(t) < len(sa):
	print('Impossible')
	sys.exit()
while len(t) > 0 and len(sa) != len(sb):
	sb += t[0]
	t = erase(t)
if len(t) & 1:
	print('Impossible')
	sys.exit()
for i in range(len(t)):
	if i & 1:
		sa += t[i]
	else:
		sb += t[i]
if flag:
	(sa, sb) = (sb, sa)
print(sa, end='|')
print(sb)


(a, b) = input().split('|')
u = input()
x = len(u)
A = len(a)
B = len(b)
t = A + B + x
if abs(B - A) <= x and t % 2 == 0:
	if t % 2 == 0:
		t = t / 2
		A = int(abs(t - A))
		a += u[0:A]
		b += u[A:]
	else:
		t = t // 2
		A = int(abs(t - A))
		a += u[0:A]
		b += u[A:x - 1]
	print(a, end='')
	print('|', end='')
	print(b)
else:
	print('Impossible')


S = input().strip()
Index = S.find('|')
(L, R) = (Index, len(S) - Index - 1)
Other = input().strip()
if (L + R + len(Other)) % 2 == 0 and max(L, R) <= min(L, R) + len(Other):
	Amount = (L + R + len(Other)) // 2
	print(S[:Index] + Other[:Amount - L] + '|' + S[Index + 1:] + Other[Amount - L:])
else:
	print('Impossible')


(l, r) = input().split('|')
to_add = input()
for c in to_add:
	if len(l) < len(r):
		l += c
	else:
		r += c
if len(l) == len(r):
	print(l + '|' + r)
else:
	print('Impossible')


s = input().split('|')
l = list(input())
for i in l:
	if len(s[0]) > len(s[1]):
		s[1] += i
	elif len(s[0]) < len(s[1]):
		s[0] += i
	else:
		s[0] += i
if len(s[0]) == len(s[1]):
	print(s[0] + '|' + s[1])
else:
	print('Impossible')


s = input()
x = list(input())
(l, r) = (0, 0)
(s1, x1) = (len(s), len(x))
k = 1
(l1, r1) = ([], [])
for i in range(s1):
	if k == 0:
		r += 1
		r1.append(s[i])
		if s[i] == '|':
			r1.remove('|')
			k = 1
			r -= 1
	else:
		l += 1
		l1.append(s[i])
		if s[i] == '|':
			l1.remove('|')
			k = 0
			l -= 1
m = l + r + x1
if l - r > 0:
	m1 = l - r
else:
	m1 = r - l
if m1 > x1 or m % 2 != 0:
	print('Impossible')
else:
	m = m // 2
	(i, j) = (0, 0)
	while j < m - l:
		if x[i] != '0':
			l1.append(x[i])
			x[i] = '0'
			j += 1
		i += 1
	(i, j) = (0, 0)
	while j < m - r:
		if x[i] != '0':
			r1.append(x[i])
			x[i] = '0'
			j += 1
		i += 1
	l = len(l1)
	r = len(r1)
	for i in range(l):
		print(l1[i], end='')
	print('|', end='')
	for i in range(r):
		print(r1[i], end='')


import sys
import math
arr = sys.stdin.readline().split('|')
st = sys.stdin.readline()
la = len(arr[0])
ra = len(arr[1]) - 1
ls = len(st) - 1
t = int(ls - math.fabs(la - ra))
if t % 2 == 0 and t >= 0:
	ss1 = []
	ss2 = []
	ss1.extend(arr[0])
	ss2.extend(arr[1][:ra])
	ss1.extend(st[:int(t / 2)])
	ss2.extend(st[int(t / 2):t])
	if la < ra:
		ss1.extend(st[t:ls])
	if ra < la:
		ss2.extend(st[t:ls])
	print(''.join(ss1) + '|' + ''.join(ss2))
else:
	print('Impossible')


s = input().split('|')
l = list(s[0])
r = list(s[1])
w = list(input())
while len(w) != 0:
	if len(l) > len(r):
		r.append(w.pop())
	else:
		l.append(w.pop())
if len(l) != len(r) or len(w) != 0:
	print('Impossible')
else:
	print(''.join(l) + '|' + ''.join(r))


(a, b) = input().split('|')
A = len(a)
B = len(b)
i = input()
c = len(i)
if A > B:
	x = c - (A - B)
	if x % 2 == 0 and x >= 0:
		if x == 0:
			b += i
		else:
			b += i[:x // 2 + A - B]
			a += i[x // 2 + A - B:]
		print(a + '|' + b)
	else:
		print('Impossible')
elif A < B:
	x = c - (B - A)
	if x % 2 == 0 and x >= 0:
		if x == 0:
			a += i
		else:
			a += i[:x // 2 + B - A]
			b += i[x // 2 + B - A:]
		print(a + '|' + b)
	else:
		print('Impossible')
elif c % 2 == 0:
	a += i[:c // 2 + A - B]
	b += i[c // 2 + A - B:]
	print(a + '|' + b)
else:
	print('Impossible')


s1 = input()
s2 = input()
d = s1.find('|')
l = s1[:d]
r = s1[d + 1:]
t = len(l) + len(r) + len(s2)
if t % 2 == 0:
	left = int(0.5 * t - len(l))
	right = int(0.5 * t - len(r))
	if left == 0:
		sr = r + s2
		sl = l
	elif right == 0:
		sl = l + s2
		sr = r
	elif (left != 0) & (right != 0):
		sl = l + s2[:left]
		sr = r + s2[left:]
	if len(sl) == len(sr):
		print(sl + '|' + sr)
	else:
		print('Impossible')
else:
	print('Impossible')


(s1, s2) = map(str, input().split('|'))
(len1, len2) = (len(s1), len(s2))
s3 = str(input())
cnt = len(s3)
cnt -= abs(len1 - len2)
if cnt < 0:
	print('Impossible')
elif cnt & 1:
	print('Impossible')
else:
	swap = False
	if len1 > len2:
		(s1, s2) = (s2, s1)
		swap = True
	w = 0
	for ch in s3:
		if len(s1) < len(s2):
			s1 += ch
		else:
			s2 += ch
	ans = s1 + '|' + s2 if swap == False else s2 + '|' + s1
	print(ans)


s = input()
left = s.index('|')
right = len(s[s.index('|') + 1:])
add = input()
left_s = s[:s.index('|')]
right_s = s[s.index('|') + 1:]
for el in add:
	if len(left_s) <= len(right_s):
		left_s += el
	else:
		right_s += el
if len(left_s) != len(right_s):
	print('Impossible')
else:
	print(f'{left_s}|{right_s}')


(L, R) = input().split('|')
l = len(L)
r = len(R)
A = input()
a = len(A)
if min(l, r) + a < max(l, r) or (l + r + a) % 2 == 1:
	print('Impossible')
else:
	for s in A:
		if len(L) <= len(R):
			L += s
		else:
			R += s
	print(L + '|' + R)


a = input()
b = input()
l = ''
r = ''
status = True
for c in a:
	if c == '|':
		status = False
		continue
	if status:
		l += c
	else:
		r += c
total = len(l) + len(r) + len(b)
if total % 2 == 0:
	i = 0
	while len(l) < total // 2 and i < len(b):
		l += b[i]
		i += 1
	while len(r) < total // 2 and i < len(b):
		r += b[i]
		i += 1
	if len(l) == len(r):
		print(l + '|' + r)
	else:
		print('Impossible')
else:
	print('Impossible')


x = list(input())
z = input()
if len(x) == 1:
	z = list(z)
	if len(z) % 2 != 0:
		print('Impossible')
		exit()
	else:
		z[int(len(z) / 2) - 1] += '|'
		h = 0
		while h < len(z):
			print(z[h], end='')
			h += 1
		exit()
h = x.index('|')
min1 = min(h, len(x) - (h + 1))
max1 = max(h, len(x) - (h + 1))
f = len(x) - 1 + len(z)
if f % 2 != 0 or min1 + len(z) < max1:
	print('Impossible')
	exit()
else:
	if f / 2 > max1:
		if max1 == len(x) - (h + 1):
			x[-1] += z[0:int(f / 2 - max1)]
		else:
			x[h - 1] += z[0:int(f / 2 - max1)]
	N = f / 2 - max1
	if min1 == h:
		if h == 0:
			x[min1] = z[int(N):] + '|'
		else:
			x[min1 - 1] += z[int(N):]
	else:
		x[-1] += z[int(N):]
	z = 0
while z < len(x):
	print(x[z], end='')
	z += 1


inp = input()
out = ''
extra = input()
s = inp.split('|')
n = len(extra)
left = len(s[0])
right = len(s[1])
if left == right and n % 2 == 1:
	print('Impossible')
elif abs(left - right) > n:
	print('Impossible')
else:
	diff = abs(left - right)
	if (n - diff) % 2 == 1:
		print('Impossible')
	else:
		if left > right:
			s[1] += extra[:diff]
		else:
			s[0] += extra[:diff]
		for i in range(diff, n):
			if i % 2 == 1:
				s[1] += extra[i]
			else:
				s[0] += extra[i]
		print('|'.join(s))


(left, right) = input().split('|')
rem = input()
for ch in rem:
	if len(left) > len(right):
		right += ch
	else:
		left += ch
if len(left) == len(right):
	print(left + '|' + right)
else:
	print('Impossible')


s = input().split('|')
ch = input()
chl = len(ch)
lr = len(s[0])
ll = len(s[1])
if (chl + lr + ll) % 2 == 0:
	i = 0
	while (lr != (chl + lr + ll) // 2 or ll != (chl + lr + ll) // 2) and i < chl:
		if lr <= ll:
			s[0] += ch[i]
			lr += 1
		else:
			s[1] += ch[i]
			ll += 1
		i += 1
	if lr == ll:
		print(s[0] + '|' + s[1])
	else:
		print('Impossible')
else:
	print('Impossible')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict
from math import ceil, floor, sqrt, log2, gcd, pi
from heapq import heappush, heappop
from fractions import Fraction
from bisect import bisect_left, bisect
import sys
abc = 'abcdefghijklmnopqrstuvwxyz'
ABC = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
(l, r) = input().split('|')
s = input()
ll = len(l)
lr = len(r)
ls = len(s)
tot = ll + lr + ls
if (ll + lr + ls) % 2 == 1:
	print('Impossible')
elif ll > tot // 2 or lr > tot // 2:
	print('Impossible')
else:
	s = s[::-1]
	s = list(s)
	r = list(r)
	l = list(l)
	while s:
		if lr < ll:
			lr += 1
			r.append(s.pop())
		else:
			ll += 1
			l.append(s.pop())
	print(''.join(l) + '|' + ''.join(r))


scales = input()
weights = input()
x = scales.find('|')
length = len(scales)
dif = x - (length - (x + 1))
if dif == 0:
	ans = 'Impossible'
elif len(weights) >= abs(dif) and (len(weights) - abs(dif)) % 2 == 0:
	if dif > 0:
		scales += weights[0:dif]
		ans = scales
	elif dif < 0:
		scales = scales[0:x] + weights[0:abs(dif)] + scales[x:]
		ans = scales
else:
	ans = 'Impossible'
weights = weights[abs(dif):]
if len(weights) % 2 != 0:
	weights = ''
while len(weights) >= 2:
	x = scales.find('|')
	scales += weights[0]
	scales = scales[0:x] + weights[1] + scales[x:]
	weights = weights[2:]
	ans = scales
print(ans)


b = input().split('|')
w = input()
(x, y, z) = map(len, b + [w])
s = sum([x, y, z])
h = s // 2
if s % 2 != 0 or x > h or y > h:
	print('Impossible')
else:
	b[0] += w[:h - x]
	b[1] += w[h - x:]
	print('|'.join(b))


def main():
	(a, b) = input().split('|')
	c = input()
	(la, lb, lc) = map(len, (a, b, c))
	(labc, flag) = divmod(la + lb + lc, 2)
	if not flag:
		(da, db) = (labc - la, labc - lb)
		if da > -1 < db:
			print(''.join((a, c[:da], '|', b, c[da:])))
			return
	print('Impossible')
main()


(realx, realy) = input().split('|')
add = input()
x = len(realx)
y = len(realy)
t = len(add)
sum = x + y + t
if sum // 2 - sum / 2 == 0:
	p = sum // 2
	tx = p - x
	ty = p - y
	if tx + x == ty + y and tx >= 0 and (ty >= 0):
		if tx > 0:
			realx += add[:tx]
		if ty > 0:
			realy += add[tx:]
		print(realx + '|' + realy)
	else:
		print('Impossible')
else:
	print('Impossible')


string = input()
(a, b) = string.split('|')
(p, q) = (len(a), len(b))
s = input()
n = len(s) - abs(p - q)
if n % 2 == 0 and n >= 0:
	n //= 2
	if p > q:
		a += s[:n]
		b += s[n:]
	else:
		a += s[n:]
		b += s[:n]
	print('%s|%s' % (a, b))
else:
	print('Impossible')


(l, r) = input().split('|')
c = input()
d = abs(len(r) - len(l))
if len(l) >= len(r):
	small = 0
elif len(l) < len(r):
	small = 1
if d <= len(c):
	x = len(c) - d
	if x % 2 == 0:
		for i in range(d):
			if small == 0:
				r += c[-1]
				c = c[:-1]
			elif small == 1:
				l += c[-1]
				c = c[:-1]
		for i in range(x):
			if i % 2 == 0:
				l += c[i]
			else:
				r += c[i]
		print(l + '|' + r)
	else:
		print('Impossible')
else:
	print('Impossible')


(L, R) = list(map(list, input().split('|')))
remaining_weight = list(input())
deficit = abs(len(L) - len(R))
d = len(remaining_weight) - deficit
if d < 0 or d % 2:
	print('Impossible')
else:
	if len(L) < len(R):
		for i in range(deficit):
			L.append(remaining_weight.pop())
	elif len(R) < len(L):
		for i in range(deficit):
			R.append(remaining_weight.pop())
	flag = True
	for weight in remaining_weight:
		if flag:
			L.append(weight)
		else:
			R.append(weight)
		flag = not flag
	print(''.join(L) + '|' + ''.join(R))


lst = input()
lst1 = lst.split('|')
st = input()
diff = abs(len(lst1[0]) - len(lst1[1]))
res = ''
if len(st) - diff < 0:
	print('Impossible')
elif (len(st) - diff) % 2 == 0:
	val = (len(st) - diff) // 2
	if len(lst1[0]) < len(lst1[1]):
		res = st[:diff] + st[diff:val + diff] + lst + st[val + diff:]
	else:
		res = st[:val] + lst + st[val:diff + val] + st[diff + val:diff + val + val]
	print(res)
else:
	print('Impossible')


from sys import stdin
s = stdin.readline().rstrip()
n = len(s)
t = stdin.readline().rstrip()
c = 0
for i in range(n):
	if s[i] == '|':
		break
	c += 1
b = c
a = n - c - 1
tot = b + a + len(t)
if tot % 2 != 0:
	print('Impossible')
elif b > tot // 2 or a > tot // 2:
	print('Impossible')
else:
	ans = ''
	for i in range(b):
		ans += s[i]
	f = tot // 2 - b
	for i in range(f):
		ans += t[i]
	ans += '|'
	for i in range(n - a, n):
		ans += s[i]
	for i in range(f, len(t)):
		ans += t[i]
	print(ans)


list1 = input()
w = list(input())
k = list1.index('|')
left = list1[0:k]
right = list1[k:]
left1 = len(left)
right1 = len(right) - 1
while left1 < right1 and w:
	list1 = w[0] + list1
	w.remove(w[0])
	left1 += 1
while right1 < left1 and w:
	list1 += w[0]
	w.remove(w[0])
	right1 += 1
if len(w) & 1:
	print('Impossible')
elif w == [] and right1 != left1:
	print('Impossible')
else:
	while w != []:
		list1 = w[0] + list1
		w.remove(w[0])
		list1 += w[0]
		w.remove(w[0])
	print(list1)


scales = input()
left = scales.find('|')
right = len(scales) - (left + 1)
rest = input()
if (len(rest) + left + right) % 2:
	print('Impossible')
else:
	half = (len(rest) + left + right) // 2
	if left > half or right > half:
		print('Impossible')
	else:
		h1 = half - left
		s1 = scales[:left] + rest[:h1]
		s2 = scales[left + 1:] + rest[h1:]
		print(s1 + '|' + s2)


string1 = input()
y = string1.find('|')
string = [string1[:y], string1[y + 1:]]
extra = input()
first = len(string[0])
last = len(string[1])
if first == last:
	if len(extra) % 2 == 0:
		for i in range(len(extra)):
			if i % 2 == 0:
				string[0] += extra[i]
			else:
				string[1] += extra[i]
		string.insert(1, '|')
		print(''.join(string))
	else:
		print('Impossible')
elif len(extra) < abs(first - last):
	print('Impossible')
elif len(extra) == abs(first - last):
	if first > last:
		for i in extra:
			string[1] += i
	else:
		for i in extra:
			string[0] += i
	string.insert(1, '|')
	print(''.join(string))
elif len(extra) > abs(first - last):
	if (len(extra) - abs(first - last)) % 2 == 0:
		temp = list(extra)
		if first > last:
			for i in range(abs(first - last)):
				x = temp.pop(0)
				string[1] += x
			for i in range(0, len(temp)):
				if i % 2 == 0:
					string[0] += temp[i]
				else:
					string[1] += temp[i]
			string.insert(1, '|')
			print(''.join(string))
		else:
			for i in range(abs(first - last)):
				x = temp.pop(0)
				string[0] += x
			for i in range(0, len(temp)):
				if i % 2 == 0:
					string[0] += temp[i]
				else:
					string[1] += temp[i]
			string.insert(1, '|')
			print(''.join(string))
	else:
		print('Impossible')


(l, r) = input().split('|')
f = input()
if abs(len(l) - len(r)) > len(f):
	print('Impossible')
	exit()
for i in range(len(f)):
	if len(r) > len(l):
		l = l + f[i]
	elif len(r) < len(l):
		r = r + f[i]
	elif (len(f) - i) % 2 == 1:
		print('Impossible')
		exit()
	else:
		l = l + f[i]
print(l + '|' + r)


s = list(input().split('|'))
p = input()
ln1 = len(s[0])
ln2 = len(s[1])
ln3 = len(p)
if ln1 == ln2:
	if ln3 % 2 == 0:
		print(s[0], end='')
		for i in range(int(ln3 / 2)):
			print(p[i], end='')
		print('|', end='')
		print(s[1], end='')
		for i in range(int(ln3 / 2), ln3):
			print(p[i], end='')
	else:
		print('Impossible')
elif ln1 > ln2:
	if ln1 - ln2 > ln3 or (ln3 - (ln1 - ln2)) % 2 != 0:
		print('Impossible')
	else:
		start = ln1 - ln2
		for i in range(start):
			s[1] += p[i]
		if ln3 - start > 0:
			print(s[0], end='')
			holy = (ln3 - start) // 2
			for i in range(start, start + holy):
				print(p[i], end='')
			print('|', end='')
			print(s[1], end='')
			for i in range(start + holy, ln3):
				print(p[i], end='')
		else:
			print(s[0], end='')
			print('|', end='')
			print(s[1])
elif ln2 - ln1 > ln3 or (ln3 - (ln2 - ln1)) % 2 != 0:
	print('Impossible')
else:
	start = ln2 - ln1
	for i in range(start):
		s[0] += p[i]
	if ln3 - start > 0:
		print(s[0], end='')
		holy = (ln3 - start) // 2
		for i in range(start, start + holy):
			print(p[i], end='')
		print('|', end='')
		print(s[1], end='')
		for i in range(start + holy, ln3):
			print(p[i], end='')
	else:
		print(s[0], end='')
		print('|', end='')
		print(s[1])


s1 = input().split('|')
s2 = input()
while s2:
	k = s2[0]
	s2 = s2[1:]
	if len(s1[0]) > len(s1[1]):
		s1[1] += k
	else:
		s1[0] += k
if len(s1[0]) == len(s1[1]):
	print(s1[0] + '|' + s1[1])
else:
	print('Impossible')


(a, b) = input().split('|')
c = input()
for i in range(len(c)):
	if len(a) <= len(b):
		a += c[i]
	elif len(a) > len(b):
		b += c[i]
if len(a) == len(b):
	print(a + '|' + b)
else:
	print('Impossible')


def main():
	string = str(input())
	extra = str(input())
	first = ''
	second = ''
	flag = True
	for i in range(len(string)):
		if string[i] != '|':
			if flag:
				first += string[i]
			else:
				second += string[i]
		else:
			flag = False
	for i in range(len(extra)):
		if len(first) < len(second):
			first += extra[i]
		else:
			second += extra[i]
	if len(first) != len(second):
		print('Impossible')
	else:
		print(first + '|' + second)
main()


(L, R) = input().split('|')
for ch in input():
	if len(L) > len(R):
		R += ch
	else:
		L += ch
print(L + '|' + R if len(L) == len(R) else 'Impossible')


w = input()
l = list(input())
(right, left) = w.split('|')
right = list(right)
left = list(left)
while len(l) != 0:
	if len(right) < len(left):
		add = l.pop(-1)
		right.append(add)
	else:
		add = l.pop(-1)
		left.append(add)
ans = ''.join(right) + '|' + ''.join(left)
if len(right) != len(left):
	print('Impossible')
else:
	print(ans)


st = input()
l = input()
st.find('|')
w = len(l)
f = st.find('|')
s = len(st) - f - 1
w -= abs(s - f)
if w < 0 or w % 2 == 1:
	print('Impossible')
else:
	cw = int(w / 2)
	if f > s:
		print(l[0:cw], end='')
		print(st, end='')
		print(l[cw:], end='')
	else:
		print(l[0:len(l) - cw], end='')
		print(st, end='')
		if cw != 0:
			print(l[len(l) - cw:], end='')


def main():
	n = input().split('|')
	l = input()
	roz = len(n[0]) - len(n[1])
	if roz % 2 != len(l) % 2 or abs(roz) > len(l):
		print('Impossible')
	else:
		if roz > 0:
			for i in range(abs(roz)):
				n[1] += l[i]
		else:
			for i in range(abs(roz)):
				n[0] += l[i]
		for i in range(abs(roz), len(l)):
			if i % 2 == 0:
				n[0] += l[i]
			else:
				n[1] += l[i]
		print(n[0] + '|' + n[1])
main()


(a, b) = input().split('|')
x = a + input() + b
m = len(x) // 2
print([x[:m] + '|' + x[m:], 'Impossible'][max(map(len, [a, b, x[m:]])) > m])


def check(l, r):
	if len(left_scale) == len(right_scale):
		print(''.join(left_scale) + '|' + ''.join(right_scale))
	else:
		print('Impossible')
l = list(map(str, input().rstrip()))
delimiter = l.index('|')
left_scale = l[:delimiter]
right_scale = l[delimiter + 1:]
weight = list(map(str, input().rstrip()))
for i in weight:
	if len(left_scale) > len(right_scale):
		right_scale.append(i)
	else:
		left_scale.append(i)
check(left_scale, right_scale)


(left, right) = map(str, input().split('|'))
line = list(input())
for i in line:
	if len(left) > len(right):
		right += i
	else:
		left += i
if len(left) == len(right):
	print(left + '|' + right)
else:
	print('Impossible')


(left, right) = input().split('|')
minimal_string_is_left = True if len(left) < len(right) else False
weighs_left = input()
if (minimal_string_is_left and len(left) + len(weighs_left) < len(right) or (not minimal_string_is_left and len(weighs_left) + len(right) < len(left))) or (max(len(left), len(right)) - (min(len(left), len(right)) + len(weighs_left))) % 2 != 0:
	print('Impossible')
else:
	if minimal_string_is_left:
		difference = len(right) - len(left)
		left += weighs_left[:difference]
		weighs_left = weighs_left[difference:]
	else:
		difference = len(left) - len(right)
		right += weighs_left[:difference]
		weighs_left = weighs_left[difference:]
	left += weighs_left[:int(len(weighs_left) / 2)]
	right += weighs_left[int(len(weighs_left) / 2):]
	print(left + '|' + right)


(x, y) = map(str, input().split('|'))
s = input()
for i in range(len(s)):
	if len(x) >= len(y):
		y = y + s[i]
	else:
		x = x + s[i]
if len(x) != len(y):
	print('Impossible')
else:
	print(x + '|' + y)


s = input()
t = input()
ass = s.split('|')
al = len(s) + len(t) - 1
if al % 2 or len(ass[0]) > al // 2 or len(ass[1]) > al // 2:
	print('Impossible')
	exit(0)
lt = list(t)
ml = al // 2 - len(ass[0])
ass[0] += t[:ml]
ass[1] += t[ml:]
print(ass[0] + '|' + ass[1])


(l, r) = input().split('|')
s = input()
while len(s) > 0:
	if len(l) < len(r):
		l += s[0]
	else:
		r += s[0]
	s = s[1:]
if len(l) == len(r):
	print(l + '|' + r)
else:
	print('Impossible')


a = list(map(str, input().split('|')))
string = input()
diff = abs(len(a[0]) - len(a[1]))
if len(string) - diff >= 0 and (len(string) - diff) % 2 == 0:
	if len(a[0]) < len(a[1]):
		a[0] = string[0:int(diff + (len(string) - diff) / 2)] + a[0]
		a[1] = a[1] + string[int(diff + (len(string) - diff) / 2):]
	else:
		a[1] = string[0:int(diff + (len(string) - diff) / 2)] + a[1]
		a[0] = a[0] + string[int(diff + (len(string) - diff) / 2):]
	print(a[0] + '|' + a[1])
else:
	print('Impossible')


(lefthand, righthand) = map(list, input().split('|'))
weights = list(input())
needed = max(len(lefthand), len(righthand)) - min(len(lefthand), len(righthand))
remaining = len(weights) - needed
if remaining % 2 == 0 and remaining >= 0:
	if len(lefthand) > len(righthand):
		righthand = righthand + weights[:needed]
		weights = weights[needed:]
	else:
		lefthand = lefthand + weights[:needed]
		weights = weights[needed:]
	righthand = righthand + weights[:int(remaining / 2)]
	lefthand = lefthand + weights[int(remaining / 2):]
	print(''.join(lefthand) + '|' + ''.join(righthand))
else:
	print('Impossible')


(a, b) = input().split('|')
S = a + input() + b
s = len(S) // 2
print([S[:s] + '|' + S[s:], 'Impossible'][max(map(len, [a, b, S[s:]])) > s])


import math
n = input()
s = input()
mid = n.index('|')
l = len(s) + len(n) - 1
news = ''
t = int(l / 2)
news += n[:mid]
news += s[:t - mid]
news += '|'
news += n[mid + 1:len(n)]
news += s[t - mid:]
mid = news.index('|')
if mid != t or l % 2 != 0:
	print('Impossible')
else:
	print(news)


x = input()
z = input()
(a, b) = (-1, -1)
(p, q) = ('', '')
p = x[:x.find('|')]
q = x[x.find('|') + 1:]
n = 0
while n < len(z):
	if len(p) < len(q):
		p += z[n]
	else:
		q += z[n]
	n += 1
if len(p) == len(q):
	print(p, '|', q, sep='')
else:
	print('Impossible')


import sys
(s, t) = (next(sys.stdin).strip(), next(sys.stdin).strip())
u = s.split('|')
for i in range(len(t) + 1):
	v = (u[0] + t[:i], u[1] + t[i:])
	if len(v[0]) == len(v[1]):
		print('%s|%s' % v)
		break
else:
	print('Impossible')


__author__ = 'asmn'
(l, r) = tuple(input().split('|'))
s = input()
num = len(s) - abs(len(l) - len(r))
if num < 0 or num % 2 != 0:
	print('Impossible')
elif len(l) < len(r):
	print(s[0:num // 2] + s[num:] + l, s[num // 2:num] + r, sep='|')
else:
	print(s[0:num // 2] + l, s[num // 2:num] + s[num:] + r, sep='|')


(Left, Right) = list(input().split('|'))
Remained = input()
Total = len(Left) + len(Right) + len(Remained)
if Total / 2 != Total // 2:
	print('Impossible')
	exit()
if Total // 2 < len(Right) or Total // 2 < len(Left):
	print('Impossible')
	exit()
Dif1 = Total // 2 - len(Left)
print(Left + Remained[:Dif1] + '|' + Right + Remained[Dif1:])


a = input()
b = input()
if (len(a) + len(b)) % 2 == 0:
	r = 'Impossible'
else:
	(a1, a2) = tuple(a.split('|'))
	if abs(len(a1) - len(a2)) > len(b):
		r = 'Impossible'
	else:
		m = (len(a) + len(b) - 1) // 2
		r = a1 + b[:m - len(a1)] + '|' + a2 + b[m - len(a1):]
print(r)


s = str(input())
s2 = str(input())
(a, b) = s.split('|')
origLeft = len(a)
origRight = len(b)
maxlen = max(origLeft, origRight)
if min(origLeft, origRight) + len(s2) < maxlen:
	print('Impossible')
elif min(origLeft, origRight) + len(s2) == maxlen:
	if origLeft > origRight:
		b += s2
		print(a + '|' + b)
	else:
		a += s2
		print(a + '|' + b)
else:
	f = 0
	minn = 0
	fr = ''
	other = 0
	if origLeft > origRight:
		fr = 'b'
		minn = len(b)
		other = len(a)
	else:
		fr = 'a'
		minn = len(a)
		other = len(b)
	minn += len(s2)
	if fr == 'b':
		while minn > origRight:
			minn -= 1
			other += 1
			if minn == other:
				print(a + s2[0:other - origLeft] + '|' + b + s2[other - origLeft:])
				f = 1
				break
		if f == 0:
			print('Impossible')
	elif fr == 'a':
		while minn > origLeft:
			minn -= 1
			other += 1
			if minn == other:
				print(a + s2[0:other - origLeft] + '|' + b + s2[other - origLeft:])
				f = 1
				break
		if f == 0:
			print('Impossible')


x = input()
y = input()
for c in y:
	left = x.index('|')
	right = len(x) - left - 1
	if left < right:
		x = c + x
	else:
		x = x + c
left = x.index('|')
right = len(x) - left - 1
if left != right:
	print('Impossible')
else:
	print(x)


s = input()
t = input()
k = s.split('|')
for i in range(len(t)):
	if len(k[0]) >= len(k[1]):
		k[1] = k[1] + t[i]
	else:
		k[0] = k[0] + t[i]
if len(k[0]) != len(k[1]):
	print('Impossible')
else:
	print(k[0] + '|' + k[1])


(l, r) = input().split('|')
n = input()
if len(r) < len(l):
	if len(n) + len(r) < len(l):
		print('Impossible')
	elif len(n) + len(r) == len(l):
		r += n
		print(l + '|' + r)
	elif (len(n) + len(r) + len(l)) % 2 != 0:
		print('Impossible')
	else:
		(toR, toL) = (n[0:len(l) - len(r)], n[len(l) - len(r):])
		r += toR
		(h1, h2) = (toL[0:len(toL) // 2], toL[len(toL) // 2:])
		l += h2
		r += h1
		print(l + '|' + r)
elif len(l) == len(r):
	if len(n) % 2 != 0:
		print('Impossible')
	else:
		(h1, h2) = (n[0:len(n) // 2], n[len(n) // 2:])
		l += h2
		r += h1
		print(l + '|' + r)
elif len(n) + len(l) < len(r):
	print('Impossible')
elif len(n) + len(l) == len(r):
	l += n
	print(l + '|' + r)
elif (len(n) + len(r) + len(l)) % 2 != 0:
	print('Impossible')
else:
	(toL, toR) = (n[0:len(r) - len(l)], n[len(r) - len(l):])
	l += toL
	(h1, h2) = (toR[0:len(toR) // 2], toR[len(toR) // 2:])
	l += h2
	r += h1
	print(l + '|' + r)


x = input()
y = x.split('|')
z = input()
z_n = [d for d in z]
lit = []
list_for_w1 = [d for d in y[0]]
list_for_w2 = [d for d in y[1]]
Ans1 = ''
Ans2 = ''
if (len(y[0]) + len(y[1]) + len(z)) % 2 != 0:
	print('Impossible')
	quit()
else:
	l1 = len(y[0])
	l2 = len(y[1])
for num in list_for_w1:
	lit.append(num)
for dum in z_n:
	lit.append(dum)
for num in list_for_w2:
	lit.append(num)
if len(lit) % 2 == 0:
	k1 = lit[:len(lit) // 2]
	k2 = lit[len(lit) // 2:]
for num in k1:
	Ans1 = Ans1 + num
for num in k2:
	Ans2 = Ans2 + num
if len(Ans1) == len(Ans2) and len(lit) % 2 == 0:
	if len(y[0]) >= len(y[1]) and y[0] in Ans1 or (len(y[1]) >= len(y[0]) and y[1] in Ans2):
		print(Ans1 + '|' + Ans2)
	else:
		print('Impossible')
		quit()
else:
	print('Impossible')


from sys import stdin

def main():
	a = input()
	b = input()
	for i in range(0, len(a)):
		if a[i] == '|':
			c = a[0:i]
			d = a[i + 1:len(a)]
	for i in range(0, len(b)):
		if len(c) > len(d):
			d = d + b[i]
		else:
			c = c + b[i]
	if len(c) == len(d):
		print(c + '|' + d)
	else:
		print('Impossible')
main()


def main():
	current = input().strip().split('|')
	unused = input().strip()
	lengths = [len(x) for x in current]
	(ll, lr, lu) = (min(lengths[0], lengths[1]), max(lengths[0], lengths[1]), len(unused))
	r = None
	if (ll + lr + lu) % 2 == 1 or ll + lu < lr:
		r = 'Impossible'
	else:
		lmid = ll + lr + lu >> 1
		(lb, rb) = (list(), list())
		i = 0
		while len(lb) + len(current[0]) < lmid:
			lb.append(unused[i])
			i += 1
		while len(rb) + len(current[1]) < lmid:
			rb.append(unused[i])
			i += 1
		r = current[0] + ''.join(lb) + '|' + current[1] + ''.join(rb)
	print(r)
main()


from sys import stdin

def solve(vec, v):
	v = list(v)
	lista = vec.split('|')
	(l1, l2) = (list(lista[0]), list(lista[1]))
	cont = 0
	while cont < len(v):
		if len(l1) < len(l2):
			l1.append(v[cont])
			cont += 1
		else:
			l2.append(v[cont])
			cont += 1
	if len(l1) == len(l2):
		a1 = ''
		a2 = ''
		for i in range(len(l1)):
			a1 = a1 + str(l1[i])
			a2 = a2 + str(l2[i])
		print(a1 + '|' + a2)
	else:
		print('Impossible')

def main():
	vec = stdin.readline().strip()
	v = stdin.readline().strip()
	solve(vec, v)
main()


def INT():
	return int(input())

def lis():
	return [int(x) for x in input().split()]

def S():
	return str(input())
(left, right) = list(S().split('|'))
giv = S()
le = len(left)
ri = len(right)
gi = len(giv)
first = abs(le - ri)
second = gi - first
if le == ri:
	if gi % 2 == 0:
		left = left + giv[:gi // 2]
		right = right + giv[gi // 2:]
		print(left + '|' + right)
	else:
		print('Impossible')
elif gi >= first:
	if le > ri:
		right = right + giv[:first]
	else:
		left = left + giv[:first]
	if second % 2 == 0 and second > 0:
		right = right + giv[first:first + second // 2]
		left = left + giv[first + second // 2:]
	if second % 2 == 0:
		print(left + '|' + right)
	else:
		print('Impossible')
else:
	print('Impossible')