#include using namespace std; using ll = long long; using vi = vector; using vl = vector; using vs = vector; using sl = set; using pl = pair; #define MOD 998244353 #define MOD2 1000000007 #define INF 1e18 #define all(v) v.begin(), v.end() #define SORT(v) sort(v.begin(), v.end()) #define RSORT(v) sort(v.rbegin(), v.rend()) #define REVERSE(v) reverse(v.begin(), v.end()) #define YESNO(b) cout << ((b) ? "Yes" : "No") << endl #define DOUT(a, b) cout << fixed << setprecision(b) << a << endl; int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, -1, 0, 1}; template void debug_out(const vector &x){ for(auto &y : x) cerr << y << " "; cerr << endl; } int main(void){ int n, k; cin >> n >> k; vs a(n); string rt(k, '9'); for (int i = 0; i < n; i++) { cin >> a[i]; for (int j = 0; j < k; j++) { rt[j] = min(rt[j], a[i][j]); } } cout << rt << endl; }