/*
 * 2619.cc: Thread Tree
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

/* typedef */

typedef vector<int> vi;

/* global variables */

string msgs[MAX_N];
vi chlds[MAX_N];

/* subroutines */

void print_tree(int k, int idx) {
  for (int i = 0; i < idx; i++) putchar('.');
  cout << msgs[k] << endl;

  for (vi::iterator vit = chlds[k].begin(); vit != chlds[k].end(); vit++)
    print_tree(*vit, idx + 1);
}

/* main */

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

  for (int i = 0; i < n; i++) {
    int ki;
    cin >> ki >> msgs[i];
    ki--;
    if (i > 0) chlds[ki].push_back(i);
  }

  print_tree(0, 0);
  return 0;
}