#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
struct edge
{
    int to; string word;
    edge(int to, string word) { this->to = to, this->word = word; }
};
vector<edge> G[1010];
void dfs(int depth, int num)
{
    if(G[depth].size() == 0) return;
    for(int u = 0; u < G[depth].size(); u++)
    {
        for(int i = 0; i < num; i++) cout << ".";
        cout << G[depth][u].word << endl;
        if(G[depth][u].to != depth) dfs(G[depth][u].to, num + 1);
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    for(int i = 0; i < n; i++)
    {
        int k; cin >> k;
        string word; cin >> word;
        G[k].push_back(edge(i + 1, word));
    }
    dfs(0, 0);
    return 0;
}


