Time Limit: 2s
Memory Limit: 256MB
Don't worry about looking handsome, Or being strong and brave. Just as you love me unconditionally, I love you just the same.Ok! Ok! There are so many beautiful and romantic poems and stories about love, but life is life, C'est La Vie. Especially in China, to marry for money or for love is a question to every after 80s girl (or may be after 90s girls soon). As an old Chinese proverb says: One cannot have fish and bear's paw at the same time. However, as we know, people are not so easy to satisfy. We want love and bread both. Now, we have the problem. There N boys and N girls, The girls has their own standard of boy friend selection, (Li, Mi), Li is the least love rate the ith girl want, Mi is the least money the ith girl want. Every boy has a attribute, (Lj, Mj), is the love rate the jth boy can give, is the money the jth boy have. If one pair of girl and boy, whose Li ≤Lj and Mi≤Mj, we can mate the ith girl with jth boy. Every girl (boy) can match with at most one boy (girl). And we want to know how many pairs of friends can be mating at most.
2 1 1 2 2 1 2 2 2 3 2 2 4 3 3 4 0 0 3 3 4 4