Problem B. Blown by the wind

Author:М. Спорышев   Time limit:1 sec
Input file:Standard input   Memory limit:512 Mb
Output file:Standard output  

Statement

Young programmer Vasya wants to give Alice a birthday present. To do this, he found a beautiful one-dimensional lawn and in N integer coordinates xi he installed ai beautiful stones, to show Alice later.

In the morning, Vasya discovered that due to the strong wind blowing in one direction or another, some stones rolled away in different directions. Now in M integer coordinates yi there are bi stones.

However, the relative position of the stones could not change. Thus, if the first stone was at the coordinate x1, and the second stone was at the coordinate x2 > x1, then their coordinates y will satisfy inequality y2 ≥ y1. Stones that were at the same x coordinates can move to different y coordinates.

Vasya wants to understand how much the arrangement of the stones has changed, so he asks you to calculate exactly how many stones were left standing in their original positions.

Input format

The first line contains the integer N.

The next N lines contain two integers each, separated by a space — xi, ai, in ascending order of xi.

The next line contains the integer M.

Output format

Output the number of stones that remained in their original positions.

Constraints

1 ≤ N, M ≤ 105

 − 109 ≤ xi, yi ≤ 109

1 ≤ ai, bi ≤ 109

Sample tests

No. Standard input Standard output
1
3
1 1
2 1
3 1
1
3 3
1
2
2
1 5
2 1
4
1 2
2 1
3 1
4 2
2

0.071s 0.012s 13