func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 5;   vector<int> e[N];   set<int> s[N];   queue<int> q;   bool vis[N];   int d[N];   int main() {     int n;     scanf( %d , &n);     for (int i = 1; i < n; i++) {       int u, v;       scanf( %d %d , &u, &v);       d[u]++, d[v]++;       e[u].push_back(v), e[v].push_back(u);     }     for (int i = 1; i <= n; i++)       if (d[i] == 1) q.push(i), s[i].insert(0);     while (q.size()) {       int tp = q.front();       q.pop();       vis[tp] = true;       for (int i = 0; i < e[tp].size(); i++) {         int v = e[tp][i];         if (vis[v]) continue;         d[v]--;         s[v].insert(*(s[tp].begin()) + 1);         if (d[v] == 1 && s[v].size() == 1) q.push(v);       }     }     int cnt = 0, ans = 0;     for (int i = 1; i <= n; i++)       if (s[i].size() > 2 || s[i].size() == 0)         return 0 * puts( -1 );       else if (s[i].size() == 1)         ans = max(ans, *s[i].begin());       else         cnt++, ans = max(ans, (*s[i].begin()) + (*s[i].rbegin()));     if (cnt > 1)       puts( -1 );     else {       while (ans % 2 == 0) ans /= 2;       printf( %d n , ans);     }     return 0;   }   