#include typedef struct list { int v; struct list *n; } list; typedef struct tree { struct tree *p; } tree; tree *get_root (tree *t) { if (t == NULL || t->p == NULL) { return t; } t->p = get_root(t->p); return t->p; } void func (int v, list **e, int *visited, int ans[][2]) { list *l = e[v]; visited[v] = 1; ans[v][0] = 0; ans[v][1] = 0; while (l != NULL) { if (visited[l->v] <= 0) { func(l->v, e, visited, ans); if (ans[v][0] < ans[l->v][1]+1) { ans[v][0] = ans[l->v][1]+1; } if (ans[v][1] <= 0 || ans[v][1] > ans[l->v][0]+1) { ans[v][1] = ans[l->v][0]+1; } } l = l->n; } return; } int main () { int n = 0; int k = 0; int u = 0; int v = 0; int res = 0; int ans[200000][2] = {}; list *e[200000] = {}; list pool[399998] = {}; int used = 0; int visited[200000] = {}; res = scanf("%d", &n); for (int i = 0; i < n-1; i++) { res = scanf("%d", &u); res = scanf("%d", &u); u--; v--; pool[used].v = v; pool[used].n = e[u]; e[u] = pool+used; used++; pool[used].v = u; pool[used].n = e[v]; e[v] = pool+used; used++; } func(0, e, visited, ans); printf("%d\n%d\n", ans[0][0], ans[0][1]); return 0; }