#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;
string longchar(vector<string>& strs,int n) {
if (n == 0) {
return "";
}
for (int i = 0; i < strs[0].length(); i++) {
for (int j = 1; j < strs.size(); j++) {
if (i == strs[j].length() || strs[j][i] != strs[0][i]) {
return strs[0].substr(0, i);
}
}
}
return strs[0];
}
int main() {
int n = 0;
string s = "";
cin >> n;
vector<string> a(n);
for (auto& s : a) {
cin >> s;
}
s=longchar(a,n);
cout << s << endl;
}