#include #include #include #include #include using namespace std; int main() { // bool first = true; while (true) { string line; string youso; string aaa; bool flag = true; while (getline(cin, aaa) && aaa != "") { flag = false; line += aaa; } getline(cin, youso); if (flag && youso == "") { break; } string tmp; getline(cin, tmp); // cout << "line: " << line << endl; // cout << "youso: " << youso << endl; // if (first) { first = false; } // else { cout << endl; } map chars; for (int i = 0; i < youso.size(); i++) { chars[youso[i]] = chars.size() - 1; } int table[chars.size()]; for (int i = 0; i < chars.size(); i++) { table[i] = -1; } int ans = 99999999; int ans_count = 0; string ans_str; for (int i = 0; i < line.size(); i++) { if (chars.find(line[i]) == chars.end()) { continue; } table[chars[line[i]]] = i; int tmpMax = i; int tmpMin = i; for (int j = 0; j < chars.size(); j++) { tmpMax = max(tmpMax, table[j]); tmpMin = min(tmpMin, table[j]); } if (tmpMin == -1) { continue; } if (ans > tmpMax - tmpMin + 1) { ans = tmpMax - tmpMin + 1; ans_count = 1; ans_str = line.substr(tmpMin, tmpMax - tmpMin + 1); } else if (ans == tmpMax - tmpMin + 1) { ans_count++; } } if (ans != 99999999) { cout << ans_count << endl << endl; int i; for (i = 0; i < ans_str.size(); i++) { if (i % 72 == 0 && i != 0) { cout << endl; } cout << ans_str[i]; } if (i % 72 != 1) { cout << endl; } // cout << ans_str << endl; } else { cout << "0" << endl; } cout << endl; } return 0; }