Workbook Algorithms

Count the number of undirected graphs X on N vertices whose number of permutations P satisfying G(P)=X lies between l and r, modulo 1e9+7.

Hard9CombinatoricsGraphMathDynamic programmingNo attempts yetTime limit1sMemory limit512 MB

Problem

A company known for its printed workbooks decided to publish a new coding workbook for elementary school students. Parents who had no idea how to teach coding at home welcomed the news.

Junseo was picked for the writing team. He did not think much of the trend at first, but an offer of 50,000 won per problem changed his mind.

Junseo took the graph algorithms unit and came up with the following problem.

For a permutation PP of 11 through NN, define an undirected graph G(P)G(P) on NN vertices as follows. For each ii, draw one edge joining vertex ii and vertex PiP_i. Self loops and repeated edges are allowed. Given an undirected graph XX on NN vertices, find every permutation PP with G(P)=XG(P) = X.

Junseo wants the number of permutations that answer the problem to be neither too small nor too large, so he uses a graph XX only when the number of permutations PP with G(P)=XG(P) = X is at least ll and at most rr. He wants the money, so he uses every graph XX that meets the bound.

The vertices are numbered 11 through NN, and two graphs count as different when their edges differ. How many problems can Junseo publish?

Input

The first line contains three integers NN, ll, rr (1N2000001 \le N \le 200\,000, 1lr1091 \le l \le r \le 10^9).

Output

Print on one line the number of distinct problems Junseo can publish, that is the number of graphs XX meeting the bound, modulo 109+710^9+7.