#include <bits/stdc++.h>
#define f(i, s, k, l) for (int i = s; i < k; i += l)
#define for0(i, k) f(i, 0, k, 1)

#define pl pair<long long, long long>
#define pb push_back

#define vl vector<long long>
#define vi vector<int>
#define sz(x) (ll)(x).size()

using namespace std;
using ll = long long;
using ld = float;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

    string s;
    cin >> s;
    ll n;
    cin >> n;
    vector<string> w(n);
    for0(i, n) cin >> w[i];
    ll count = 0;
    for0(i, n) {
        if (s.starts_with(w[i]) || s.ends_with(w[i])) count++;
    }
    // With many overlapping words, the count can increase above 2.
    if (count == 2) cout << "yes" << endl;
    else cout << "no" << endl;
}
