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 C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Numerics;

namespace competitive
{
    class Program
    {
        static void Main(string[] args)
        {
            var scanner = new Scanner();
            var n = scanner.NextInt();
            var graph = new List<int>[n];
            for (int i = 0; i < n; i++)
            {
                graph[i] = new List<int>();
            }
            for (int i = 0; i < n - 1; i++)
            {
                var a = scanner.NextInt();
                var b = scanner.NextInt();
                graph[a - 1].Add(b - 1);
                graph[b - 1].Add(a - 1);
            }
            // key is player, value is before tile
            var board = new KeyValuePair<int, int>[n];
            board[0] = new KeyValuePair<int, int>(1, int.MinValue);
            board[n - 1] = new KeyValuePair<int, int>(-1, int.MinValue);
            // 幅優先探索を使って1 - n(0 - n-1)間の最短経路を求める
            var queue = new Queue<KeyValuePair<int, int>>();
            // key is index, value is cost
            queue.Enqueue(new KeyValuePair<int, int>(0, 0));
            var cost = -1;
            while (queue.Count > 0)
            {
                var item = queue.Dequeue();
                if (item.Key == n - 1)
                {
                    cost = item.Value;
                    break;
                }
                var tiles = graph[item.Key];
                foreach (var tile in tiles)
                {
                    board[tile] = new KeyValuePair<int, int>(0, item.Key);
                    queue.Enqueue(new KeyValuePair<int, int>(tile, item.Value + 1));
                }
            }
            board[0] = new KeyValuePair<int, int>(1, int.MinValue);
            board[n - 1] = new KeyValuePair<int, int>(-1, board[n - 1].Value);
            var minRoute = new List<int>();
            var currentInd = n - 1;
            while (true)
            {
                var current = board[currentInd];
                minRoute.Add(currentInd);
                currentInd = board[currentInd].Value;
                if (currentInd == int.MinValue)
                {
                    break;
                }
            }
            minRoute.Reverse();

            var first = minRoute.Take(minRoute.Count / 2 + minRoute.Count % 2 == 0 ? 0 : 1);
            var second = minRoute.Skip(minRoute.Count / 2 + minRoute.Count % 2 == 0 ? 0 : 1);
            foreach (var item in first)
            {
                board[item] = new KeyValuePair<int, int>(1, board[item].Value);
            }
            foreach (var item in second)
            {
                board[item] = new KeyValuePair<int, int>(-1, board[item].Value);
            }
            var q2 = new Queue<int>();
            q2.Enqueue(0);
            while (q2.Count > 0)
            {
                var item = q2.Dequeue();
                var nexts = graph[item];
                foreach (var next in nexts)
                {
                    if (board[next].Key == 0)
                    {
                        board[next] = new KeyValuePair<int, int>(1, board[next].Value);
                        q2.Enqueue(next);
                    }
                }
            }
            var count = 0;
            for (int i = 0; i < n; i++)
            {
                if (board[i].Key == 1)
                {
                    count++;
                }
            }
            if (count > n - count)
            {
                Console.WriteLine("Fennec");
            }
            else
            {
                Console.WriteLine("Snuke");
            }
        }
    }
    #region
    public static class Extensions
    {
        public static int ToInt(this string str) => int.Parse(str);
        public static double ToDouble(this string str) => double.Parse(str);
        public static long ToLong(this string str) => long.Parse(str);
        public static BigInteger ToBigInteger(this string str) => BigInteger.Parse(str);
    }

    public class Scanner
    {
        private TextReader reader;
        public Scanner()
        {
            reader = Console.In;
        }
        public Scanner(TextReader reader)
        {
            this.reader = reader;
        }
        private string NextWord()
        {
            var sb = new StringBuilder();
            while (true)
            {
                var c = reader.Read();
                if ((c == 13 || c == 10 || c == 32) && sb.Length > 0 || c == -1)
                {
                    break;
                }
                sb.Append((char)c);
            }
            return sb.ToString();
        }
        public int NextInt()
        {
            return NextWord().ToInt();
        }
        public string Next()
        {
            return NextWord();
        }
        public double NextDouble()
        {
            return NextWord().ToDouble();
        }
        public long NextLong()
        {
            return NextWord().ToLong();
        }
        public BigInteger NextBigInteger()
        {
            return NextWord().ToBigInteger();
        }
        public string NextLine()
        {
            return reader.ReadLine();
        }
    }
    #endregion
}