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 Rust (1.15.1) (judge verdict: Wrong Answer)

use std::vec::Vec;
use std::cmp::*;
use std::collections::VecDeque;
use std::collections::BinaryHeap;


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let mut g = vec![vec![]; n];
    for _ in 0..n-1 {
      let t: Vec<(usize)> = read_vec();
      g[t[0] - 1].push((t[1] - 1, 1));
      g[t[1] - 1].push((t[0] - 1, 1));
    }

    let dist = dijkstra_to_goal(n, &g, 0, n-1) - 1;
    let count = bfs(n, &g, 0, n-1);

    let fennec = count - dist + (dist + 1) / 2;
    let snuke =  n as u64 - fennec - 2;
    /*
    println!("count = {}", count);
    println!("dist = {}", dist);
    println!("fennec = {}", fennec);
    println!("snuke = {}", snuke);
    */
    if fennec > snuke {
      println!("Fennec");
    } else {
      println!("Snuke");
    }
}


// 単一始点から目的のノードへの最短経路超を探索
fn dijkstra_to_goal(n: usize, adj_list: &Vec<Vec<(usize, u64)>>, start: usize, goal: usize) -> u64 {
  let mut dist = vec![std::u64::MAX; n];
  let mut p_queue: BinaryHeap<(i64, usize)> = BinaryHeap::new();

  //init
  dist[start] = 0;
  p_queue.push((0, start));

  while !p_queue.is_empty() {
    // 起点となるノード
    let (cost, now)
      = match p_queue.pop() {
        None => break,
        Some(e) => (-e.0 as u64, e.1),
      };

      if now == goal {
        break;
      }

    // 繋がっているノードを探索
    for &edge in &adj_list[now] {
      let next = edge.0;
      let weight = edge.1;

      if dist[next] > weight + cost {
        p_queue.push((-((weight + cost) as i64), next));
        dist[next] = weight + cost;
      }
    }

  }

  dist[goal]
}


fn bfs(n: usize, g: &Vec<Vec<(usize, u64)>>, start: usize, oppsite: usize) -> u64 {
  let mut visit = vec![false; n];
  let mut q = VecDeque::new();
  let mut count = 0;
  //init
  visit[start] = true;
  q.push_back(start);

  while !q.is_empty() {
    let now
      = match q.pop_front() {
        None => 0,
        Some(e) => e,
      };

      for &e in &g[now] {
        if !visit[e.0] && e.0 != oppsite {
          visit[e.0] = true;
          q.push_back(e.0);
          count += 1;
        }
      }
  }

  count
}