시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
2 초 128 MB 334 73 56 21.961%

문제

알파벳 소문자로 이루어진 두 문자열 a와 b에 대해, a의 부분문자열의 순열이자 b의 부분문자열의 순열이 되는 가장 긴 문자열 x를 구하여라

입력

각각의 입력은 한 쌍의 줄로 이루어져 있다.

첫 줄에는 문자열 a가 두번째 줄에는 문자열 b가 주어진다.

각각의 문자열은 줄로 구분되며, 최대 1000개의 알파벳 소문자로 이루어졌다.

출력

각각의 입력에 대해, x를 출력한다.

가능한 x가 여러 개 존재하는 경우, 사전순으로 가장 앞에 오는 것을 출력한다.

예제 입력 1

pretty
women
walking
down
the
street

예제 출력 1

e
nw
et
W3sicHJvYmxlbV9pZCI6IjE2MjIiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWFjZjVcdWQxYjUgXHVjMjFjXHVjNWY0IiwiZGVzY3JpcHRpb24iOiI8cD5cdWM1NGNcdWQzMGNcdWJjYjMgXHVjMThjXHViYjM4XHVjNzkwXHViODVjIFx1Yzc3NFx1YjhlOFx1YzViNFx1YzljNCBcdWI0NTAgXHViYjM4XHVjNzkwXHVjNWY0IGFcdWM2NDAgYlx1YzVkMCBcdWIzMDBcdWQ1NzQsIGFcdWM3NTggXHViZDgwXHViZDg0XHViYjM4XHVjNzkwXHVjNWY0XHVjNzU4IFx1YzIxY1x1YzVmNFx1Yzc3NFx1Yzc5MCBiXHVjNzU4Jm5ic3A7XHViZDgwXHViZDg0XHViYjM4XHVjNzkwXHVjNWY0XHVjNzU4IFx1YzIxY1x1YzVmNFx1Yzc3NCBcdWI0MThcdWIyOTQgXHVhYzAwXHVjN2E1IFx1YWUzNCBcdWJiMzhcdWM3OTBcdWM1ZjQgeFx1Yjk3YyBcdWFkNmNcdWQ1NThcdWM1ZWNcdWI3N2M8XC9wPlxyXG4iLCJpbnB1dCI6IjxwPlx1YWMwMVx1YWMwMVx1Yzc1OCBcdWM3ODVcdWI4MjVcdWM3NDAgXHVkNT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