#include <bits/stdc++.h>   using namespace std;   bool is_prefix(string s, string comp) {     bool res = false;     int sz = s.size();     int comp_sz = comp.size();     if (sz > comp_sz)       return res;     else {       res = true;       for (int i = 0; i < sz; i++) {         if (s[i] != comp[i]) {           res = false;           break;         }       }     }     return res;   }   int main(int argc, char* argv[]) {     int n;     string s;     vector<string> res;     cin >> s;     cin >> n;     for (int i = 0; i < n; i++) {       string t;       cin >> t;       if (is_prefix(s, t)) res.push_back(t);     }     if (res.size() == 0) {       cout << s;     } else {       sort(res.begin(), res.end());       cout << res[0];     }     return 0;   }   