시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB81181634.783%

문제

문자열 A의 부분 문자열이란, A에 속하는 하나 또는 그 이상의 문자(연속하지 않아도 된다)를 이용해서 만든 새로운 문자열이다. 이때, A에서의 순서를 그대로 유지해야 된다.

두 문자열 A와 B가 주어진다. 이때, A의 부분 문자열이면서, B의 부분 문자열이 아닌 가장 짧은 부분 문자열을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 문자열 A, 둘째 줄에 문자열 B가 주어진다. 문자열은 알파벳 소문자로만 이루어져 있고, 길이는 2000보다 작거나 같다. 항상 정답이 존재하는 경우만 입력으로 주어진다. 

출력

첫째 줄에 A의 부분 문자열이면서, B의 부분 문자열이 아닌 가장 짧은 부분 문자열의 길이를 출력하고, 둘째 줄에는 문자열을 출력한다. 만약, 가능한 문자열이 여러 가지인 경우에는 아무거나 출력한다.

예제 입력 1

ababaa
abbaa

예제 출력 1

3
bab

예제 입력 2

babab
babba

예제 출력 2

3
aab

예제 입력 3

banana
anbnaanbaan

예제 출력 3

5
banna
W3sicHJvYmxlbV9pZCI6IjMyNDQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI0NTAgXHViZDgwXHViZDg0IFx1YmIzOFx1Yzc5MFx1YzVmNCAyIiwiZGVzY3JpcHRpb24iOiI8cD5cdWJiMzhcdWM3OTBcdWM1ZjQgQVx1Yzc1OCBcdWJkODBcdWJkODQgXHViYjM4XHVjNzkwXHVjNWY0XHVjNzc0XHViNzgwLCBBXHVjNWQwIFx1YzE4ZFx1ZDU1OFx1YjI5NCBcdWQ1NThcdWIwOTggXHViNjEwXHViMjk0IFx1YWRmOCBcdWM3NzRcdWMwYzFcdWM3NTggXHViYjM4XHVjNzkwKFx1YzVmMFx1YzE4ZFx1ZDU1OFx1YzljMCBcdWM1NGFcdWM1NDRcdWIzYzQgXHViNDFjXHViMmU0KVx1Yjk3YyBcdWM3NzRcdWM2YTlcdWQ1NzRcdWMxMWMgXHViOWN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