Correct solution but not being accepted

I don’t understand where my code giving wrong answers. Most of the test cases were running except for first two. Please respond ASAP.

just the comparator had to be updateed

bool compare(const pair<int,int>&p1,const pair<int,int>&p2)
{

	if(p1.second == p2.second) return p1.first < p2.first;

	return p1.second < p2.second;

}