Help needed in Sliding Median Solution

    void er(long val){ // erase from sets
	if(up.find(val) != up.end()) up.erase(up.find(val));
	else low.erase(low.find(val));
	if(low.empty()){
		low.insert(*up.begin());
		up.erase(up.find(*up.begin()));
	}
}

It’s a part of solution for Sliding Median (CSES) problem. I have a doubt, why are we deleting from the up multiset first and why not from the low multiset first?

other way around probably works too