#include <bits/stdc++.h>
using namespace std;
struct TreeNode {
char val;
TreeNode *left, *right;
};
int n;
char a, b, c, rootc;
TreeNode **nodes;
void preorder(TreeNode *root) {
if (root == nullptr) return ;
cout << root->val;
preorder(root->left);
preorder(root->right);
}
int main() {
cin >> n;
nodes = new TreeNode* [26];
for (int i = 0; i < 26; i++) {
nodes[i]->val = i + 'a';
cout << "赋值完成!\n";
nodes[i]->left = nodes[i]->right = nullptr;
cout << "指针设置完成!\n";
cout << "i = " << i << endl;
}
for (int i = 0; i < n; i++) {
cin >> a >> b >> c;
if (i == 0) rootc = a;
if (b != '*') nodes[a - 'a']->left = nodes[b - 'a'];
if (c != '*') nodes[a - 'a']->right = nodes[c - 'a'];
}
preorder(nodes[rootc - 'a']);
delete[] nodes;
return 0;
}