Jason discovered that alarms can sing one of the n+1 tunes, which have the accompanying construction: let si (0≤i≤n) be the I-th tune and t be a line of length n, then, at that point, for each i

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Computer science.

Jason discovered that alarms can sing one of the n+1 tunes, which have the accompanying construction: let si (0≤i≤n) be the I-th tune and t be a line of length n, then, at that point, for each i<n: si+1=sitisi. All in all i+1-st tune is the connection of I-th tune, I-th letter (0-recorded) of t and the I-th melody. 

 

Luckily, he likewise knows s0 and t. Jason considers how frequently a mariner's name is referenced in a specific tune. Answer q inquiries: given the mariner's name (w) and the file of a tune (I) output the number of events of w in si as a substring. As this number can be very huge, output its remaining portion modulo 109+7. 

 

Input 

 

In the main line of input there are two integers n, q ( 1≤n,q≤105) implying that there are n+1 tunes and q questions. In the following two lines strings s0 and t follow (1≤|s0|≤100,|t|=n). 

 

Next q lines depict the questions; every one contains an integer k (0≤k≤n), the record of the melody sung by the alarms, and a non-void string w, which is the name of a mariner. All strings in this issue comprise just of lowercase English letters, and the amount of lengths of mariners' names doesn't surpass 106. 

 

Output 

 

Output q lines, I-th of them ought to contain the rest of 109+7 of the number of events of w in sk.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY