```cpp
#include
using namespace std;
int k;
struct Tree {
int left,right;
}myTree[17];
void qianxu(int q) {
//root -> leftson -> rightson
if(q) {
cout<
qianxu(myTree[q].left);
qianxu(myTree[q].right);
}
}
void zhongxu(int z) {
//leftson -> root -> rightson
if(z) {
zhongxu(myTree[z].left);
cout<
}
}
void houxu(int h) {
//leftson -> rightson -> root
if(h) {
houxu(myTree[h].left);
houxu(myTree[h].right);
cout<
}
int main() {
cin>>k;
for(int i=1;i<=k;i++) {
cin>>myTree[i].left>>myTree[i].right;
}
qianxu(1);
cout<
cout<
return 0;
}
```