All Tracks Math Problem

Girlfriend's demands
Tag(s):

Ad-Hoc, Algorithms, Easy, Mathamatics

Problem
Editorial
Analytics

Like most of the girlfriends, Ashima when asks for something, won’t stop until she gets that.
The way she gets that is by keep on repeating the same things again and again. Like if she wants chocolate, she will just keep on repeating “chocolate” again and again.

I have decided to answer to her demands as “Yes” or “No” by not delaying a lot. Otherwise, there would be a lot of repercussions. So, randomly at certain intervals, I just answer with “Yes” or “No” using the following rule, I will just select two integers a and b, if the element at the position a is same as the element as position b in the non-ending chant by Ashima, I will speak “Yes”, otherwise say “No”.

Your job is to find my side of the conversation given the name of the demand Ashima has and the random integers I picked.

Input:
First line of the input contains a string S, the name of the item she is demanding.
Next line contains an integer Q, the number of pairs of integers that used to say “Yes” or “No” to her. These pairs are given in order.
Next Q line, each contains 2 integers, a and b. (1-based indexing)

Output:
For each query, print “Yes” or “No” as described above.

Constraints:
1 ≤ |S| ≤ 105
1 ≤ Q ≤ 105
1 ≤ a, b ≤ 1018

SAMPLE INPUT
vgxgp
3
2 4
2 5
7 14
SAMPLE OUTPUT
Yes
No
Yes
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

HackerEarth

Challenge Name

October Easy Challenge

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?