#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IMX INT_MAX
#define IMN INT_MIN
int discard; //you can access string length using the function
string str1, str2, temp;
int main () {
    cin >> discard >> discard >> str1 >> str2;
    if (str1.length() > str2.length()) {//if str1 is not the shorter one, make it the shorter one by switching
        temp = str2;
        str2 = str1;
        str1 = temp;
    }
    for (int size = str1.length(); size >= 1; size--) { //backwards length checking
        for (int j = 0; j <= str1.length() - size; j++) { //start position
            temp = str1.substr(j, size); //the substring
            if (str2.find(temp) != string::npos) { //if the substring works, it is the largest
                cout << "The longest common substring: " << temp; //output and end program
                return 0;
            }
        }
    }
    cout << "No Common Substring";
    return 0;
}