Problem:
Score : 400 points

Problem Statement

Fennec and Snuke are playing a board game.

On the board, there are N cells numbered 1 through N, and N-1 roads, each connecting two cells. Cell a_i is adjacent to Cell b_i through the i-th road. Every cell can be reached from every other cell by repeatedly traveling to an adjacent cell. In terms of graph theory, the graph formed by the cells and the roads is a tree.

Initially, Cell 1 is painted black, and Cell N is painted white. The other cells are not yet colored.
Fennec (who goes first) and Snuke (who goes second) alternately paint an uncolored cell.
More specifically, each player performs the following action in her/his turn:

Fennec: selects an uncolored cell that is adjacent to a black cell, and paints it black.

Snuke: selects an uncolored cell that is adjacent to a white cell, and paints it white.

A player loses when she/he cannot paint a cell. Determine the winner of the game when Fennec and Snuke play optimally.

Constraints

2 \leq N \leq 10^5

1 \leq a_i, b_i \leq N

The given graph is a tree.

Input

Input is given from Standard Input in the following format:

N
a_1 b_1
:
a_{N-1} b_{N-1}

Output

If Fennec wins, print Fennec; if Snuke wins, print Snuke.

Sample Input 1

7
3 6
1 2
3 1
7 4
5 7
1 4

Sample Output 1

Fennec

For example, if Fennec first paints Cell 2 black, she will win regardless of Snuke's moves.

Sample Input 2

4
1 4
4 2
2 3

Sample Output 2

Snuke

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static ArrayList<String> s = new ArrayList<String>();
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n= in.nextInt();
		ArrayList<Integer>[] adj= new ArrayList[n];
		for (int i = 0; i < adj.length; i++) {
			adj[i]= new ArrayList<Integer>();
		}
		for (int i = 0; i < n-1; i++) {
			int a= in.nextInt()-1;
			int b= in.nextInt()-1;
			adj[a].add(b);
			adj[b].add(a);
		}
		int midnode= 0;
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		q.offer(0);
		int[] vis = new int[n];
		int [] dist= new int[n];
		Arrays.fill(vis, -1);
		vis[0] = 0;
		dist[0]=0;
		while (!q.isEmpty()) {
			int cur = q.poll();
			for (int v : adj[cur]) {
				if (vis[v] == -1) {
					vis[v] = cur;
					dist[v]= dist[cur]+1;
					q.offer(v);
				}
			}
		}
		ArrayDeque<Integer> path = new ArrayDeque<Integer>();
		int go = n-1;
		path.add(go);
		while (go != -1 && go != 0) {
			path.addFirst(vis[go]);
			go = vis[go];
		}
		int distance= dist[n-1];
		int cop= 0;
		int block= -1;
		while(cop<distance/2+1){
			block= path.poll();
			cop++;
		}
		block= path.poll();
		boolean [] numferr= new boolean[n];
		ArrayDeque<Integer> ferrad= new ArrayDeque<>();
		numferr[0]= true;
		ferrad.offer(0);
		while(!ferrad.isEmpty()){
			int cur= ferrad.poll();
			for(int nex: adj[cur]){
				if(nex==block) continue;
				if(!numferr[nex]){
					ferrad.offer(nex);
					numferr[nex]= true;
				}
			}
		}
		int res=0;
		for (int i = 0; i < numferr.length; i++) {
			if(numferr[i]){
				res++;
			}
		}

		int other= n-res;
		if(res<=other){
			System.out.println("Snuke");
		}
		else{
			System.out.println("Fennec");
		}

	}
	public static void combinations(String suffix,String prefix){
		if(prefix.length()<0)return;
		s.add(suffix);
		for(int i=0;i<prefix.length();i++)
			combinations(suffix+prefix.charAt(i),prefix.substring(i+1,prefix.length()));
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}

		public double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		public String next() throws IOException {
			if (!st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
				return next();
			}
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
	}
}