Need help in a SPOJ problem - CPATTERN

Hello everybody. I have been stuck up in this problem CPATTERN from SPOJ for quite a few days. Could anyone please help me out by suggesting a suitable approach for it