n = gets.to_i
_a = []

n.times{
    _a.push(gets.split.map(&:to_i))
}

x = []
n.times{|i|
    x.push([i, -1, -1, 0, 0, -1, "root"])
}

def checkdepth(x, k, d)
    if k[1] == -1 then
        return d
    else
        checkdepth(x,x[k[1]],d+1)
    end
end

def checkheight(x, k, h)
   
end

_a.each{|k|
    x[k[0]][6] = "internal node"
    if k[1] != -1 then
        x[k[1]][1] = k[0]
        x[k[0]][3] += 1
    end
    if k[2] != -1 then
        x[k[2]][1] = k[0]
        x[k[0]][3] += 1
    end
    if k[1] != -1 && k[2] != -1 then
        x[k[1]][2] = k[2]
        x[k[2]][2] = k[1]
    elsif k[1] == -1 && k[2] == -1 then
        x[k[0]][6] = "leaf"
    end
}

def merge(a, l, r, m)
    _L = a[l..m-1]
    _R = a[m..r-1]
    _L.push([0,1.0/0.0])
    _R.push([0,1.0/0.0])
    i = j = 0
    for k in 0..r-l-1
        if _L[i][1] <= _R[j][1] then
            a[l + k] = _L[i]
            i += 1
        else
            a[l + k] = _R[j]
            j += 1
        end
    end
end

def mergesort(a, l, r)
    if l + 1 < r then
        m = (l + r) / 2
        mergesort(a, l, m)
        mergesort(a, m, r)
        merge(a, l, r, m)
    end
end

x.each{|k|
    k[4] = checkdepth(x, k, 0)
}

c = []
x.each{|k|
    c.push([k[0],k[4]])
}

mergesort(c, 0, c.length)
c.reverse!

def checkheight(x, k, h)
    x[k][5] = h
    if x[x[k][1]][5] == -1 && x[k][1] != -1 then
        checkheight(x, x[k][1], h+1)
    end

end

c.each{|k|
    if x[k[0]][5] == -1 then
        checkheight(x, k[0], 0)
    end
}

x.each{|k|   
    if k[1] == -1 then
        k[6] = "root"
    end
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n",k[0],k[1],k[2],k[3],k[4],k[5],k[6])
}
