#include <bits/stdc++.h>
#define endl '\n'
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define SZ(x) ((int)x.size())
#define ALL(V) V.begin(), V.end()
#define L_B lower_bound
#define U_B upper_bound
#define pb push_back
using namespace std;
template < class T, class T2> inline int chkmax( T & x, const T2 & y) { return x < y ? x = y, 1 : 0 ; }
template < class T, class T2> inline int chkmin( T & x, const T2 & y) { return x > y ? x = y, 1 : 0 ; }
const double PI = acos ( - 1 ) ;
const int MAXN = ( 1 << 21 ) ;
struct complex_base
{
double x, y;
complex_base( double _x = 0 , double _y = 0 ) { x = _x; y = _y; }
friend complex_base operator- ( const complex_base & a, const complex_base & b) { return complex_base( a.x - b.x , a.y - b.y ) ; }
friend complex_base operator+ ( const complex_base & a, const complex_base & b) { return complex_base( a.x + b.x , a.y + b.y ) ; }
friend complex_base operator* ( const complex_base & a, const complex_base & b) { return complex_base( a.x * b.x - a.y * b.y , a.y * b.x + b.y * a.x ) ; }
friend void operator/ = ( complex_base & a, const double & P) { a.x / = P; a.y / = P; }
} ;
int bit_rev[ MAXN] ;
int last_n_fft = - 1 , ilast_n_fft = - 1 ;
complex_base root[ MAXN] , iroot[ MAXN] ;
void fft( complex_base * a, int lg)
{
int n = ( 1 << lg) ;
if ( last_n_fft ! = n)
{
double ang = 2 * PI / n;
for ( int i = 0 ; i < ( n >> 1 ) ; i++ )
root[ i] = complex_base( cos ( ang * i) , sin ( ang * i) ) ;
last_n_fft = n;
}
for ( int i = 1 ; i < n; i++ )
{
bit_rev[ i] = ( bit_rev[ i >> 1 ] >> 1 ) | ( ( i & 1 ) << ( lg - 1 ) ) ;
if ( bit_rev[ i] < i) swap( a[ i] , a[ bit_rev[ i] ] ) ;
}
for ( int len = 2 ; len <= n; len <<= 1 )
{
int step = ( n / len) ;
for ( int j = 0 ; j < ( len >> 1 ) ; j++ )
for ( int i = 0 ; i < n; i + = len)
{
complex_base u = a[ i + j] , v = root[ step * j] * a[ i + j + ( len >> 1 ) ] ;
a[ i + j] = u + v;
a[ i + j + ( len >> 1 ) ] = u - v;
}
}
}
void inv_fft( complex_base * a, int lg)
{
int n = ( 1 << lg) ;
if ( ilast_n_fft ! = n)
{
double ang = - 2 * PI / n;
for ( int i = 0 ; i < ( n >> 1 ) ; i++ )
iroot[ i] = complex_base( cos ( ang * i) , sin ( ang * i) ) ;
ilast_n_fft = n;
}
for ( int i = 1 ; i < n; i++ )
{
bit_rev[ i] = ( bit_rev[ i >> 1 ] >> 1 ) | ( ( i & 1 ) << ( lg - 1 ) ) ;
if ( bit_rev[ i] < i) swap( a[ i] , a[ bit_rev[ i] ] ) ;
}
for ( int len = 2 ; len <= n; len <<= 1 )
{
int step = ( n / len) ;
for ( int j = 0 ; j < ( len >> 1 ) ; j++ )
for ( int i = 0 ; i < n; i + = len)
{
complex_base u = a[ i + j] , v = iroot[ step * j] * a[ i + j + ( len >> 1 ) ] ;
a[ i + j] = u + v;
a[ i + j + ( len >> 1 ) ] = u - v;
}
}
for ( int i = 0 ; i < n; i++ )
a[ i] / = n;
}
complex_base A[ MAXN] , B[ MAXN] ;
vector< int64_t > mult( vector< int64_t > a, vector< int64_t > b)
{
if ( a.size ( ) * b.size ( ) <= 256 )
{
vector< int64_t > ans( a.size ( ) + b.size ( ) , 0 ) ;
for ( int i = 0 ; i < ( int ) a.size ( ) ; i++ )
for ( int j = 0 ; j < ( int ) b.size ( ) ; j++ )
ans[ i + j] + = a[ i] * b[ j] ;
return ans;
}
int lg = 0 ; while ( ( 1 << lg) < ( int ) ( a.size ( ) + b.size ( ) ) ) ++ lg;
for ( int i = 0 ; i < ( 1 << lg) ; i++ ) A[ i] = B[ i] = complex_base( 0 , 0 ) ;
for ( int i = 0 ; i < ( int ) a.size ( ) ; i++ ) A[ i] = complex_base( a[ i] , 0 ) ;
for ( int i = 0 ; i < ( int ) b.size ( ) ; i++ ) B[ i] = complex_base( b[ i] , 0 ) ;
fft( A, lg) ; fft( B, lg) ;
for ( int i = 0 ; i < ( 1 << lg) ; i++ )
A[ i] = A[ i] * B[ i] ;
inv_fft( A, lg) ;
vector< int64_t > ans( a.size ( ) + b.size ( ) , 0 ) ;
for ( int i = 0 ; i < ( int ) ans.size ( ) ; i++ )
ans[ i] = ( int64_t ) ( A[ i] .x + 0.5 ) ;
return ans;
}
int n, L, R;
vector< int > adj[ MAXN] ;
void read( )
{
cin >> n >> L >> R;
for ( int i = 1 ; i <= n; i++ )
adj[ i] .clear ( ) ;
for ( int i = 0 ; i < n - 1 ; i++ )
{
int u, v;
cin >> u >> v;
adj[ u] .push_back ( v) ;
adj[ v] .push_back ( u) ;
}
}
int tr_sz[ MAXN] , cnt_vers;
bool used[ MAXN] ;
void pre_dfs( int u, int pr)
{
cnt_vers++ ;
tr_sz[ u] = 1 ;
for ( int v: adj[ u] )
if ( ! used[ v] && v ! = pr)
{
pre_dfs( v, u) ;
tr_sz[ u] + = tr_sz[ v] ;
}
}
int centroid( int u, int pr)
{
for ( int v: adj[ u] )
if ( ! used[ v] && v ! = pr && tr_sz[ v] > cnt_vers / 2 )
return centroid( v, u) ;
return u;
}
int link[ MAXN] ;
vector< int64_t > cnt;
void dfs_add( int u, int pr, int dep = 0 )
{
if ( dep ! = 0 )
cnt[ dep] ++ ;
for ( int v: adj[ u] )
if ( v ! = pr && ! used[ v] )
dfs_add( v, u, dep + 1 ) ;
}
int64_t answer[ MAXN] ;
void add_dfs1( int u, int pr, int dep = 0 )
{
answer[ dep] ++ ;
for ( int v: adj[ u] )
if ( v ! = pr && ! used[ v] )
add_dfs1( v, u, dep + 1 ) ;
}
vector< int64_t > get_cnt( int u, int pr, int d)
{
cnt.assign ( tr_sz[ u] + 1 , 0 ) ;
dfs_add( u, pr, d) ;
return cnt;
}
void decompose( int u, int pr = - 1 )
{
cnt_vers = 0 ;
pre_dfs( u, u) ;
int cen = centroid( u, u) ;
link[ cen] = pr;
used[ cen] = true ;
for ( int v: adj[ cen] )
if ( ! used[ v] )
decompose( v, cen) ;
used[ cen] = false ;
pre_dfs( cen, cen) ;
vector< int64_t > answer_c( 2 * cnt_vers + 42 , 0 ) ;
vector< int64_t > Cn = get_cnt( cen, cen, 0 ) ;
Cn = mult( Cn, Cn) ;
for ( int i = 0 ; i < SZ( Cn) ; i++ )
answer_c[ i] + = Cn[ i] ;
for ( int v: adj[ cen] )
if ( ! used[ v] )
{
add_dfs1( v, cen, 1 ) ;
Cn = get_cnt( v, cen, 1 ) ;
Cn = mult( Cn, Cn) ;
for ( int i = 0 ; i < SZ( Cn) ; i++ )
answer_c[ i] - = Cn[ i] ;
}
for ( int i = 0 ; i < SZ( answer_c) ; i++ )
answer[ i] + = answer_c[ i] / 2ll;
}
void solve( )
{
for ( int i = 0 ; i <= n; i++ )
answer[ i] = 0 ;
decompose( 1 ) ;
int64_t ans = 0 ;
for ( int i = 0 ; i <= n - 1 ; i++ )
{
int c = n - 1 - i;
if ( L <= c && c <= R)
ans + = answer[ i] ;
}
cout << ans << endl;
}
int main( )
{
ios_base:: sync_with_stdio ( false ) ;
cin .tie ( NULL ) ;
freopen ( "awesome.in" , "r" , stdin ) ;
int T;
cin >> T;
while ( T-- )
{
read( ) ;
solve( ) ;
}
return 0 ;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgZW5kbCAnXG4nCgovLyNwcmFnbWEgR0NDIG9wdGltaXplICgiTzMiKQovLyNwcmFnbWEgR0NDIHRhcmdldCAoInNzZTQiKQoKI2RlZmluZSBTWih4KSAoKGludCl4LnNpemUoKSkKI2RlZmluZSBBTEwoVikgVi5iZWdpbigpLCBWLmVuZCgpCiNkZWZpbmUgTF9CIGxvd2VyX2JvdW5kCiNkZWZpbmUgVV9CIHVwcGVyX2JvdW5kCiNkZWZpbmUgcGIgcHVzaF9iYWNrCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwp0ZW1wbGF0ZTxjbGFzcyBULCBjbGFzcyBUMj4gaW5saW5lIGludCBjaGttYXgoVCAmeCwgY29uc3QgVDIgJnkpIHsgcmV0dXJuIH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