#include <bits/stdc++.h>
using namespace std;
const int N = 110;
struct node {
  string s;
} a[N];
bool cmp(node a, node b) {
  if (a.s.size() != b.s.size()) a.s.size() > b.s.size();
  for (int i = 0; i < a.s.size(); i++) {
    if (a.s[i] != b.s[i]) return a.s[i] < b.s[i];
  }
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n;
  cin >> n;
  int bet = 0;
  for (int i = 0; i < n; i++) {
    string ss;
    cin >> ss;
    bool flag = true;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] != ss[j]) {
        flag = false;
        break;
      }
    }
    if (flag) a[bet++].s = ss;
  }
  if (bet) {
    sort(a, a + bet, cmp);
    cout << a[0].s << endl;
  } else
    cout << s << endl;
  return 0;
}
