import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.util.Map.Entry;
import static java.
lang.
Math.
*;
void run() {
Map
<String, List
<Integer
>> f
= new HashMap
<String, List
<Integer
>>(1 << 21); int n = s.length();
int m = nextInt();
int[] l = new int[m];
int[] r = new int[m];
for (int j = 0; j < m; j++) {
l[j] = nextInt() - 1;
r[j] = nextInt() - 0;
int k = str.length();
int li = 0;
while (li < k) {
while (li < k && str.charAt(li) == '*') {
++li;
}
int ri = li;
while (ri < k && str.charAt(ri) != '*') {
++ri;
}
if (li < ri) {
String sub
= str.
substring(li, ri
); f.put(sub, new ArrayList<Integer>());
}
li = ri;
}
}
for (int i = 0; i < n; i++) {
for (int len = min(10, n - i); len >= 1; len--) {
List<Integer> list = f.get(s.substring(i, i + len));
if (list != null) {
list.add(i);
}
}
}
for (int j = 0; j < m; j++) {
boolean ok = true;
int i = l[j];
int k = str.length();
int li = 0;
while (ok && li < k) {
while (li < k && str.charAt(li) == '*') {
++li;
}
int ri = li;
while (ri < k && str.charAt(ri) != '*') {
++ri;
}
if (li < ri) {
String sub
= str.
substring(li, ri
); List<Integer> list = f.get(sub);
if (list.isEmpty()) {
ok = false;
break;
}
if (index < 0) {
index = ~index;
}
if (index >= list.size()) {
ok = false;
break;
}
i = list.get(index);
if (li == 0) {
ok &= i == l[j];
}
i += sub.length();
if (ri == k) {
ok &= i == r[j];
}
ok &= i <= r[j];
}
li = ri;
}
println(ok ? "Yes" : "No");
}
}
public static boolean nextPermutation(int[] permutation) {
int n = permutation.length, a = n - 2;
while (0 <= a && permutation[a] >= permutation[a + 1]) {
a--;
}
if (a == -1) {
return false;
}
int b = n - 1;
while (permutation[b] <= permutation[a]) {
b--;
}
swap(permutation, a, b);
for (int i = a + 1, j = n - 1; i < j; i++, j--) {
swap(permutation, i, j);
}
return true;
}
public static void swap(int[] array, int i, int j) {
if (i == j) {
return;
}
array[i] ^= array[j];
array[j] ^= array[i];
array[i] ^= array[j];
}
int[][] nextMatrix(int n, int m) {
int[][] matrix = new int[n][m];
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
matrix[i][j] = nextInt();
return matrix;
}
while (!tokenizer.hasMoreTokens())
return tokenizer.nextToken();
}
boolean hasNext() {
while (!tokenizer.hasMoreTokens()) {
if (line == null) {
return false;
}
}
return true;
}
int[] nextArray(int n) {
int[] array = new int[n];
for (int i = 0; i < n; i++) {
array[i] = nextInt();
}
return array;
}
int nextInt() {
}
long nextLong() {
return Long.
parseLong(next
()); }
double nextDouble() {
return Double.
parseDouble(next
()); }
try {
return reader.readLine();
return null;
}
}
super(outputStream);
}
Main Main
= new Main
(System.
out);
Main.run();
Main.close();
reader.close();
}
}
aW1wb3J0IGphdmEuaW8uKjsKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5tYXRoLkJpZ0ludGVnZXI7CmltcG9ydCBqYXZhLnV0aWwuTWFwLkVudHJ5OwoKaW1wb3J0IHN0YXRpYyBqYXZhLmxhbmcuTWF0aC4qOwoKcHVibGljIGNsYXNzIE1haW4gZXh0ZW5kcyBQcmludFdyaXRlciB7CgogICAgdm9pZCBydW4oKSB7CgogICAgICAgIFN0cmluZyBzID0gbmV4dCgpOwogICAgICAgIE1hcDxTdHJpbmcsIExpc3Q8SW50ZWdlcj4+IGYgPSBuZXcgSGFzaE1hcDxTdHJpbmcsIExpc3Q8SW50ZWdlcj4+KDEgPDwgMjEpOwogICAgICAgIGludCBuID0gcy5sZW5ndGgoKTsKCiAgICAgICAgaW50IG0gPSBuZXh0SW50KCk7CgogICAgICAgIGludFtdIGwgPSBuZXcgaW50W21dOwogICAgICAgIGludFtdIHIgPSBuZXcgaW50W21dOwoKICAgICAgICBTdHJpbmdbXSBwID0gbmV3IFN0cmluZ1ttXTsKCiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBtOyBqKyspIHsKICAgICAgICAgICAgbFtqXSA9IG5leHRJbnQoKSAtIDE7CiAgICAgICAgICAgIHJbal0gPSBuZXh0SW50KCkgLSAwOwoKICAgICAgICAgICAgU3RyaW5nIHN0ciA9IHBbal0gPSBuZXh0KCk7CiAgICAgICAgICAgIGludCBrID0gc3RyLmxlbmd0aCgpOwoKICAgICAgICAgICAgaW50IGxpID0gMDsKCiAgICAgICAgICAgIHdoaWxlIChsaSA8IGspIHsKICAgICAgICAgICAgICAgIHdoaWxlIChsaSA8IGsgJiYgc3RyLmNoYXJBdChsaSkgPT0gJyonKSB7CiAgICAgICAgICAgICAgICAgICAgKytsaTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGludCByaSA9IGxpOwoKICAgICAgICAgICAgICAgIHdoaWxlIChyaSA8IGsgJiYgc3RyLmNoYXJBdChyaSkgIT0gJyonKSB7CiAgICAgICAgICAgICAgICAgICAgKytyaTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICBpZiAobGkgPCByaSkgewogICAgICAgICAgICAgICAgICAgIFN0cmluZyBzdWIgPSBzdHIuc3Vic3RyaW5nKGxpLCByaSk7CiAgICAgICAgICAgICAgICAgICAgZi5wdXQoc3ViLCBuZXcgQXJyYXlMaXN0PEludGVnZXI+KCkpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgbGkgPSByaTsKICAgICAgICAgICAgfQogICAgICAgIH0KCiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICAgICAgZm9yIChpbnQgbGVuID0gbWluKDEwLCBuIC0gaSk7IGxlbiA+PSAxOyBsZW4tLSkgewogICAgICAgICAgICAgICAgTGlzdDxJbnRlZ2VyPiBsaXN0ID0gZi5nZXQocy5zdWJzdHJpbmcoaSwgaSArIGxlbikpOwogICAgICAgICAgICAgICAgaWYgKGxpc3QgIT0gbnVsbCkgewogICAgICAgICAgICAgICAgICAgIGxpc3QuYWRkKGkpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IG07IGorKykgewogICAgICAgICAgICBib29sZWFuIG9rID0gdHJ1ZTsKICAgICAgICAgICAgaW50IGkgPSBsW2pdOwoKICAgICAgICAgICAgU3RyaW5nIHN0ciA9IHBbal07CiAgICAgICAgICAgIGludCBrID0gc3RyLmxlbmd0aCgpOwoKICAgICAgICAgICAgaW50IGxpID0gMDsKCiAgICAgICAgICAgIHdoaWxlIChvayAmJiBsaSA8IGspIHsKICAgICAgICAgICAgICAgIHdoaWxlIChsaSA8IGsgJiYgc3RyLmNoYXJBdChsaSkgPT0gJyonKSB7CiAgICAgICAgICAgICAgICAgICAgKytsaTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGludCByaSA9IGxpOwoKICAgICAgICAgICAgICAgIHdoaWxlIChyaSA8IGsgJiYgc3RyLmNoYXJBdChyaSkgIT0gJyonKSB7CiAgICAgICAgICAgICAgICAgICAgKytyaTsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICBpZiAobGkgPCByaSkgewogICAgICAgICAgICAgICAgICAgIFN0cmluZyBzdWIgPSBzdHIuc3Vic3RyaW5nKGxpLCByaSk7CiAgICAgICAgICAgICAgICAgICAgTGlzdDxJbnRlZ2VyPiBsaXN0ID0gZi5nZXQoc3ViKTsKCiAgICAgICAgICAgICAgICAgICAgaWYgKGxpc3QuaXNFbXB0eSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG9rID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgaW50IGluZGV4ID0gQ29sbGVjdGlvbnMuYmluYXJ5U2VhcmNoKGxpc3QsIGkpOwoKICAgICAgICAgICAgICAgICAgICBpZiAoaW5kZXggPCAwKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIGluZGV4ID0gfmluZGV4OwogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgaWYgKGluZGV4ID49IGxpc3Quc2l6ZSgpKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG9rID0gZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgaSA9IGxpc3QuZ2V0KGluZGV4KTsKCiAgICAgICAgICAgICAgICAgICAgaWYgKGxpID09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgb2sgJj0gaSA9PSBsW2pdOwogICAgICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICAgICAgaSArPSBzdWIubGVuZ3RoKCk7CgogICAgICAgICAgICAgICAgICAgIGlmIChyaSA9PSBrKSB7CiAgICAgICAgICAgICAgICAgICAgICAgIG9rICY9IGkgPT0gcltqXTsKICAgICAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgICAgICAgIG9rICY9IGkgPD0gcltqXTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGxpID0gcmk7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIHByaW50bG4ob2sgPyAiWWVzIiA6ICJObyIpOwogICAgICAgIH0KCiAgICB9CgogICAgcHVibGljIHN0YXRpYyBib29sZWFuIG5leHRQZXJtdXRhdGlvbihpbnRbXSBwZXJtdXRhdGlvbikgewogICAgICAgIGludCBuID0gcGVybXV0YXRpb24ubGVuZ3RoLCBhID0gbiAtIDI7CiAgICAgICAgd2hpbGUgKDAgPD0gYSAmJiBwZXJtdXRhdGlvblthXSA+PSBwZXJtdXRhdGlvblthICsgMV0pIHsKICAgICAgICAgICAgYS0tOwogICAgICAgIH0KICAgICAgICBpZiAoYSA9PSAtMSkgewogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQoKICAgICAgICBpbnQgYiA9IG4gLSAxOwogICAgICAgIHdoaWxlIChwZXJtdXRhdGlvbltiXSA8PSBwZXJtdXRhdGlvblthXSkgewogICAgICAgICAgICBiLS07CiAgICAgICAgfQoKICAgICAgICBzd2FwKHBlcm11dGF0aW9uLCBhLCBiKTsKICAgICAgICBmb3IgKGludCBpID0gYSArIDEsIGogPSBuIC0gMTsgaSA8IGo7IGkrKywgai0tKSB7CiAgICAgICAgICAgIHN3YXAocGVybXV0YXRpb24sIGksIGopOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIHZvaWQgc3dhcChpbnRbXSBhcnJheSwgaW50IGksIGludCBqKSB7CiAgICAgICAgaWYgKGkgPT0gaikgewogICAgICAgICAgICByZXR1cm47CiAgICAgICAgfQogICAgICAgIGFycmF5W2ldIF49IGFycmF5W2pdOwogICAgICAgIGFycmF5W2pdIF49IGFycmF5W2ldOwogICAgICAgIGFycmF5W2ldIF49IGFycmF5W2pdOwogICAgfQoKICAgIGludFtdW10gbmV4dE1hdHJpeChpbnQgbiwgaW50IG0pIHsKICAgICAgICBpbnRbXVtdIG1hdHJpeCA9IG5ldyBpbnRbbl1bbV07CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspCiAgICAgICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgbTsgaisrKQogICAgICAgICAgICAgICAgbWF0cml4W2ldW2pdID0gbmV4dEludCgpOwogICAgICAgIHJldHVybiBtYXRyaXg7CiAgICB9CgogICAgU3RyaW5nIG5leHQoKSB7CiAgICAgICAgd2hpbGUgKCF0b2tlbml6ZXIuaGFzTW9yZVRva2VucygpKQogICAgICAgICAgICB0b2tlbml6ZXIgPSBuZXcgU3RyaW5nVG9rZW5pemVyKG5leHRMaW5lKCkpOwogICAgICAgIHJldHVybiB0b2tlbml6ZXIubmV4dFRva2VuKCk7CiAgICB9CgogICAgYm9vbGVhbiBoYXNOZXh0KCkgewogICAgICAgIHdoaWxlICghdG9rZW5pemVyLmhhc01vcmVUb2tlbnMoKSkgewogICAgICAgICAgICBTdHJpbmcgbGluZSA9IG5leHRMaW5lKCk7CiAgICAgICAgICAgIGlmIChsaW5lID09IG51bGwpIHsKICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTsKICAgICAgICAgICAgfQogICAgICAgICAgICB0b2tlbml6ZXIgPSBuZXcgU3RyaW5nVG9rZW5pemVyKGxpbmUpOwogICAgICAgIH0KICAgICAgICByZXR1cm4gdHJ1ZTsKICAgIH0KCiAgICBpbnRbXSBuZXh0QXJyYXkoaW50IG4pIHsKICAgICAgICBpbnRbXSBhcnJheSA9IG5ldyBpbnRbbl07CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICAgICAgYXJyYXlbaV0gPSBuZXh0SW50KCk7CiAgICAgICAgfQogICAgICAgIHJldHVybiBhcnJheTsKICAgIH0KCiAgICBpbnQgbmV4dEludCgpIHsKICAgICAgICByZXR1cm4gSW50ZWdlci5wYXJzZUludChuZXh0KCkpOwogICAgfQoKICAgIGxvbmcgbmV4dExvbmcoKSB7CiAgICAgICAgcmV0dXJuIExvbmcucGFyc2VMb25nKG5leHQoKSk7CiAgICB9CgogICAgZG91YmxlIG5leHREb3VibGUoKSB7CiAgICAgICAgcmV0dXJuIERvdWJsZS5wYXJzZURvdWJsZShuZXh0KCkpOwogICAgfQoKICAgIFN0cmluZyBuZXh0TGluZSgpIHsKICAgICAgICB0cnkgewogICAgICAgICAgICByZXR1cm4gcmVhZGVyLnJlYWRMaW5lKCk7CiAgICAgICAgfSBjYXRjaCAoSU9FeGNlcHRpb24gZXJyKSB7CiAgICAgICAgICAgIHJldHVybiBudWxsOwogICAgICAgIH0KICAgIH0KCiAgICBwdWJsaWMgTWFpbihPdXRwdXRTdHJlYW0gb3V0cHV0U3RyZWFtKSB7CiAgICAgICAgc3VwZXIob3V0cHV0U3RyZWFtKTsKICAgIH0KCiAgICBzdGF0aWMgQnVmZmVyZWRSZWFkZXIgcmVhZGVyOwogICAgc3RhdGljIFN0cmluZ1Rva2VuaXplciB0b2tlbml6ZXIgPSBuZXcgU3RyaW5nVG9rZW5pemVyKCIiKTsKICAgIHN0YXRpYyBSYW5kb20gcm5kID0gbmV3IFJhbmRvbSgpOwoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHRocm93cyBJT0V4Y2VwdGlvbiB7CiAgICAgICAgcmVhZGVyID0gbmV3IEJ1ZmZlcmVkUmVhZGVyKG5ldyBJbnB1dFN0cmVhbVJlYWRlcihTeXN0ZW0uaW4pKTsKICAgICAgICBNYWluIE1haW4gPSBuZXcgTWFpbihTeXN0ZW0ub3V0KTsKCiAgICAgICAgTWFpbi5ydW4oKTsKICAgICAgICBNYWluLmNsb3NlKCk7CiAgICAgICAgcmVhZGVyLmNsb3NlKCk7CiAgICB9Cn0=