/******************************************
*    AUTHOR:         BHUVNESH JAIN        *
*    INSTITUITION:   BITS PILANI, PILANI  *
******************************************/
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL; 
typedef long double LD;
typedef pair<int,int> pii;

const int MAX = 1e5 + 5;
const int LIM = 50;
const long long p1 = 31;
const long long mod = 999999937;

int n;
string s, p;
map<int,vector<int>> h[LIM];

int main() {
	#ifndef ONLINE_JUDGE
		// freopen("inp.txt", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin >> s;
	n = s.length();
	int q, l, r, m;
	int a, b, c, d;
	for(int i = 0; i < n; ++i) {
		a = 0;
		for(int j = 0; j < 10; ++j) {
			if(i+j >= n) break;
			a = (1ll*a*p1)%mod + (s[i+j]-'a'+1);
			a %= mod;
			h[j][a].push_back(i);
		}
	}
	cin >> q;
	while(q--) {
		cin >> l >> r >> p;
		l -= 1;
		r -= 1;
		m = p.length();
		b = 0, c = 0;
		for(int i = 0; i < m; ++i) {
			if (p[i] == '*') {
				b += 1;
			}
			else {
				c += 1;
			}
		}
		if (b == m) {
			//all *
			printf("Yes\n");
			continue;
		}
		if (c == m && (r-l+1) > m) {
			//all alpha
			printf("No\n");
			continue;
		}
		if (c > (r-l+1)) {
			//alpha count > size of substring
			printf("No\n");
			continue;
		}
		bool ans = 1;
		int st = 0, lt = m-1;
		b = l, c = r;
		if (p[st] != '*') {
			//case of inital character(s)
			while(st < m && p[st] != '*') {
				if (p[st] != s[b]) {
					ans = 0;
					break;
				}
				b += 1;
				st += 1;
			}
			if (ans == 0) {
				printf("No\n");
				continue;
			}
		}
		if (p[lt] != '*') {
			//case of last character(s)
			while(lt >= 0 && p[lt] != '*') {
				if (p[lt] != s[c]) {
					ans = 0;
					break;
				}
				c -= 1;
				lt -= 1;
			}
			if (ans == 0) {
				printf("No\n");
				continue;
			}
		}
		//start and end character are *
		if (st <= lt) {
			assert(p[st] == '*');
			assert(p[lt] == '*');
		}
		d = b;
		for(int i = st; i < lt; ++i) {
			if (p[i] == '*') {
				int j = i;
				while(j < m && p[j] == p[i]) {
					j += 1;
				}
				i = j-1;
				continue;
			}
			//case of fixed character
			int j = i, cnt = -1;
			a = 0;
			while(j < m && p[j]!='*') {
				a = (1ll*a*p1)%mod + (p[j]-'a'+1);
				a %= mod;
				j += 1;
				cnt += 1;
			}
			auto it = lower_bound(h[cnt][a].begin(), h[cnt][a].end(), d);
			if (it == h[cnt][a].end()) {
				ans = 0;
				break;
			}
			int v = *it;
			//check if pattern doesn't cross the segment [l:r]
			if ((v+cnt) > r) {
				ans = 0;
				break;
			}
			d = v+1;
			i = j-1;
		}
		if (ans) {
			printf("Yes\n");
		}
		else {
			printf("No\n");
		}
	}
	return 0;
}