def dfs(rel,node,level)
    n = 0
    c = rel[n]
    while c.size > 0
        n = c.shift
        print "." * level[n]
        puts node[n]
        next if !rel[n]
        c = rel[n] + c
    end
end
n = gets.to_i
node = Array.new
level = Array.new(n,-1)
child = Array.new(n).map{Array.new}
n.times do |i|
    k = gets.to_i
    m = gets.chomp
    node[i+1] = m
    level[i+1] = level[k] + 1
    child[k].push(i+1)
end
dfs(child,node,level)