#include <bits/stdc++.h>
int main() {
  char s[1000];
  char line[1000];
  int i, j, k, n;
  int found;
  char result[1000];
  int contain;
  scanf("%s", &s);
  scanf("%d", &n);
  found = 0;
  for (i = 0; i < 1000; i += 1) result[i] = 'z';
  for (i = 0; i < n; i += 1) {
    scanf("%s", &line);
    contain = 1;
    if (strlen(line) < strlen(s))
      contain = 0;
    else {
      for (j = 0; j < strlen(s); j += 1) {
        if (s[j] != line[j]) {
          contain = 0;
          break;
        }
      }
    }
    if (contain == 1) {
      if (strcmp(line, result) < 0) {
        found = 1;
        strcpy(result, line);
      }
    }
  }
  if (found == 0) {
    printf("%s\n", s);
  } else {
    printf("%s\n", result);
  }
  return 0;
}
