<?
function retMax($p1, $p2)
{
if($p1>=p2)return $(int)p1;
else return $(int)p2;
}
function retMin($p1, $p2)
{
if($p1<=$p2)return $(int)p1;
else return $(int)p2;
}
function getNumFStr($string,$count)
{
$string.='|';
$q=0;
$i=0;
while(1)
{
if($string[$i]=='|') break;
if($string[$i]==' ') {$q++; $i++;}
else
{
if($q==$count) $tab.=$string[$i];
$i++;
}
}
return $tab;
}
function main()
{
$hm=0;
$hmt=0;
$stdin = fopen('php://stdin', 'r');
while($hm>0){
$hm=$hm-1;
$t=true;
while($hmt>0){
$hmt=$hmt-1;
$type=getNumFStr($line,0);
$x=0;
$y=0;
$r=0;
$maxX=0;
$maxY=0;
$minX=0;
$minY=0;
switch($type){
case 'c':
$x=getNumFStr($line,1);
$y=getNumFStr($line,2);
$r=getNumFStr($line,3);
$x=$x-1;
echo ("$x $y $r");
if($t==true){ $minX=$x-$r; $minY=$y-$r; $maxX=$x+$r; $maxY=$y+$r; }
else{
$u=$x-$r;
$minX=retMin($u, $minX);
$u=$y-$r;
$minY=retMin($u,$minY);
$u=$x+$r;
$maxX=retMax($u,$maxX);
$u=$y+$r;
$maxY=retMax($u,$maxY);}
break;
case 'p':
$x=getNumFStr($line,1);
$y=getNumFStr($line,2);
if($t==true){ $minX=$x; $minY=$y; $maxX=$x; $maxY=$y;}
else{ $minX=retMin($x, $minX); $minY=retMin($y,$minY); $maxX=retMax($x,$maxX); $maxY=retMax($y,$maxY);}
break;
case 'l':
$x=getNumFStr($line,1);
$y=getNumFStr($line,2);
$x2=getNumFStr($line,3);
$y2=getNumFStr($line,4);
if($t==true){ $minX=retMin($x,$x2); $minY=retMin($y,$y2); $maxX=retMax($x,$x2); $maxY=retMax($y,$y2); }
else{ $minX=retMin(retMin($x,$x2), $minX); $minY=retMin(retMin($y,$y2),$minY); $maxX=retMax(retMax($x,$x2),$maxX); $maxY=retMax(retMax($y,$y2),$maxY);}
break;
}
$t=false;
}
echo $minX.' '.$minY.' '.$maxX.' '.$maxY."\n";
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W5YPXJldE1pbigkeCwkeDIpOwkkbWluWT1yZXRNaW4oJHksJHkyKTsJJG1heFg9cmV0TWF4KCR4LCR4Mik7CSRtYXhZPXJldE1heCgkeSwkeTIpOwl9CgkJCQkJCWVsc2V7CSAkbWluWD1yZXRNaW4ocmV0TWluKCR4LCR4MiksICRtaW5YKTsJJG1pblk9cmV0TWluKHJldE1pbigkeSwkeTIpLCRtaW5ZKTsJJG1heFg9cmV0TWF4KHJldE1heCgkeCwkeDIpLCRtYXhYKTsJJG1heFk9cmV0TWF4KHJldE1heCgkeSwkeTIpLCRtYXhZKTt9CgkKCQkJCWJyZWFrOwoJCQl9CgkJCQoJCQkkdD1mYWxzZTsKCQkJCgkJfQoJCWVjaG8gJG1pblguJyAnLiRtaW5ZLicgJy4kbWF4WC4nICcuJG1heFkuIlxuIjsKCQkkbGluZT1mZ2V0cygkc3RkaW4pOwoJCQoJfQoJZmNsb3NlKCRzdGRpbik7CiAKfQptYWluKCk7Cj8+IA==
<?
function retMax($p1, $p2)
{
if($p1>=p2)return $(int)p1;
else return $(int)p2;
}
function retMin($p1, $p2)
{
if($p1<=$p2)return $(int)p1;
else return $(int)p2;
}
function getNumFStr($string,$count)
{
$string.='|';
$q=0;
$i=0;
while(1)
{
if($string[$i]=='|') break;
if($string[$i]==' ') {$q++; $i++;}
else
{
if($q==$count) $tab.=$string[$i];
$i++;
}
}
return $tab;
}
function main()
{
$hm=0;
$hmt=0;
$stdin = fopen('php://stdin', 'r');
fscanf($stdin, "%d", $hm);
while($hm>0){
$hm=$hm-1;
fscanf($stdin, "%d", $hmt);
$t=true;
while($hmt>0){
$hmt=$hmt-1;
$line=fgets($stdin);
$type=getNumFStr($line,0);
$x=0;
$y=0;
$r=0;
$maxX=0;
$maxY=0;
$minX=0;
$minY=0;
switch($type){
case 'c':
$x=getNumFStr($line,1);
$y=getNumFStr($line,2);
$r=getNumFStr($line,3);
$x=$x-1;
echo ("$x $y $r");
if($t==true){ $minX=$x-$r; $minY=$y-$r; $maxX=$x+$r; $maxY=$y+$r; }
else{
$u=$x-$r;
$minX=retMin($u, $minX);
$u=$y-$r;
$minY=retMin($u,$minY);
$u=$x+$r;
$maxX=retMax($u,$maxX);
$u=$y+$r;
$maxY=retMax($u,$maxY);}
break;
case 'p':
$x=getNumFStr($line,1);
$y=getNumFStr($line,2);
if($t==true){ $minX=$x; $minY=$y; $maxX=$x; $maxY=$y;}
else{ $minX=retMin($x, $minX); $minY=retMin($y,$minY); $maxX=retMax($x,$maxX); $maxY=retMax($y,$maxY);}
break;
case 'l':
$x=getNumFStr($line,1);
$y=getNumFStr($line,2);
$x2=getNumFStr($line,3);
$y2=getNumFStr($line,4);
if($t==true){ $minX=retMin($x,$x2); $minY=retMin($y,$y2); $maxX=retMax($x,$x2); $maxY=retMax($y,$y2); }
else{ $minX=retMin(retMin($x,$x2), $minX); $minY=retMin(retMin($y,$y2),$minY); $maxX=retMax(retMax($x,$x2),$maxX); $maxY=retMax(retMax($y,$y2),$maxY);}
break;
}
$t=false;
}
echo $minX.' '.$minY.' '.$maxX.' '.$maxY."\n";
$line=fgets($stdin);
}
fclose($stdin);
}
main();
?>