#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int n;
  cin >> n;
  string arr[150];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    if (str == arr[i]) {
      cout << str;
      return 0;
    }
  }
  vector<string> s;
  int m = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < str.size(); j++) {
      if (str[j] == arr[i][j]) m++;
    }
    if (m == str.size()) s.push_back(arr[i]);
    m = 0;
  }
  sort(s.begin(), s.end());
  if (s.size() > 0)
    cout << s[0];
  else
    cout << str;
  return 0;
}
