Under construction

Still being built. Things may change

Almost Periodic String

Time limit2sMemory limit512 MB

Summary
For each query, decide whether the substring S[l..r] can be turned into a string of period t by changing at most one character.
Level

Hard8 of 10

Topics
String, Hash map, Prefix sum, Implementation
Solved
No attempts yet

Problem

You are given a string SS. Answer QQ queries about this string SS. In the ii-th query, you may change up to one character in S[li,ri]S[l_i, r_i]. Determine whether S[li,ri]S[l_i, r_i] can be made into a string of period tit_i. Here S[l,r]S[l, r] denotes the substring of SS from the ll-th character to the rr-th character.

A string WW is a string of period tt if Wi=Wi+tW_i = W_{i+t} for every i=1,2,...,∣W∣−ti = 1, 2, ..., |W|-t.

Input

The input is given from standard input in the following format.

SS

QQ

l1l_1 r1r_1 t1t_1

......

lQl_Q rQr_Q tQt_Q

Output

Output QQ lines. The ii-th line must contain the answer to the ii-th query as Yes or No.

Constraints

  • 1≤∣S∣≤1051 \leq |S| \leq 10^5
  • 1≤Q≤1051 \leq Q \leq 10^5
  • 1≤li≤ri≤∣S∣1 \leq l_i \leq r_i \leq |S|
  • 1≤ti≤ri−li+11 \leq t_i \leq r_i-l_i+1
  • SS consists only of lowercase English letters

Examples2

  1. Example 1

    Input
    abcabcaxcabc
    4
    1 9 3
    8 12 3
    1 4 2
    2 3 2
    
    Expected output
    Yes
    Yes
    No
    Yes
    
  2. Example 2

    Input
    isuruu
    4
    3 6 1
    3 6 2
    3 6 3
    2 4 1
    
    Expected output
    Yes
    Yes
    Yes
    No