#include <bits/stdc++.h>
using namespace std;
int main() {
  short int q, w, e, r = 100, q1, q2, q3;
  char a[101], s[101], d[101] = {'{'};
  cin >> a >> q;
  q1 = strlen(a);
  bool c;
  for (w = 0; w < q; w++) {
    cin >> s;
    c = 1;
    for (e = 0; (e < q1) && (c); e++)
      if (a[e] != s[e]) c = 0;
    if (c) {
      q2 = strlen(s);
      for (e = q1; e <= q2; e++) {
        if (d[e - q1] < s[e]) break;
        if (d[e - q1] > s[e]) {
          c = 0;
          break;
        }
      }
      if (!c) {
        r = q2 - q1;
        for (e = q1; e <= q2; e++) d[e - q1] = s[e];
      }
    }
  }
  cout << a;
  if (r < 100) cout << d;
  return 0;
}
