#include <bits/stdc++.h>
using namespace std;
bool IsPref(string s1, string s2) {
  if (s1.length() > s2.length()) {
    return 0;
  }
  for (int i = 0; i < s1.length(); i++) {
    if (s1[i] != s2[i]) {
      return 0;
    }
  }
  return 1;
}
int main() {
  string s, s1, sp = "";
  bool flag = 0;
  cin >> s;
  int n, i, j;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s1;
    if (IsPref(s, s1) && (!flag || s1 < sp)) {
      sp = s1;
      flag = 1;
    }
  }
  if (flag) {
    cout << sp;
  } else {
    cout << s;
  }
  return 0;
}
