There are N gangs in a city. Each gang occupies several rectangular territories, and any overlap between territories of different gangs causes a dispute.
N satisfies 2≤N≤300, and gang i owns Mi territories. Every territory is a rectangle whose sides are parallel to the x and y axes, given by its lower-left corner (x1,y1) and its upper-right corner (x2,y2). The coordinates are integers satisfying 0≤x1<x2<1000000 and 0≤y1<y2<1000000.
A dispute region is a part where two territories of different gangs overlap with positive area. Territories that meet only along an edge or at a point are not a dispute region.
Each gang must give up exactly one of its Mi territories. Decide whether all dispute regions can be eliminated this way.