#include <bits/stdc++.h>
const long long mod = (long long)1e9 + 7;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  string ans = s;
  long long n;
  cin >> n;
  long long cnt = 0;
  while (n--) {
    string c;
    cin >> c;
    bool valid = true;
    for (long long i = 0; i < s.size(); i++) {
      if (s[i] != c[i]) {
        valid = false;
      }
    }
    if (valid) {
      if (cnt == 0) {
        ans = c;
        cnt = 1;
      } else {
        ans = min(ans, c);
      }
    }
  }
  cout << ans << "\n";
  return 0;
}
