#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> g;
vector<bool> removed;
vector<bool> vis;
vector<int> deg;
int maxD;
int dfs(int u)
{
vis[u] = true;
int cnt = 1;
for (auto [v, id] : g[u])
{
if (vis[v] || removed[id])
continue;
cnt += dfs(v);
}
return cnt;
}
int dfs2(int u, int d)
{
vis[u] = true;
maxD = max(maxD, d);
int cnt = 1;
for (auto [v, id] : g[u])
{
if (vis[v] || removed[id])
continue;
cnt += dfs2(v, d + 1);
}
return cnt;
}
int main()
{
int h;
cin >> h;
int n = (1 << h) - 1;
int m = (1 << h) + 1;
g.resize(n);
removed.resize(m);
vector<pair<int, int>> edges;
for (int i = 0; i < m; i++)
{
int u, v;
cin >> u >> v;
u--; v--;
edges.emplace_back(u, v);
g[u].emplace_back(v, i);
g[v].emplace_back(u, i);
}
vector<int> candidates;
for (int i = 0; i < m; i++)
{
removed[i] = true;
vis.assign(n, false);
int cnt = dfs(0);
if (cnt == n)
{
candidates.push_back(i);
}
removed[i] = false;
}
if (candidates.size() > 60)
{
cout << -1 << "\n";
}
for (int i = 0; i < candidates.size(); i++)
{
for (int j = i + 1; j < candidates.size(); j++)
{
for (int k = j + 1; k < candidates.size(); k++)
{
removed[candidates[i]] = true;
removed[candidates[j]] = true;
removed[candidates[k]] = true;
deg.assign(n, 0);
for (int id = 0; id < m; id++)
{
if (removed[id])
continue;
auto [u, v] = edges[id];
deg[u]++;
deg[v]++;
}
int root = -1;
int leaves = 0;
bool ok = true;
for (int u = 0; u < n; u++)
{
if (deg[u] == 2)
root = u;
else if (deg[u] == 1)
leaves++;
else
ok &= deg[u] == 3;
}
ok &= root != -1;
ok &= leaves == 1 << (h - 1);
if (ok)
{
maxD = 0;
vis.assign(n, false);
int cnt = dfs2(root, 0);
ok &= cnt == n;
ok &= maxD == h - 1;
if (ok)
{
cout << candidates[i] + 1 << " " << candidates[j] + 1 << " " << candidates[k] + 1 << "\n";
return 0;
}
}
removed[candidates[i]] = false;
removed[candidates[j]] = false;
removed[candidates[k]] = false;
}
}
}
cout << -1 << "\n";
return 0;
}