Limits 2s, 512 MB

Gakra Miah is a Wollywood movie lover. He watches movies almost everyday. He has watched so many movies already that now he needs some variations in watching movies to increase his enjoyment.

Today, he has made M plans to watch some types of movies sequentially within N days. But the problem is, he used to go to the movie theatre to watch movies, and in movie theatres only one type of movies can be watched on usual days, and any type of movies can be watched on special days.

Now given what types of movies can be watched in the next N days in the movie theatres, your task is to determine if Gakra Miah's plans will be successful or not.

Input

The input will start with an integer N (1 ≤ N ≤ 105), the next line will be followed by a character of string S of length N, containing English lowercase alphabets and character '#'. Each lowercase letter is denoting that the day is normal, and on this day only this type of movies can be watched. The character '#' is denoting that the day is special, and any type of movies can be watched on this
day.

The next line will contain another integer M (1 ≤ M ≤ 105), the number of plans and the next M lines will be followed by strings of characters P1, P2,... ,PM (1 ≤ Length of each Pi ≤ N, 1 ≤ Length of entire string ≤ 105) containing only lowercase alphabets.

Output

The output should contain M lines, one for each plan. Print "Plan will be successful" without quotes for each Pi if he will be able to watch all the movies of Pi plan sequentially, otherwise print "Plan should be changed" without quotes.

Sample

InputOutput
17
ambbc#dzaagh##nff
10
ammajan
bodnahate
vaatde
baba
aaa
aaaa
cbaas
ssss
dddd
y
Plan will be successful
Plan should be changed
Plan should be changed
Plan will be successful
Plan will be successful
Plan will be successful
Plan will be successful
Plan should be changed
Plan will be successful
Plan will be successful

Submit

Login to submit.

Contributors

Statistics

87% Solution Ratio
FrdhsnEarliest, Apr '19
nusuBotFastest, 0.0s
Jaber_SiamLightest, 2.8 MB
Moin84Shortest, 553B
Toph uses cookies. By continuing you agree to our Cookie Policy.