Seeding The Pattern (WA)

prob : https://www.codechef.com/problems/SEEDS

soln : https://www.codechef.com/viewsolution/19076044

can someone give me some counter case where my code fails? Or can suggest a better approach.