#include <bits/stdc++.h>
using namespace std;
int main() {
  string word, visited[101], Min = "zzzzzzzzzzzzz";
  cin >> word;
  int n;
  cin >> n;
  bool found = false;
  for (int i = 0; i < n; i++) {
    cin >> visited[i];
    int index = visited[i].find(word);
    if (index == 0) {
      found = true;
      string substring = visited[i].substr(word.length());
      Min = min(Min, substring);
    }
  }
  if (found)
    cout << word << Min;
  else
    cout << word;
  return 0;
}
