Problemas
Bessie has been given
Define the union of a set of segments to be the set of all
Bessie wants to compute the sum of the complexities over all
Normally, your job is to help Bessie. But this time, you are Bessie, and there's no one to help you. Help yourself!
SCORING:
Test cases 2-3 satisfy
N\le 16 .Test cases 4-7 satisfy
N\le 1,000 .Test cases 8-12 satisfy no additional constraints.
Entrada
The first line contains
Each of the next
Salida
Output the answer, modulo
Ejemplo
3
1 6
2 3
4 5
8
The complexity of each nonempty subset is written below.
The answer is