#include <bits/stdc++.h>
using namespace std;
class RandomGCD {
public :
long long Pow( long long a, long long e, long long mod) {
if ( e <= 0 ) return 1 ;
long long x = Pow( a,e/ 2 ,mod) ;
x = ( x* x) % mod;
if ( e% 2 ! = 0 ) x = ( x* a) % mod;
return x; }
long long mod = 1000000007 ;
int High,Low,M;
long long count( vector< long long > & A, int D) {
if ( High/ D == Low/ D) return 0 ;
if ( A[ D] >= 0 ) return A[ D] ;
A[ D] = Pow( High/ D- Low/ D,M,mod) - ( High/ D- Low/ D) ;
for ( int i = 2 ; i <= ( High- Low) / D; i++ )
if ( High/ ( D* i) - Low/ ( D* i) > 1 ) A[ D] = ( A[ D] + mod- count( A,D* i) ) % mod;
return A[ D] ; }
int countTuples( int N, int K, int low, int high) {
Low = ( low- 1 ) / K;
High = high/ K;
M = N;
vector< long long > A( High- Low+ 1 ,- 1 ) ;
return count( A,1 ) + ( ( Low < 1 && High >= 1 ) ? 1 : 0 ) ; }
} ;
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpjbGFzcyBSYW5kb21HQ0QgewoJcHVibGljOgoJCWxvbmcgbG9uZyBQb3cobG9uZyBsb25nIGEsIGxvbmcgbG9uZyBlLCBsb25nIGxvbmcgbW9kKSB7CgkJCWlmKGUgPD0gMCkgcmV0dXJuIDE7CgkJCWxvbmcgbG9uZyB4ID1Qb3coYSxlLzIsbW9kKTsKCQkJeCA9KHgqeCklbW9kOwoJCQlpZihlJTIgIT0gMCkgeCA9KHgqYSklbW9kOwoJCQlyZXR1cm4geDt9IAoJCgkJbG9uZyBsb25nIG1vZCA9MTAwMDAwMDAwNzsKCQlpbnQgSGlnaCxMb3csTTsKCQoJCWxvbmcgbG9uZyBjb3VudCh2ZWN0b3I8bG9uZyBsb25nPiAmQSwgaW50IEQpIHsKCQkJaWYoSGlnaC9EID09IExvdy9EKSByZXR1cm4gMDsKCQkJaWYoQVtEXSA+PSAwKSByZXR1cm4gQV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