#include <bits/stdc++.h>
using namespace std;
int main() {
  char pal[300];
  char book[200][200];
  int tb[200];
  char aux;
  int cont, j, k;
  int i = 0;
  int tam;
  while (scanf("%c", &aux) == 1 && aux != '\n') {
    pal[i++] = aux;
  }
  tam = i;
  pal[tam] = '\0';
  scanf("%d%*c", &cont);
  for (j = 0; j < cont; j++) {
    i = 0;
    while (scanf("%c", &aux) == 1 && aux != '\n') {
      book[j][i++] = aux;
    }
    tb[j] = i;
    book[j][i] = '\0';
  }
  char temp[300];
  for (i = 1; i < cont; i++)
    for (j = 0; j < cont - 1; j++)
      if (strcmp(book[j], book[j + 1]) > 0) {
        strcpy(temp, book[j]);
        strcpy(book[j], book[j + 1]);
        strcpy(book[j + 1], temp);
      }
  int sim = 1;
  int xx = -1;
  for (j = 0; j < cont && sim; j++) {
    sim = 0;
    for (i = 0; i < tam; i++) {
      if (pal[i] != book[j][i]) {
        sim = 1;
      }
    }
    if (!sim) xx = j;
  }
  if (xx != -1)
    printf("%s\n", book[xx]);
  else {
    for (i = 0; i < tam; i++) {
      printf("%c", pal[i]);
    }
    printf("\n");
  }
}
