#include <bits/stdc++.h>
using namespace std;
static bool compare(string s, string temp) {
  if (s.size() > temp.size()) return false;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != temp[i]) return false;
  }
  return true;
}
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int max = n - 1, min = 0;
  while (max - min > 1) {
    int temp = (max + min) / 2;
    if (compare(s, a[temp]))
      max = temp;
    else
      min = temp;
  }
  int result = -1;
  if (compare(s, a[max])) result = max;
  if (compare(s, a[min])) result = min;
  if (result == -1)
    cout << s;
  else
    cout << a[result];
  return 0;
}
