Here is my code:

```
public static void main(String [] args){
int[][] arr = new int[][] {{1,2}, {3,2}, {6,8}, {9,8} {2,5}, {8,5}, {5,-1}};
print(arr);
}
public static void print(int[][] arr){
int number_nodes = arr.length;
int[] visited = new int[arr.length];
for(int i=0; i<number_nodes; i++)
visited[i] = arr[i][0];
for(int i=0; i<arr.length; i++){
if(arr[i][1] == -1){
visited[i] =-1;
System.out.println(arr[i][0] +" -Root");
}else{
for(int j=0; j<arr.length; j++){
if(visited[i] == -1)
j++;
else if(arr[i][0] == arr[j][1]){
visited[i] = -1;
System.out.println(arr[i][0]+"- Inner");
}
}
}
}
for(int i=0; i<visited.length; i++){
if(visited[i] == -1)
System.out.println(visited[i]+ "-Leaf");
}
}
```