#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
string dir[1024];
vector<int> subd[1024];
void pr(int d,int n){
  if(n!=0){
    REP(i,n-1) cout << '.';
    cout << dir[d] << endl;
  }
  REP(i,subd[d].size()){
    pr(subd[d][i],n+1);
  }
}
int main(void)
{
  int n;
  cin >> n;
  FOR(i,1,n+1){
    int pa;
    cin >> pa >> dir[i];
    subd[pa].push_back(i);
  }
  pr(0,0);
  return 0;
}