Please Help flipmagic re on task 1 ac on task 2 and 3

Please help magic flips starters 10 this solution gives runtime error on task 1 but ac on task 2 and 3 tried 10 times with long long and making bounds big but failed.
My solution
Problem