Birthday

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Bogdan received a birthday gift: a board game called "Subsegment sum". This entertaining game consists of nn two-sided cards. An integer is written on each side of each card. The cards are arranged in a row on the table and are indexed from 1 to nn, left to right. After the arrangement the cards can be turned over, but not swapped.

The player receives tasks, each task is a pair of numbers ll and rr. After receiving a task, the player places each card with index from ll to rr, inclusive, some side up. The target is to make the sum of the numbers on the upper sides of cards with index from ll to rr, inclusive, as large as possible.

Bogdan became bored with achieving maximum sums, so he decided to make the game harder. Now Bogdan selects a number kk, and when he solves the task for cards from ll to rr, inclusive, he places these cards with some side up in such a way that the sum of the numbers on their upper sides was as large as possible, but not divisible by kk. If Bogdan is able to solve this task, he denotes the received maximum sum as f(l,r)f(l, r). If he is unable to select sides to make the sum on the upper sides indivisible by kk, he considers f(l,r)=0f(l,r)=0.

After some playing, Bogdan started thinking about the following problem. He wants to calculate the sum of f(l,r)f(l, r) for all possible pairs ll and rr, in other words, calculate _1lrnf(l,r)\sum\limits\_{1 \le l \le r \le n}f(l,r)

Help Bogdan find this sum. Since the answer can be very large, calculate it by modulo 109+710^9+ 7.

입력

The first line contains two integers nn and kk (1n51051 \le n \le 5 \cdot 10^5; 1k1091 \le k \le 10^9).

Each of the next nn lines contains a description of a card on the table: two integers a_ia\_i and b_ib\_i (1a_i,b_i1091 \le a\_i, b\_i \le 10^9) --- the numbers written on two sides of the card with index ii.

출력

Output one integer, the answer taken modulo 109+710^9+7.