#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = 1e6+10;
const int mod = 1e9+7;
#define all(x) (x).begin(), (x).end()
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
struct point_2d
{
ld x , y ;
point_2d operator+ ( point_2d p ){ return { p.x + x , p.y + y }; }
point_2d operator- ( point_2d p ){ return { p.x - x , p.y - y }; }
point_2d operator* ( ld d ){ return { x * d , y * d }; }
point_2d operator/ ( ld d ){ return { x / d , y / d }; }
};
struct circle{
ld r ;
point_2d c ;
};
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
vector<int> parent ;
vector<circle> circles;
//Functions:-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
ld distance( point_2d a ){
return sqrt( a.x*a.x + a.y*a.y );
}
bool Can_connect( circle a , circle b ){
return ( distance( a.c - b.c ) <= ( a.r + b.r ) ) ;
}
int find_parent( int x ){
if( parent[x] != x ) parent[x] = find_parent( parent[x] );
return parent[x] ;
}
void join( int x , int y ){
x = find_parent( x );
y = find_parent( y );
parent[y] = x ;
}
ld to_degree( ld rad ){
return rad * (180.0 / acos(-1));
}
ld find_angle( point_2d a ){
if( a.x == 0 && a.y == 0 )
while(true);
if( a.x > 0.0 && a.y == 0.0 ) return 0.00;
if( a.x == 0.0 && a.y > 0.0 ) return 90.00;
if( a.x < 0.0 && a.y == 0.0 ) return 180.0;
if( a.x == 0.0 && a.y < 0.0 ) return 270.0;
ld angle = atan( abs(a.y) / abs(a.x) );
angle = to_degree( angle );
if( a.x > 0.0 && a.y > 0.0 ) return angle ;
if( a.x < 0.0 && a.y > 0.0 ) return 180.0 - angle ;
if( a.x < 0.0 && a.y < 0.0 ) return 180.0 + angle ;
if( a.x > 0.0 && a.y < 0.0 ) return 360.0 - angle ;
}
void make_groups(){
int n = circles.size() ;
for( int i = 0 ; i < n ; i++ )
for( int j = i+1 ; j < n ; j++ )
if( Can_connect( circles[i] , circles[j]) )
join( i , j );
for( int i = 0 ; i < n ; i++ )
parent[i] = find_parent( i );
}
void solve(){
int n , R , k ; cin >> n >> R >> k ;
parent.clear();
parent.resize( n );
circles.clear();
circles.resize( n );
for( int i = 0 ; i < n ; i++ ){
cin >> circles[i].c.x >> circles[i].c.y >> circles[i].r ;
parent[i] = i ;
}
make_groups();
map< int , bool > used ;
map< int , pair<ld,ld> > range ;
set< int > groups ;
for( int i = 0 ; i < n ; i++ ){
groups.insert( parent[i] ) ;
ld angle = find_angle( circles[i].c ) ;
ld theta = to_degree(asin(circles[i].r / distance( circles[i].c ))) ;
ld st_angle = angle - theta ;
ld en_angle = angle + theta ;
if( st_angle > en_angle )
en_angle += 360.0;
if( used[parent[i]] == false ){
used[parent[i]] = true ;
range[parent[i]] = { st_angle , en_angle } ;
}
range[parent[i]] = { max( st_angle , range[parent[i]].first ) , max( en_angle , range[parent[i]].second ) } ;
}
for( int c = 1 ; c <= k ; c++ ){
int ans = 1 ;
ld l = 360.0 / c ;
pair< ld , ld > rg = { 0 , l } ;
bool flag1 = false , flag2 = false ;
for( auto i : groups ){
int val = range[i].first / l ;
ld st_angle = range[i].first - (ll)(val) * l ;
ld en_angle = range[i].second - (ll)(val) * l ;
ld w = en_angle - st_angle ;
if( ( en_angle - st_angle ) >= 2 * l ){
ans = 0 ;
break;
}else if( ( en_angle - st_angle ) < l ) continue ;
if( st_angle == 0.0 ) flag1 = true;
if( en_angle < 2 * l){
rg = { max( rg.first , (ld)0 ) , min( rg.second , 2 * l - en_angle ) };
}else{
rg = { max( rg.first , l + w - en_angle ) , min( rg.second , 3 * l - en_angle ) };
}
}
if( ans == 0 ){
cout << ans ;
continue;
}
if( rg.first == rg.second && rg.first == 0 && !flag1 )
ans = 1 ;
else if( rg.first < rg.second )
ans = 1 ;
else
ans = 0 ;
cout << ans ;
}
cout << endl;
// exit(0);
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.precision(10);
cout << fixed;
#ifndef ONLINE_JUDGE
freopen("input.txt" , "r" , stdin );
#endif
int t ; cin >> t ;
while( t-- ) solve();
// cout << find_angle( { 0 , 0 } ) << endl;
}
Copy