#include <iostream>
#include <vector>
using namespace std;

void print(int curr, int depth, vector<vector<int> > list, vector<string> res){
    string dots = "";
    for(int i=0; i<depth; i++){
        dots += ".";
    }
    cout << dots << res[curr] << endl;

    for(int i=0; i<(int)list[curr].size(); i++){
        print(list[curr][i], depth+1, list, res);
    }
}

int main(){
    int n;
    cin >> n;

    vector<vector<int> > list(n+1);
    vector<string> res(n+1);
    for(int i=1; i<=n; i++){
        int k;
        cin >> k >> res[i];
        list[k].push_back(i);
    }

    print(1, 0, list, res);
    return 0;
}