#C460. Discounted Items Count

    ID: 48156 Type: Default 1000ms 256MiB

Discounted Items Count

Discounted Items Count

You are given n items. Each item is described by two integers: its price and its rating. Additionally, there are m discount criteria, where each criterion is given as three integers: minPrice, maxPrice, and minRating.

An item qualifies for a discount if its price p and rating r satisfy the inequality \[ minPrice \leq p \leq maxPrice \quad \text{and} \quad r \geq minRating. \]

Your task is to count the total number of unique items that satisfy at least one discount criterion.

If an item qualifies under multiple criteria, it should be counted only once. If there are no discount criteria, the answer is 0.

inputFormat

The first line of input contains two integers n and m representing the number of items and the number of discount criteria respectively.

The next n lines each contain two integers price and rating for each item.

If m > 0, the next m lines each contain three integers minPrice, maxPrice, and minRating that describe a discount criterion.

Note: When m = 0, there are no additional lines after the items.

outputFormat

Output a single integer representing the total number of unique items that qualify for at least one discount criterion.

## sample
5 2
1000 4
1500 3
2000 5
3000 2
2500 5
1000 2000 4
2000 3000 3
3