#include <bits/stdc++.h>
using namespace std;
const int N = 10e5;
void Auto(string k, int n) {
  string x, mins = "z";
  int t = 0;
  bool oo = true;
  for (int i = 0; i < (int)n; i++) {
    cin >> x;
    if (x == k) {
      cout << k << endl;
      return;
    }
    if (x > k) {
      for (int j = 0; j < (int)((int)((k).size())); j++)
        if (x[j] == k[j])
          ++t;
        else
          break;
    }
    if (t == ((int)((k).size())) && mins > x) {
      oo = false;
      mins = x;
    }
    t = 0;
  }
  if (oo)
    cout << k << endl;
  else
    cout << mins << endl;
}
int main() {
  int n;
  string k;
  cin >> k >> n;
  Auto(k, n);
}
