시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 33 12 8 72.727%

문제

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

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

입력

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

출력

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

예제 입력 1

ababaa
abbaa

예제 출력 1

3
bab
W3sicHJvYmxlbV9pZCI6IjMyNDQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI0NTAgXHViZDgwXHViZDg0IFx1YmIzOFx1Yzc5MFx1YzVmNCAyIiwiZGVzY3JpcHRpb24iOiI8cD5cdWJiMzhcdWM3OTBcdWM1ZjQgQVx1Yzc1OCBcdWJkODBcdWJkODQgXHViYjM4XHVjNzkwXHVjNWY0XHVjNzc0XHViNzgwLCBBXHVjNWQwIFx1YzE4ZFx1ZDU1OFx1YjI5NCBcdWQ1NThcdWIwOTggXHViNjEwXHViMjk0IFx1YWRmOCBcdWM3NzRcdWMwYzFcdWM3NTggXHViYjM4XHVjNzkwKFx1YzVmMFx1YzE4ZFx1ZDU1OFx1YzljMCBcdWM1NGFcdWM1NDRcdWIzYzQgXHViNDFjXHViMmU0KVx1Yjk3YyBcdWM3NzRcdWM2YTlcdWQ1NzRcdWMxMWMgXHViOWNjXHViNGUwIFx1YzBjOFx1Yjg1Y1x1YzZiNCBcdWJiMzhcdWM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