s = "4" * 123
while '4444' in s or '7777' in s:
if '4444' in s:
s = s.replace('4444', '77')
else:
s = s.replace('7777', '44')
print(s)
s = "4" * 123
while '4444' in s or '7777' in s:
if '4444' in s:
s = s.replace('4444', '77')
else:
s = s.replace('7777', '44')
print(s)