#include <iostream>
#include <vector>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

class State {
public:
	int id;
	string str;
	int deep;
	vector<State> rep;

	void draw()
	{
		rep(i, deep) {
			cout << '.';
		}

		cout << str << endl;

		for (auto& r : rep) {
			r.draw();
		}
	}

	void add(State s, int i)
	{
		if (i == id) {
			s.deep = deep + 1;
			rep.push_back(s);
		}
		else {
			for (auto& r : rep) {
				r.add(s, i);
			}
		}
	}
};

int main()
{
	int n;

	cin >> n;

	State s;
	s.id = 1;
	s.deep = 0;
	
	cin >> s.str >> s.str;

	rep(i, n - 1) {
		int r;
		State temp;
		temp.id = i + 2;

		cin >> r >> temp.str;

		s.add(temp, r);
	}

	s.draw();

	return 0;
}