import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
static int N;
static int[] costs;
static List<List<Integer>> list;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
N = Integer.parseInt(br.readLine());
list = new ArrayList<>();
for(int i=0; i<=N; i++){
list.add(new ArrayList<>());
}
while(true){
StringTokenizer st = new StringTokenizer(br.readLine());
int from = Integer.parseInt(st.nextToken());
int to = Integer.parseInt(st.nextToken());
if(from == -1 || to == -1) break;
list.get(from).add(to);
list.get(to).add(from);
}
costs = new int[N+1];
for(int i=1; i<=N; i++){
bfs(i);
}
int minCost = Integer.MAX_VALUE;
for(int i=1; i<=N; i++){
minCost = Math.min(minCost, costs[i]);
}
List<Integer> cntList = new ArrayList<>();
for(int i=1; i<=N; i++){
if(costs[i] == minCost) cntList.add(i);
}
Collections.sort(cntList);
System.out.println(minCost+" "+cntList.size());
for(Integer num : cntList){
System.out.print(num+ " ");
}
}
static void bfs(int startV){
boolean[] visited = new boolean[N+1];
visited[startV] = true;
int cost = 0;
int maxCost = 0;
Deque<int[] > queue = new ArrayDeque<>();
queue.offer(new int[]{startV, cost});
while(!queue.isEmpty()){
int[] curr = queue.poll();
int currV = curr[0];
int currCost = curr[1];
for(Integer nextV : list.get(currV)){
if(!visited[nextV]){
visited[nextV] = true;
maxCost = Math.max(maxCost, currCost+1);
queue.offer(new int[] {nextV, currCost+1});
}
}
}
costs[startV] = maxCost;
}
}