Cuber QQ always envies those Kejin players, who pay a lot of RMB to get a higher level in the game. So he worked so hard that you are now the game designer of this game. He decided to annoy these Kejin players a little bit, and give them the lesson that RMB does not always work.
This game follows a traditional Kejin rule of "when you are level ii, you have to pay aiai RMB to get to level i+1i+1". Cuber QQ now changed it a little bit: "when you are level ii, you pay aiai RMB, are you get to level i+1i+1 with probability pipi; otherwise you will turn into level xixi (xi≤ixi≤i)".
Cuber QQ still needs to know how much money expected the Kejin players needs to ``ke'' so that they can upgrade from level ll to level rr, because you worry if this is too high, these players might just quit and never return again.
Input
The first line of the input is an integer tt, denoting the number of test cases.
For each test case, there is two space-separated integers nn (1≤n≤500 0001≤n≤500 000) and qq(1≤q≤500 0001≤q≤500 000) in the first line, meaning the total number of levels and the number of queries.
Then follows nn lines, each containing integers riri, sisi, xixi, aiai (1≤ri≤si≤1091≤ri≤si≤109, 1≤xi≤i1≤xi≤i, 0≤ai≤1090≤ai≤109), space separated. Note that pipi is given in the form of a fraction risirisi.
The next qq lines are qq queries. Each of these queries are two space-separated integers ll and rr (1≤l<r≤n+11≤l<r≤n+1).
The sum of nn and sum of qq from all tt test cases both does not exceed 106106.
Output
For each query, output answer in the fraction form modulo 109+7109+7, that is, if the answer is PQPQ, you should output P⋅Q−1P⋅Q−1 modulo 109+7109+7, where Q−1Q−1 denotes the multiplicative inverse of QQ modulo 109+7109+7.