# Untitled

unknown
plain_text
9 days ago
1.9 kB
1
Indexable
Never
def count_sums(n):
sum_chet = []
sum_nechet = []
if len(n) > 0:
sum_chet.append(int(n[0]))
if len(n) > 1:
sum_nechet.append(int(n[1]))

for i in range(2, len(n)):
if i % 2 == 0:
sum_chet.append(sum_chet[-1] + int(n[i]))
else:
sum_nechet.append(sum_nechet[-1] + int(n[i]))
return sum_chet, sum_nechet

def main():
n = input()
q = int(input())
sum_chet, sum_nechet = count_sums(n)
for i in range(q):
l, r = map(int, input().split())
if l == r:
print("NO")
return
l -= 1
r -= 1
new_l_chet = l
if l % 2 != 0:
new_l_chet += 1
new_r_chet = r
if r % 2 != 0:
new_r_chet -= 1
chet_l = new_l_chet // 2
chet_r = new_r_chet // 2

new_l_nechet = l
if l % 2 == 0:
new_l_nechet += 1
new_r_nechet = r
if r % 2 == 0:
new_r_nechet -= 1
nechet_l = max(0, (new_l_nechet - 1) // 2)
nechet_r = max(0, (new_r_nechet - 1) // 2)

chet_l_value = 0
if chet_l - 1 >= 0:
chet_l_value = int(sum_chet[chet_l - 1])

nechet_l_value = 0
if nechet_l - 1 >= 0:
nechet_l_value = int(sum_nechet[nechet_l - 1])

# print(sum_chet, sum_nechet)
# print("chet_l, chet_r", chet_l, chet_r)
# print("nechet_l, nechet_r", nechet_l, nechet_r)

result_chet = sum_chet[chet_r] - chet_l_value
result_nechet = sum_nechet[nechet_r] - nechet_l_value

# print("result_chet = ", result_chet)
# print("result_nechet = ", result_nechet)

if (result_chet - result_nechet) % 11 == 0:
print("YES")
else:
print("NO")

if __name__ == '__main__':
main()

# 23111
# 5
# 1 3
# 3 5
# 4 5
# 3 4
# 1 5