#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
int main() {
  string s, s1, ans;
  getline(cin, s);
  int n;
  scanf("%d\n", &n);
  for (int i = 0; i < n; i++) {
    getline(cin, s1);
    if (s1.size() < s.size()) continue;
    bool q = true;
    for (int j = 0; j < s.size(); j++)
      if (s[j] != s1[j]) q = false;
    if (!q) continue;
    if (ans.empty() || ans > s1) ans = s1;
  }
  if (ans.empty())
    cout << s;
  else
    cout << ans;
  return 0;
}
