F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

RootedTree

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 367    Accepted Submission(s): 180


Problem Description
There are n nodes, you should write a program to calculate how many way to form a rooted tree. This tree must satisfy two following conditions:
1: This tree should contain all the n nodes.
2: The size of subtree whose root is node i, should be from $l_i$ to $r_i$.
Give you $l_i$ and $r_i$, you should output the answer.
 

Input
There are several cases, First is the number of cases T. (There are most ten cases).
For each case, in the first line is a integer n ($1 \leq n \leq 14$). In following n line, each line has two integers $l_i, r_i (1 \leq l_i \leq r_i \leq n$).
 

Output
For each case output the answer modulo $10^9 + 7$.
 

Sample Input
2 3 1 3 1 3 1 3 3 1 1 2 2 3 3
 

Sample Output
9 1
 

Hint
The first sample: 1 -> 2 -> 3, 1 -> 3 -> 2, 2 <- 1 -> 3, 2 -> 1 -> 3, 2 -> 3 -> 1, 1 <- 2 -> 3,
3 -> 1 -> 2, 3 -> 2 -> 1, 2 <- 3 -> 1(1 -> 2 represent 2¡¯father is 1), these trees satisfy all the conditions.
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 15:16:32, Gzip enabled