Brackets all over (Dynamic Programming)

Only two test cases are getting passed.
I used dyanmic programming and took modulus too at the end.
Please see to the solution.
Answer link : https://ide.codingblocks.com/s/56150
Question link : https://hack.codingblocks.com/contests/c/640/1080
Please check the answer