PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000026. Hoa đỏ và hoa trắng (Flowers)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Hoa đỏ và hoa trắng (Flowers)

Flowers

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

A gardener arranges red and white flowers in a row. A red flower can be placed individually, while white flowers are placed in groups of exactly kk consecutive white flowers. Each such group acts as one unit during construction.

Count all arrangements whose total number of flowers is between aa and bb, inclusive. Arrangements are distinct when their color sequences differ.

Print the count modulo 109+710^9+7.

Input

One line contains three integers kk, aa, and bb: the white-block size and the inclusive length bounds.

Output

Print the number of valid flower arrangements of lengths aa through bb, modulo 109+710^9+7.

Subtasks

  • Subtask 1 (20 points): 1≤k≤301\le k\le 30; 1≤a≤1051\le a\le 10^5; 1≤b≤1051\le b\le 10^5; a≤ba\le b.
  • Subtask 2 (30 points): 1≤k≤10001\le k\le 1000; 1≤a≤1051\le a\le 10^5; 1≤b≤1051\le b\le 10^5; a≤ba\le b.
  • Subtask 3 (50 points): 1≤k≤1051\le k\le 10^5; 1≤a≤1051\le a\le 10^5; 1≤b≤1051\le b\le 10^5; a≤ba\le b.

Examples

Input

2 1 3

Output

6

Explanation

For k=2k=2, a red flower is one unit and white flowers occur in blocks of two. Length 11 has R; length 22 has RR, WW; length 33 has RRR, RWW, WWR. The total is 1+2+3=61+2+3=6.