Language: C++

fscanf(STDIN,'%d',$n);
$tree=new Tree();
for($i=0;$i<$n;$i++) {
	$tree->insNode(trim(fgets(STDIN)));
}

for($i=2;$i<$fl;$i++){
	$tree->insNode($is[$i]);
}

for($i=0;$i<$cl;$i++){
	$node=$tree->getNode($i);

	$out='node '.$node->id.': ';
	$out.='parent = '.$node->getParent()->id.', ';
	$out.='depth = '.$node->getDepth().', ';
	$out.=$node->getType().', ';
	$out.='['.implode(', ',$node->child).']';

	$out.='<br>';
	echo $out;
}
print_r($tree);

class Tree{
	public $node=array();

	public function insNode($str){
		$this->node[]=new Node($this,$str);
	}
	function getNode($id){
		foreach($this->node as $node){
			if($node->id==$id){return $node;}
		}
		return new Node();
	}
}
class Node{
	public $tree;
	public $id=-1;
	public $parent;
	public $child=array();
	public $depth=-1;
	function __construct($tree='',$str=''){
		if(!$tree){return;}

		$this->tree=$tree;

		$in=explode(' ',$str);
		$this->id=(int)$in[0];

		$cl=$in[1]+2;
		for($i=2;$i<$cl;$i++){$this->child[]=(int)$in[$i];}
	}
	function getParent(){
		if(isset($this->parent)){return $this->parent;}
		foreach($this->tree->node as $node){
			if($node->id==$this->id){continue;}
			foreach($node->child as $child){
				if($child==$this->id){return $node;}
			}
		}
		return new Node();
	}
	function getDepth(){
		if($this->id==-1){return -1;}
		if($this->depth>-1){return $this->depth;}

		return $this->depth=$this->getParent()->getDepth()+1;
	}
	function getType(){
		$isP=($this->getParent()->id!=-1)? 1:0;
		$isC=(count($this->child))? 1:0;
		if(!$isP){return 'root';}
		return ($isC)? 'internal node':'leaf';
	}
}

Compiler output:
a.cc:1:14: warning: multi-character character constant [-Wmultichar]
    1 | fscanf(STDIN,'%d',$n);
      |              ^~~~
a.cc:14:14: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
   14 |         $out='node '.$node->id.': ';
      |              ^~~~~~~
a.cc:14:32: warning: multi-character character constant [-Wmultichar]
   14 |         $out='node '.$node->id.': ';
      |                                ^~~~
a.cc:15:15: warning: multi-character literal with 9 characters exceeds 'int' size of 4 bytes
   15 |         $out.='parent = '.$node->getParent()->id.', ';
      |               ^~~~~~~~~~~
a.cc:15:50: warning: multi-character character constant [-Wmultichar]
   15 |         $out.='parent = '.$node->getParent()->id.', ';
      |                                                  ^~~~
a.cc:16:15: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   16 |         $out.='depth = '.$node->getDepth().', ';
      |               ^~~~~~~~~~
a.cc:16:44: warning: multi-character character constant [-Wmultichar]
   16 |         $out.='depth = '.$node->getDepth().', ';
      |                                            ^~~~
a.cc:17:32: warning: multi-character character constant [-Wmultichar]
   17 |         $out.=$node->getType().', ';
      |                                ^~~~
a.cc:18:27: warning: multi-character character constant [-Wmultichar]
   18 |         $out.='['.implode(', ',$node->child).']';
      |                           ^~~~
a.cc:20:15: warning: multi-character character constant [-Wmultichar]
   20 |         $out.='<br>';
      |               ^~~~~~
a.cc:44:36: error: empty character constant
   44 |         function __construct($tree='',$str=''){
      |                                    ^~
a.cc:44:44: error: empty character constant
   44 |         function __construct($tree='',$str=''){
      |                                            ^~
a.cc:74:34: warning: multi-character character constant [-Wmultichar]
   74 |                 if(!$isP){return 'root';}
      |                                  ^~~~~~
a.cc:75:32: warning: multi-character literal with 13 characters exceeds 'int' size of 4 bytes
   75 |                 return ($isC)? 'internal node':'leaf';
      |                                ^~~~~~~~~~~~~~~
a.cc:75:48: warning: multi-character character constant [-Wmultichar]
   75 |                 return ($isC)? 'internal node':'leaf';
      |                                                ^~~~~~
a.cc:1:7: error: expected constructor, destructor, or type conversion before '(' token
    1 | fscanf(STDIN,'%d',$n);
      |       ^
a.cc:2:1: error: '$tree' does not name a type
    2 | $tree=new Tree();
      | ^~~~~
a.cc:3:1: error: expected unqualified-id before 'for'
    3 | for($i=0;$i<$n;$i++) {
      | ^~~
a.cc:3:10: error: '$i' does not name a type
    3 | for($i=0;$i<$n;$i++) {
      |          ^~
a.cc:3:16: error: '$i' does not name a type
    3 | for($i=0;$i<$n;$i++) {
      |                ^~
a.cc:7:1: error: expected unqualified-id before 'for'
    7 | for($i=2;$i<$fl;$i++){
      | ^~~
a.cc:7:10: error: '$i' does not name a type
    7 | for($i=2;$i<$fl;$i++){
      |          ^~
a.cc:7:17: error: '$i' does not name a type
    7 | for($i=2;$i<$fl;$i++){
      |                 ^~
a.cc:11:1: error: expected unqualified-id before 'for'
   11 | for($i=0;$i<$cl;$i++){
      | ^~~
a.cc:11:10: error: '$i' does not name a type
   11 | for($i=0;$i<$cl;$i++){
      |          ^~
a.cc:11:17: error: '$i' does not name a type
   11 | for($i=0;$i<$cl;$i++){
      |                 ^~
a.cc:23:8: error: expected constructor, destructor, or type conversion before '(' token
   23 | print_r($tree);
      |        ^
a.cc:26:15: error: expected ':' before '$node'
   26 |         public $node=array();
      |               ^~~~~~
      |               :
a.cc:26:16: error: '$node' does not name a type
   26 |         public $node=array();
      |                ^~~~~
a.cc:28:15: error: expected ':' before 'function'
   28 |         public function insNode($str){
      |               ^~~~~~~~~
      |               :
a.cc:28:16: error: 'function' does not name a type; did you mean 'union'?
   28 |         public function insNode($str){
      |                ^~~~~~~~
      |                union
a.cc:31:9: error: 'function' does not name a type; did you mean 'union'?
   31 |         function getNode($id){
      |         ^~~~~~~~
      |         union
a.cc:37:2: error: expected ';' after class definition
   37 | }
      |  ^
      |  ;
a.cc:39:15: error: expected ':' before '$tree'
   39 |         public $tree;
      |               ^~~~~~
      |               :
a.cc:39:16: error: '$tree' does not name a type
   39 |         public $tree;
      |                ^~~~~
a.cc:40:15: error: expected ':' before '$id'
   40 |         public $id=-1;
      |               ^~~~
      |               :
a.cc:40:16: error: '$id' does not name a type
   40 |         public $id=-1;
      |                ^~~
a.cc:41:15: error: expected ':' before '$parent'
   41 |         public $parent;
      |               ^~~~~~~~
      |               :
a.cc:41:16: error: '$parent' does not name a type
   41 |         public $parent;
      |                ^~~~~~~
a.cc:42:15: error: expected ':' before '$child'
   42 |         public $child=array();
      |               ^~~~~~~
      |               :
a.cc:42:16: error: '$child' does not name a type
   42 |         public $child=array();
      |                ^~~~~~
a.cc:43:15: error: expected ':' before '$depth'
   43 |         public $depth=-1;
      |               ^~~~~~~
      |               :
a.cc:43:16: error: '$depth' does not name a type
   43 |         public $depth=-1;
      |                ^~~~~~
a.cc:44:9: error: 'function' does not name a type; did you mean 'union'?
   44 |         function __construct($tree='',$str=''){
      |         ^~~~~~~~
      |         union
a.cc:55:9: error: 'function' does not name a type; did you mean 'union'?
   55 |         function getParent(){
      |         ^~~~~~~~
      |         union
a.cc:65:9: error: 'function' does not name a type; did you mean 'union'?
   65 |         function getDepth(){
      |         ^~~~~~~~
      |         union
a.cc:71:9: error: 'function' does not name a type; did you mean 'union'?
   71 |         function getType(){
      |         ^~~~~~~~
      |         union
a.cc:77:2: error: expected ';' after class definition
   77 | }
      |  ^
      |  ;