#!/usr/bin/perl

$data=$ARGV[0];

open(FL,$data);
$i=0;
while(<FL>){
    chop;my @array = split;
    
    $k=int($i/4);
    $l=$i-($k*4);
    
    $time[$l]=$array[0];
    $tlm_flag[$l]=$array[1];
    
    if($l==3){

	$tlm_flag_sum[$k]=$tlm_flag[0]+$tlm_flag[1]+$tlm_flag[2]+$tlm_flag[3];
	$time_init[$k]=$time[0];

#	print"$time[0] $tlm_flag_sum[$k]\n";

    }

	$i++;
    
}

$maxk=$k;
#print"$maxk\n";

for($j=0;$j<=$maxk;$j++){
#    print"$j $time_init[$j] $tlm_flag_sum[$j] \n";

    if($tlm_flag_sum[$j]==0){
	$gti_start[$m]=$time_init[$j];
#	print"$time_init[$j] $gti_start ";
	$m++;
    }else{
	$gti_end=$time_init[$j-1];
	
	if($m>0){
	print"$gti_start[0] $gti_end\n";
	}
	$m=0;
    }
}
