#include #include #include char input[4001][201]; char sablona[201]; int lengths[4001]; int main() { while (1) { int cases; int i, min_index; int lines = 0; int min_length = 201; scanf("%d\n", &cases); if (!cases) break; for (i = 0; i < cases; i++) { scanf("%s\n", input[lines]); int tmp = strlen(input[lines]); lengths[i] = tmp; if (min_length > tmp) { min_length = tmp; min_index = lines; } lines++; } int len = lengths[min_index]; int offset = 0; int j; int max_match = 0; char string_match[201]; for (i = len; i >= 0; i--) { for (offset = 0; offset < len-2; offset++) { strncpy(sablona, input[min_index]+offset, i); int match = 0; for (j = 0; j < lines; j++) { if (strstr(input[j], sablona)) { match++; } else { break; } } if(match == lines) { if (len-offset > max_match || (len-offset == max_match && strcmp(string_match, sablona) > 0)) { strcpy(string_match, sablona); max_match = len-offset; } } } if (max_match != 0) { break; } } if (max_match != 0) { printf("%s\n", string_match); } else { printf("IDENTITY LOST %s\n", input[i]); } } return 0; }