Double Attendance

아직 제출이 없습니다시간 제한3초메모리 제한1024 MB

문제

Due to a rather ambitious school schedule, two of your classes are about to be held starting at exactly the same time, in two different classrooms! You can only be in one place at a time, so the best you can hope for is catching the important bits of both, even if that means sneaking back and forth between the two.

The two classrooms are numbered 11 and 22. In classroom ii, the teacher will show N_iN\_i different slides during the class, with the jthj^\text{th} slide shown throughout the exclusive time interval (A_i,j,B_i,j)( A\_{i,j}, B\_{i,j}) (0A_i,j<B_i,j)(0 \le A\_{i,j} < B\_{i,j}) where A_i,jA\_{i,j} and B_i,jB\_{i,j} are times elapsed since the start of class measured in seconds. In both classes, there does not exist a point in time at which multiple slides are simultaneously being shown. For example, a class may have slides spanning the pair of intervals (1,2)(1, 2) and (5,6)(5, 6), or the pair (10,20)(10, 20) and (20,30)(20, 30), but not the pair (10,20)(10, 20) and (19,30)(19, 30).

You begin the day in classroom 11 with both classes starting at time 00. Following that, at any point in time (not necessarily after an integral number of seconds), you may move from your current classroom to the other one in KK seconds. You consider yourself to have seen a slide if you spend a positive amount of time in its classroom strictly within the time interval during which it's being shown. When moving between the two classrooms, you're not considered to be inside either of them for KK seconds and are thus unable to see any slides.

For example, if classroom 11 has a slide being shown for the time interval (10,20)(10, 20), classroom 22 has a slide being shown for the time interval (15,25)(15, 25), and K=8K = 8, then you'll get to see both slides if you move from classroom 11 to classroom 22 at time 11.511.5 seconds (arriving at time 19.519.5 seconds). On the other hand, if you leave classroom 11 at time 1717 seconds (arriving at time 2525 seconds), then you'll enter classroom 22 just after its slide stops being shown and will therefore miss it.

What's the maximum number of distinct slides which you can see at least once?

입력

The first line contains three space-separated integers N_1N\_1, N_2N\_2, and KK.

The next N_1N\_1 lines each contain two space-separated integers A_1,iA\_{1,i} and B_1,iB\_{1,i} (1iN_1)(1 \le i \le N\_1).

The next N_2N\_2 lines each contain two space-separated integers, A_2,iA\_{2, i} and B_2,iB\_{2,i} (1iN_2)(1 \le i \le N\_2).

출력

Output one integer which is the maximum number of distinct slides which you can see.