시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 23 1 1 16.667%

문제

알파벳 소문자로 되어있는 두 문자열 a와 b가 주어졌을 때, ax 또는 bx가 팰린드롬이 되는 가장 짧은 문자열 x를 찾는 프로그램을 작성하시오. 이때, ax와 bx가 둘 다 팰린드롬이면 안 된다. 

입력

입력은 여러개의 테스트 케이스로 되어 있다. 각 테스트 케이스는 두 줄이고, 첫째 줄에는 a, 둘째 줄에는 b가 주어진다. 각 문자열은 0개 이상, 1,000개 이하의 알파벳 소문자로 이루어져 있다.

출력

각 테스트 케이스에 대해서 문제의 조건을 만족하는 가장 짧은 x를 출력한다. 만약 그러한 x가 여러개라면 사전순으로 가장 앞서는 것을 출력한다.

예제 입력 1

abab
ababab
abc
def

예제 출력 1

baba
ba
W3sicHJvYmxlbV9pZCI6IjQzOTkiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIwNWRcdWM3NzhcdWI0ZGNcdWI4NmMiLCJkZXNjcmlwdGlvbiI6IjxwPlxyXG5cdFx1YzU0Y1x1ZDMwY1x1YmNiMyBcdWMxOGNcdWJiMzhcdWM3OTBcdWI4NWMgXHViNDE4XHVjNWI0XHVjNzg4XHViMjk0IFx1YjQ1MCBcdWJiMzhcdWM3OTBcdWM1ZjQgYVx1YzY0MCBiXHVhYzAwIFx1YzhmY1x1YzViNFx1Yzg0Y1x1Yzc0NCBcdWI1NGMsIGF4IFx1YjYxMFx1YjI5NCBieFx1YWMwMCBcdWQzMzBcdWI5YjBcdWI0ZGNcdWI4NmNcdWM3NzQgXHViNDE4XHViMjk0IFx1YWMwMFx1YzdhNSBcdWM5ZTdcdWM3NDAgXHViYjM4XHVjNzkwXHVjNWY0IHhcdWI5N2MgXHVjYzNlXHViMjk0IFx1ZDUwNFx1Yjg1Y1x1YWRmOFx1YjdhOFx1Yzc0NCBcdWM3OTFcdWMxMzFcdWQ1NThcdWMyZGNcdWM2MjQuIFx1Yzc3NFx1YjU0Yywg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