#include <bits/stdc++.h>
using namespace std;
int tc;
bool comp(string a, string b) {
  if (a.size() == b.size()) {
    for (long long int i = 0; i < a.size(); i++) {
      if (a[i] > b[i])
        return true;
      else if (a[i] < b[i])
        return false;
    }
    return false;
  }
  return a.size() < b.size();
}
int main(void) {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  string s;
  cin >> s;
  long long int n;
  cin >> n;
  vector<string> v;
  for (long long int i = 0; i < n; i++) {
    long long int flag = 0;
    string a;
    cin >> a;
    for (long long int j = 0; j < a.size(); j++) {
      if (j > s.size() - 1) break;
      if (a[j] != s[j]) {
        flag = 1;
        break;
      }
    }
    if (flag == 0) v.push_back(a);
  }
  sort(v.begin(), v.end());
  if (v.size() == 0)
    cout << s;
  else
    cout << v[0];
}
