9124: Non-Puzzle: Segment Pair

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

There are nnn pairs of segments in the X-axis. The iii-th of them is [li,ri][l_{i},r_{i}][li,ri] and [li′,ri′][l'_{i},r'_{i}][li,ri].

You should choose exactly one segment from each pair (that is, choose either [li,ri][l_{i},r_{i}][li,ri] or [li′,ri′][l'_{i},r'_{i}][li,ri] for each iii), satisfying that there exists at least one point xxx, which is included by all the chosen segments.

You need to determine the number of different ways of choosing the segments (over 2n2^n2n possible ways) that satisfies the condition, output it modulo 109+710^9+7109+7.

Two ways are considered different if and only if there exists iii, such that [li,ri][l_{i},r_{i}][li,ri] is chosen in one way, and [li′,ri′][l'_{i},r'_{i}][li,ri] is chosen in another. Note that even if [li,ri]=[li′,ri′][l_{i},r_{i}] = [l'_{i},r'_{i}][li,ri]=[li,ri], the two ways are considered different.

输入格式

The first line contains one integer nnn(1≤n≤5⋅1051\le n \le 5\cdot 10^51n5105).
The following nnn lines, each line contains four integers li,ri,li′,ri′l_{i},r_{i},l'_{i},r'_{i}li,ri,li,ri(1≤li≤ri≤5⋅1051\le l_{i} \le r_{i} \le 5\cdot 10^51liri5105 , 1≤li′≤ri′≤5⋅1051\le l'_{i} \le r'_{i} \le 5\cdot 10^51liri5105).

输出格式

Output a single integer, representing the number of different ways of choosing the segments, modulo 109+710^9+7109+7.

输入样例 复制

3
1 4 6 7
2 5 3 5
1 3 5 7

输出样例 复制

2

分类标签