Concatenate two text file and make the suffix array indexing;
Keep the line ID and Text ID (here Text ID is A and B);
After the suffix array indexing constructed, the text file will be sorted according to the alphabet order. simply identify the duplicate prefix and see their correspondent line ID;