#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)

int main() {
    int n; cin >> n;
    vector<string> M(n);
    vector<vector<int>> reply(n + 1);
    rep(i, n) {
        int k; cin >> k >> M[i];
        reply[k].push_back(i);
    }
    function<void(int, int)> dump = [&](int d, int k) {
        if (k > n) return;
        for (int& i : reply[k]) {
            cout << string(d, '.') << M[i] << endl;
            dump(d + 1, i + 1);
        }
    };
    dump(0, 0);
}