#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  string s;
  cin >> s;
  vector<string> ans;
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    string p;
    cin >> p;
    long long flag = 0;
    for (long long j = 0; j < s.length(); j++) {
      if (s[j] != p[j]) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      ans.push_back(p);
    }
  }
  if (ans.size() == 0) {
    cout << s << endl;
  } else {
    sort(ans.begin(), ans.end());
    cout << ans[0] << endl;
  }
  return 0;
}
