Explorer Reisen, after entering a mysterious castle, found an ancient book. Reisen noticed that the book consists of n pages, with each page containing exactly one sentence. The sentence on the i-th page is represented by a string Si, which consists only of lowercase Latin letters. Moreover, she cannot understand the meaning of the sentences but decides to try deciphering them. Reisen carries out q studies. The i-th study involves the numbers li,ri,ki, indicating that she will analyze the sentences on pages from li to ri, using the sentence on page ki as the reference to measure the degree of similarity among them. The similarity of this dataset is defined as the total length of the longest common prefixes (LCP) between each analyzed sentence and the reference sentence. For each study, help Reisen calculate the similarity of the dataset to decode the book.
### Input
- The first line contains two positive integers n,q.
- The next n lines, the i-th line, contain the string Si.
- The next q lines, the i-th line, contain three positive integers li,ri,ki.
### Output
- Print q lines, each containing the result of a study.
### Constraints
- 1≤n,q≤5⋅104.
- The total length of all strings does not exceed 5â‹…104.
- For all queries, 1≤li,ri,ki≤n with 1≤i≤q.
### Example
Input
65acdeab≥xyzacxxyuvta136164353124361
Output
514567