#include <bits/stdc++.h>
using namespace std;
bool pref(string a, string b) {
  int i, l1 = a.length(), l2 = b.length();
  if (l1 > l2) return false;
  i = 0;
  while (i < l1) {
    if (a[i] != b[i]) return false;
    i++;
  }
  return true;
}
int main() {
  string pre, str, ans;
  int i, n;
  cin >> pre >> n;
  bool found = false;
  while (n--) {
    cin >> str;
    if (pref(pre, str)) {
      if (!found) {
        ans.assign(str);
        found = !found;
      } else {
        if (ans.compare(str) > 0) ans.assign(str);
      }
    }
  }
  if (!found)
    cout << pre << endl;
  else
    cout << ans << endl;
  return 0;
}
