Problem:
Score : 800 points

Problem Statement

Takahashi and Aoki will play a game on a tree.
The tree has N vertices numbered 1 to N, and the i-th of the N-1 edges connects Vertex a_i and Vertex b_i.

At the beginning of the game, each vertex contains a coin.
Starting from Takahashi, he and Aoki will alternately perform the following operation:

Choose a vertex v that contains one or more coins, and remove all the coins from v.

Then, move each coin remaining on the tree to the vertex that is nearest to v among the adjacent vertices of the coin's current vertex.

The player who becomes unable to play, loses the game.
That is, the player who takes his turn when there is no coin remaining on the tree, loses the game.
Determine the winner of the game when both players play optimally.

Constraints

1 \leq N \leq 2 \times 10^5

1 \leq a_i, b_i \leq N

a_i \neq b_i

The graph given as input is a tree.

Input

Input is given from Standard Input in the following format:

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

Output

Print First if Takahashi will win, and print Second if Aoki will win.

Sample Input 1

3
1 2
2 3

Sample Output 1

First

Here is one possible progress of the game:

Takahashi removes the coin from Vertex 1. Now, Vertex 1 and Vertex 2 contain one coin each.

Aoki removes the coin from Vertex 2. Now, Vertex 2 contains one coin.

Takahashi removes the coin from Vertex 2. Now, there is no coin remaining on the tree.

Aoki takes his turn when there is no coin on the tree and loses.

Sample Input 2

6
1 2
2 3
2 4
4 6
5 6

Sample Output 2

Second

Sample Input 3

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

Sample Output 3

First

Solution in C# (Mono 4.6.2.0) (judge verdict: Accepted)

using System;
using System.Linq;
using System.Collections.Generic;

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            AGC033.C();
        }

        class AGC033
        {
            public static void A()
            {
                var H = Read.Int();
                var W = Read.Int();
                var A = new bool[H + 2, W + 2];
                Queue<Tuple<int, int>> queue = new Queue<Tuple<int, int>>();
                for(int i = 1; i <= H; ++i)
                {
                    var str = Read.Str();
                    for (int j = 0; j < W; ++j)
                    {
                        A[i, j + 1] = str[j] == '.';
                        if (str[j] == '#')
                        {
                            queue.Enqueue(new Tuple<int, int>(i, j + 1));
                        }
                    }
                }
                var distMax = 0;
                var dist = new int[H + 2, W + 2];
                for(int i = 0; i < H + 2; ++i)
                {
                    for(int j = 0; j < W + 2; ++j)
                    {
                        dist[i, j] = A[i, j] ? -1 : 0;
                    }
                }
                var dx = new int[] { 1, 0, -1, 0 };
                var dy = new int[] { 0, 1, 0, -1 };
                while (queue.Count > 0)
                {
                    var t = queue.Dequeue();
                    for(int i = 0; i < 4; ++i)
                    {
                        var x = t.Item1 + dx[i];
                        var y = t.Item2 + dy[i];
                        if (dist[x, y] < 0)
                        {
                            dist[x, y] = dist[t.Item1, t.Item2] + 1;
                            distMax = Math.Max(distMax, dist[x, y]);
                            queue.Enqueue(new Tuple<int, int>(x, y));
                        }
                    }
                }
                Console.WriteLine(distMax);
            }
            public static void B()
            {
                var H = Read.Int();
                var W = Read.Int();
                var N = Read.Int();
                var SR = Read.Int();
                var SC = Read.Int();
                var S = Read.Str();
                var T = Read.Str();
                {
                    int idx1 = 0;
                    int idx2 = H;
                    for(int i = N - 1; i >= 0; --i)
                    {
                        switch (T[i])
                        {
                            case 'U': idx2 = Math.Min(H, idx2 + 1); break;
                            case 'D': idx1 = Math.Max(0, idx1 - 1); break;
                        }
                        switch (S[i])
                        {
                            case 'U': idx1++; break;
                            case 'D': idx2--; break;
                        }
                        if (idx1 == idx2) { Console.WriteLine("NO"); return; }
                    }
                    if(idx1>=SR || idx2 < SR) { Console.WriteLine("NO"); return; }
                }
                {
                    int idx1 = 0;
                    int idx2 = W;
                    for (int i = N - 1; i >= 0; --i)
                    {
                        switch (T[i])
                        {
                            case 'L': idx2 = Math.Min(W, idx2 + 1); break;
                            case 'R': idx1 = Math.Max(0, idx1 - 1); break;
                        }
                        switch (S[i])
                        {
                            case 'L': idx1++; break;
                            case 'R': idx2--; break;
                        }
                        if (idx1 == idx2) { Console.WriteLine("NO"); return; }
                    }
                    if (idx1 >= SC || idx2 < SC) { Console.WriteLine("NO"); return; }
                }
                Console.WriteLine("YES");
            }
            public static void C()
            {
                var N = Read.Int();
                var Adj = Read.AdjacencyList(N, N - 1);
                var dist1 = Util.CalcDistance_OnTree(Adj, N, 1);
                var max = dist1.Max();
                var dist2 = Util.CalcDistance_OnTree(Adj, N, Enumerable.Range(1, N).Where(i => dist1[i] == max).First());
                var d = dist2.Max();
                Console.WriteLine(d % 3 != 1 ? "First" : "Second");
            }
        }


        class Util
        {
            public static int[] CalcDistance_OnTree(Dictionary<int, HashSet<int>> adj, int N, int start)
            {
                var dist = Enumerable.Range(0, N + 1).Select(i => -1).ToArray();
                dist[start] = 0;
                Queue<int> queue = new Queue<int>();
                queue.Enqueue(start);
                while (queue.Count > 0)
                {
                    var v = queue.Dequeue();
                    foreach (var w in adj[v])
                    {
                        if (dist[w] < 0)
                        {
                            dist[w] = dist[v] + 1;
                            queue.Enqueue(w);
                        }
                    }
                }
                return dist;
            }
        }

        static class Read
        {
            static Queue<string> queue = new Queue<string>();
            static void Enqueue() { var ss = Console.ReadLine().Split(' '); foreach (var s in ss) { queue.Enqueue(s); } }
            public static int Int() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt32(queue.Dequeue()); }
            public static long Long() { if (queue.Count == 0) { Enqueue(); } return Convert.ToInt64(queue.Dequeue()); }
            public static string Str() { if (queue.Count == 0) { Enqueue(); } return queue.Dequeue(); }
            public static int[] IntN() { return Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray(); }
            public static long[] LongN() { return Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray(); }
            public static string[] StrN() { return Console.ReadLine().Split(' '); }
            public static Tuple<int, int>[] TupleInt(int n) { List<Tuple<int, int>> list = new List<Tuple<int, int>>(); for (int i = 0; i < n; ++i) { var ab = Read.IntN(); list.Add(new Tuple<int, int>(ab[0], ab[1])); } return list.ToArray(); }
            public static Tuple<long, long>[] TupleLong(int n) { List<Tuple<long, long>> list = new List<Tuple<long, long>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<long, long>(ab[0], ab[1])); } return list.ToArray(); }
            public static Tuple<string, string>[] TupleStr(int n) { List<Tuple<string, string>> list = new List<Tuple<string, string>>(); for (int i = 0; i < n; ++i) { var ab = Read.StrN(); list.Add(new Tuple<string, string>(ab[0], ab[1])); } return list.ToArray(); }
            public static Tuple<double, double>[] TupleDouble(int n) { List<Tuple<double, double>> list = new List<Tuple<double, double>>(); for (int i = 0; i < n; ++i) { var ab = Read.LongN(); list.Add(new Tuple<double, double>(ab[0], ab[1])); } return list.ToArray(); }
            public static long[,] LongMatrix(int r, int c)
            {
                var mat = new long[r, c];
                for (int i = 0; i < r; ++i)
                {
                    var x = Read.LongN();
                    for (int j = 0; j < c; ++j)
                    {
                        mat[i, j] = x[j];
                    }
                }
                return mat;
            }
            public static Dictionary<int, HashSet<int>> AdjacencyList(int N, int M)
            {
                Dictionary<int, HashSet<int>> dict = new Dictionary<int, HashSet<int>>();
                for (int i = 0; i <= N; ++i)
                {
                    dict.Add(i, new HashSet<int>());
                }
                for (int i = 0; i < M; ++i)
                {
                    var ab = Read.IntN();
                    dict[ab[0]].Add(ab[1]);
                    dict[ab[1]].Add(ab[0]);
                }
                return dict;
            }
            public static Dictionary<int, Dictionary<int, long>> AdjacencyListWithWeight(int N, int M)
            {
                Dictionary<int, Dictionary<int, long>> dict = new Dictionary<int, Dictionary<int, long>>();
                for (int i = 0; i <= N; ++i)
                {
                    dict.Add(i, new Dictionary<int, long>());
                }
                for (int i = 0; i < M; ++i)
                {
                    var ab = Read.IntN();
                    dict[ab[0]].Add(ab[1], ab[2]);
                    dict[ab[1]].Add(ab[0], ab[2]);
                }
                return dict;
            }
        }
    }
}