stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef vector<ll> vll;

typedef vector<vll> vvll;



// あるノードを選び、根として、葉を全て削除する

// 最後の1つを選んだ人の勝ちt



int N;

vector<int>path[202020];

int flg[202020];

int mxx = 0;

void dfs(int x, int val){

    flg[x] = val;

    if(flg[mxx] < flg[x])mxx = x;

    for(int i = 0; i < path[x].size(); i++){

        int nxt = path[x][i];

        if(flg[nxt])continue;

        dfs(nxt, val + 1);

    }

}



int dp[202020];



int main(){



    cin >> N;

    for(int i = 1; i < N; i++){

        int a, b;

        cin >> a >> b;

        a--; b--;

        path[a].push_back(b);

        path[b].push_back(a);

    }

    for(int i = 0; i < N; i++)flg[i] = 0;

    dfs(0, 1);

    for(int i = 0; i < N; i++)flg[i] = 0;

    dfs(mxx, 1);

    int depth = flg[mxx];

    dp[0] = 1;

    dp[1] = 1;

    dp[2] = 2;

    for(int i = 1; i <= depth; i++){

        if(dp[i] == 0){

            if(dp[i - 1] == 1 && dp[i - 2] == 1){

                dp[i] = 2;

            }

            else{

                dp[i] = 1;

            }

        }

    }    

    if(dp[depth] == 1)cout << "First" << endl;

    else cout << "Second" << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 6.45067810557792x):
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;



class Tree{

    public:

    vector<vector<int> >edge;

    vector<int>depth;

    Tree(int num){

        edge = vector<vector<int> >(num);

        depth = vector<int>(num, 0);

    }

    void add(int a, int b){

        edge[a].push_back(b);

        edge[b].push_back(a);

    }

    void dfs(int x = 0, int from = -1, int dep = 1){

        depth[x] = dep;

        for(int i = 0; i < edge[x].size(); i++){

            int nxt = edge[x][i];

            if(from == nxt)continue;

            dfs(nxt, x, dep + 1);

        }

    }

    int diameter(){

        dfs();

        int mxIdx = 0;

        for(int i = 0; i < depth.size(); i++){

            if(depth[mxIdx] < depth[i]){

                mxIdx = i;

            }

        }

        dfs(mxIdx);

        int mxDepth = 0;

        for(int i = 0; i < depth.size(); i++){

            mxDepth = max(mxDepth, depth[i]);

        }

        return mxDepth;

    }

};

int main(){



    int N;

    cin >> N;

    Tree tree(N);

    for(int i = 1; i < N; i++){

        int a, b;

        cin >> a >> b;

        tree.add(a - 1, b - 1);

    }

    if(tree.diameter() % 3 == 2)cout << "Second" << endl;

    else cout << "First" << endl;



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define maxn 200005

using namespace std;

int n;

vector<int> g[maxn];

int dep[maxn];

int len, id;

bool SG[maxn];

void dfs(int x) {

	if (dep[x] > len) len = dep[x], id = x;

	for (int i = 0; i < g[x].size(); i++) {

		if (!dep[g[x][i]]) {

			dep[g[x][i]] = dep[x] + 1;

			dfs(g[x][i]);

		}

	}

}

int main() {

	scanf("%d", &n);

	memset(dep, 0, sizeof(dep));

	for (int i = 0; i < n - 1; i++) {

		int u, v;

		scanf("%d%d", &u, &v);

		g[u].push_back(v);

		g[v].push_back(u);

	}

	dep[1] = 1;

	dfs(1);

	memset(dep, 0, sizeof(dep));

	dep[id] = 1;

	dfs(id);

	SG[1] = 1; SG[2] = 0;

	for (int i = 3; i <= n; i++) {

		SG[i] = !(SG[i - 1] & SG[i - 2]);

		//printf("%d ", SG[i]);

	}

	//puts("");

	if (SG[len]) printf("First\n");

	else printf("Second\n");

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1384429024162153x):
//#pragma GCC optimize("Ofast")

//#pragma GCC target("avx,avx2,fma")



#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

#define pb push_back

#define F first

#define S second

#define ins insert

#define mp make_pair

#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)

#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)

#define bit __builtin_popcount

#define md (l + ((r - l) / 2))

#define all(x) x.begin(),x.end()

#define eb emplace_back

#define ub upper_bound

#define lb lower_bound

#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)



using namespace std;

using namespace __gnu_pbds;



typedef long long ll;

typedef long double ld;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;

const ll MAX = 1e15 + 11;

const int INF1 = 2e9 + 11;

const ll INF2 = 2e18 + 11;

const double INF3 = 1e8 + 11;

const int base = 500;

const int P = 31;

const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};

const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

const double EPS = 1e-4;

const double PI = acos(-1.0);





template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }





typedef pair <int, int> pii;

typedef pair <ll, ll> pll;





mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int n, r, mx;

vector <int> g[N];

void dfs(int v, int pr, int dist) {

    if (mx < dist) {

        mx = dist;

        r = v;

    }

    for (int to : g[v]) {

        if (to != pr) dfs(to, v, dist + 1);

    }

}

main() {

    file("rmq");

    ios;

    cin >> n;

    fo(i, 1, n - 1, 1) {

        int u, v;

        cin >> u >> v;

        g[u].eb(v);

        g[v].eb(u);

    }

    dfs(1, 1, -1);

    mx = -1;

    dfs(r, r, -1);

    if (mx % 3) cout << "First";

    else cout << "Second";

    return 0;

}

/**



*/
// Slower C++ solution:
#include <bits/stdc++.h>

#define maxn 200005

using namespace std;

int n;

vector<int> g[maxn];

int dep[maxn];

int len, id;

bool SG[maxn];

void dfs(int x) {

	if (dep[x] > len) len = dep[x], id = x;

	for (int i = 0; i < g[x].size(); i++) {

		if (!dep[g[x][i]]) {

			dep[g[x][i]] = dep[x] + 1;

			dfs(g[x][i]);

		}

	}

}

int main() {

	scanf("%d", &n);

	memset(dep, 0, sizeof(dep));

	for (int i = 0; i < n - 1; i++) {

		int u, v;

		scanf("%d%d", &u, &v);

		g[u].push_back(v);

		g[v].push_back(u);

	}

	dep[1] = 1;

	dfs(1);

	memset(dep, 0, sizeof(dep));

	dep[id] = 1;

	dfs(id);

	SG[1] = 1; SG[2] = 0;

	for (int i = 3; i <= n; i++) {

		SG[i] = !(SG[i - 1] & SG[i - 2]);

		//printf("%d ", SG[i]);

	}

	//puts("");

	if (SG[len]) printf("First\n");

	else printf("Second\n");

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1425429906387599x):
#include <iostream>

#include <vector>

#define nmax 200005

using namespace std;

int n, nod1, viz1[nmax], viz2[nmax], maxi1, maxi2, nod2;

vector <int> v[nmax];

void dfs1(int nod)

{

    for(auto it=v[nod].begin(); it!=v[nod].end(); ++it)

        if(!viz1[*it])

          {

              viz1[*(it)]=viz1[nod]+1;

              if(maxi1< (viz1[*(it)])) {nod1=*(it); maxi1=viz1[*(it)];}

              dfs1(*it);

          }

}

void dfs2(int nod)

{

    for(auto it=v[nod].begin(); it!=v[nod].end(); ++it)

        if(!viz2[*it])

          {

              viz2[*(it)]=viz2[nod]+1;

              if(maxi2< (viz2[*(it)])) {nod2=*(it); maxi2=viz2[*(it)];}

              dfs2(*it);

          }

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);



    int i, x, y;

    cin>>n;

    for(i=1; i<n; i++)

    {

        cin>>x>>y;

        v[x].push_back(y);

        v[y].push_back(x);

    }

    maxi1=1;

    nod1=1;

    viz1[1]=1;

    dfs1(1);



    viz2[nod1]=1;

    maxi2=1;

    dfs2(nod1);



    if(maxi2%3==2) cout<<"Second\n";

    else cout<<"First\n";

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <cstring>



using namespace std;



vector<int> L[200005];

int n, D, nr, nodMax, uz[200005], dp[200005];



void DFS(int x);



int main()

{

    int x, y;



    cin >> n;

    for (int i=1;i<n;i++)

    {

        cin >> x >> y;

        L[x].push_back(y);

        L[y].push_back(x);

    }

    DFS(1);

    memset(uz,0,sizeof(uz));

    DFS(nodMax);

    dp[0] = 1;

    dp[1] = 0;

    for (int i=2;i<=D;i++)

        dp[i] = (dp[i-2] == 0 || dp[i-1] == 0);

    if (dp[D])

        cout << "First\n";

    else

        cout << "Second\n";

    return 0;

}



void DFS(int x)

{

    uz[x] = 1;

    if (nr > D)

    {

        D = nr;

        nodMax = x;

    }

    for (int i:L[x])

    {

        if (!uz[i])

        {

            nr++;

            DFS(i);

            nr--;

        }

    }

}

// Faster C++ solution for the same problem (measured speedup: 1.1313459629213765x):
#include <iostream>

#include <vector>

#define nmax 200005

using namespace std;

int n, nod1, viz1[nmax], viz2[nmax], maxi1, maxi2, nod2;

vector <int> v[nmax];

void dfs1(int nod)

{

    for(auto it=v[nod].begin(); it!=v[nod].end(); ++it)

        if(!viz1[*it])

          {

              viz1[*(it)]=viz1[nod]+1;

              if(maxi1< (viz1[*(it)])) {nod1=*(it); maxi1=viz1[*(it)];}

              dfs1(*it);

          }

}

void dfs2(int nod)

{

    for(auto it=v[nod].begin(); it!=v[nod].end(); ++it)

        if(!viz2[*it])

          {

              viz2[*(it)]=viz2[nod]+1;

              if(maxi2< (viz2[*(it)])) {nod2=*(it); maxi2=viz2[*(it)];}

              dfs2(*it);

          }

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);



    int i, x, y;

    cin>>n;

    for(i=1; i<n; i++)

    {

        cin>>x>>y;

        v[x].push_back(y);

        v[y].push_back(x);

    }

    maxi1=1;

    nod1=1;

    viz1[1]=1;

    dfs1(1);



    viz2[nod1]=1;

    maxi2=1;

    dfs2(nod1);



    if(maxi2%3==2) cout<<"Second\n";

    else cout<<"First\n";

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define ll long long

using namespace std;

int a,b,n,l,dis[200100],S;

vector<int> G[200100];

void dfs(int u,int f)

{

    dis[u]=dis[f]+1;

    for(int i=0;i<G[u].size();i++){

        if(G[u][i]!=f) dfs(G[u][i],u);

    }

}

int main(){

	ios::sync_with_stdio(false);

	cin >> n;

	for(int i = 1;i < n;i ++){

		cin >> a >> b;

		G[a].push_back(b);

		G[b].push_back(a);

	}

	dfs(1,0);

    for(int i=1;i<=n;i++) if(dis[i]>dis[S]) S=i;  

    dfs(S,0);

    for(int i=1;i<=n;i++) l=max(l,dis[i]-1);

	if(l %3 == 1)

		cout <<"Second"<<endl;

	else

		cout<<"First"<<endl;

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 4.544396700796284x):
#include <bits/stdc++.h>

using namespace std;

#define Maxn 400007

int last[Maxn],pre[Maxn],other[Maxn],cnt=0;

int dis[Maxn];

bool vis[Maxn];

void insert(int u,int v)

{

    other[++cnt]=v,pre[cnt]=last[u],last[u]=cnt;

}

void dfs(int u)

{

    vis[u]=true;

    for (int q=last[u];q;q=pre[q])

    {

        int v=other[q];

        if (!vis[v])

        {

            dis[v]=dis[u]+1;

            dfs(v);

        }

    }

}

int n;

int main()

{

    scanf("%d",&n);

    for (int i=1;i<n;i++)

    {

        int u,v;

        scanf("%d%d",&u,&v);

        insert(u,v),insert(v,u);

    }

    memset(vis,false,sizeof(vis));

    dis[1]=0;

    dfs(1);

    int id=1;

    for (int i=1;i<=n;i++)

        if (dis[i]>dis[id]) id=i;

    memset(vis,false,sizeof(vis));

    dis[id]=0;

    dfs(id);

    int ans=0;

    for (int i=1;i<=n;i++)

        ans=max(ans,dis[i]);

    if (ans%3==1) printf("Second\n"); else printf("First\n");

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

#define maxn 200005

using namespace std;

int n;

vector<int> g[maxn];

int dep[maxn];

int len, id;

bool SG[maxn];

void dfs(int x) {

	if (dep[x] > len) len = dep[x], id = x;

	for (int i = 0; i < g[x].size(); i++) {

		if (!dep[g[x][i]]) {

			dep[g[x][i]] = dep[x] + 1;

			dfs(g[x][i]);

		}

	}

}

int main() {

	scanf("%d", &n);

	memset(dep, 0, sizeof(dep));

	for (int i = 0; i < n - 1; i++) {

		int u, v;

		scanf("%d%d", &u, &v);

		g[u].push_back(v);

		g[v].push_back(u);

	}

	dep[1] = 1;

	dfs(1);

	memset(dep, 0, sizeof(dep));

	dep[id] = 1;

	dfs(id);

	SG[1] = 1; SG[2] = 0;

	for (int i = 3; i <= n; i++) {

		SG[i] = !(SG[i - 1] & SG[i - 2]);

		//printf("%d ", SG[i]);

	}

	//puts("");

	if (SG[len]) printf("First\n");

	else printf("Second\n");

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.192249062669516x):
#include <bits/stdc++.h>

using namespace std;

#define Maxn 400007

int last[Maxn],pre[Maxn],other[Maxn],cnt=0;

int dis[Maxn];

bool vis[Maxn];

void insert(int u,int v)

{

    other[++cnt]=v,pre[cnt]=last[u],last[u]=cnt;

}

void dfs(int u)

{

    vis[u]=true;

    for (int q=last[u];q;q=pre[q])

    {

        int v=other[q];

        if (!vis[v])

        {

            dis[v]=dis[u]+1;

            dfs(v);

        }

    }

}

int n;

int main()

{

    scanf("%d",&n);

    for (int i=1;i<n;i++)

    {

        int u,v;

        scanf("%d%d",&u,&v);

        insert(u,v),insert(v,u);

    }

    memset(vis,false,sizeof(vis));

    dis[1]=0;

    dfs(1);

    int id=1;

    for (int i=1;i<=n;i++)

        if (dis[i]>dis[id]) id=i;

    memset(vis,false,sizeof(vis));

    dis[id]=0;

    dfs(id);

    int ans=0;

    for (int i=1;i<=n;i++)

        ans=max(ans,dis[i]);

    if (ans%3==1) printf("Second\n"); else printf("First\n");

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <cstring>



using namespace std;



vector<int> L[200005];

int n, D, nr, nodMax, uz[200005], dp[200005];



void DFS(int x);



int main()

{

    int x, y;



    cin >> n;

    for (int i=1;i<n;i++)

    {

        cin >> x >> y;

        L[x].push_back(y);

        L[y].push_back(x);

    }

    DFS(1);

    memset(uz,0,sizeof(uz));

    DFS(nodMax);

    dp[0] = 1;

    dp[1] = 0;

    for (int i=2;i<=D;i++)

        dp[i] = (dp[i-2] == 0 || dp[i-1] == 0);

    if (dp[D])

        cout << "First\n";

    else

        cout << "Second\n";

    return 0;

}



void DFS(int x)

{

    uz[x] = 1;

    if (nr > D)

    {

        D = nr;

        nodMax = x;

    }

    for (int i:L[x])

    {

        if (!uz[i])

        {

            nr++;

            DFS(i);

            nr--;

        }

    }

}

// Faster C++ solution for the same problem (measured speedup: 5.14136453828259x):
#include <bits/stdc++.h>

using namespace std;

#define Maxn 400007

int last[Maxn],pre[Maxn],other[Maxn],cnt=0;

int dis[Maxn];

bool vis[Maxn];

void insert(int u,int v)

{

    other[++cnt]=v,pre[cnt]=last[u],last[u]=cnt;

}

void dfs(int u)

{

    vis[u]=true;

    for (int q=last[u];q;q=pre[q])

    {

        int v=other[q];

        if (!vis[v])

        {

            dis[v]=dis[u]+1;

            dfs(v);

        }

    }

}

int n;

int main()

{

    scanf("%d",&n);

    for (int i=1;i<n;i++)

    {

        int u,v;

        scanf("%d%d",&u,&v);

        insert(u,v),insert(v,u);

    }

    memset(vis,false,sizeof(vis));

    dis[1]=0;

    dfs(1);

    int id=1;

    for (int i=1;i<=n;i++)

        if (dis[i]>dis[id]) id=i;

    memset(vis,false,sizeof(vis));

    dis[id]=0;

    dfs(id);

    int ans=0;

    for (int i=1;i<=n;i++)

        ans=max(ans,dis[i]);

    if (ans%3==1) printf("Second\n"); else printf("First\n");

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <vector>

#define nmax 200005

using namespace std;

int n, nod1, viz1[nmax], viz2[nmax], maxi1, maxi2, nod2;

vector <int> v[nmax];

void dfs1(int nod)

{

    for(auto it=v[nod].begin(); it!=v[nod].end(); ++it)

        if(!viz1[*it])

          {

              viz1[*(it)]=viz1[nod]+1;

              if(maxi1< (viz1[*(it)])) {nod1=*(it); maxi1=viz1[*(it)];}

              dfs1(*it);

          }

}

void dfs2(int nod)

{

    for(auto it=v[nod].begin(); it!=v[nod].end(); ++it)

        if(!viz2[*it])

          {

              viz2[*(it)]=viz2[nod]+1;

              if(maxi2< (viz2[*(it)])) {nod2=*(it); maxi2=viz2[*(it)];}

              dfs2(*it);

          }

}

int main()

{

    ios_base::sync_with_stdio(false);

    cin.tie(NULL);



    int i, x, y;

    cin>>n;

    for(i=1; i<n; i++)

    {

        cin>>x>>y;

        v[x].push_back(y);

        v[y].push_back(x);

    }

    maxi1=1;

    nod1=1;

    viz1[1]=1;

    dfs1(1);



    viz2[nod1]=1;

    maxi2=1;

    dfs2(nod1);



    if(maxi2%3==2) cout<<"Second\n";

    else cout<<"First\n";

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.544467127461605x):
#include <bits/stdc++.h>

using namespace std;

#define Maxn 400007

int last[Maxn],pre[Maxn],other[Maxn],cnt=0;

int dis[Maxn];

bool vis[Maxn];

void insert(int u,int v)

{

    other[++cnt]=v,pre[cnt]=last[u],last[u]=cnt;

}

void dfs(int u)

{

    vis[u]=true;

    for (int q=last[u];q;q=pre[q])

    {

        int v=other[q];

        if (!vis[v])

        {

            dis[v]=dis[u]+1;

            dfs(v);

        }

    }

}

int n;

int main()

{

    scanf("%d",&n);

    for (int i=1;i<n;i++)

    {

        int u,v;

        scanf("%d%d",&u,&v);

        insert(u,v),insert(v,u);

    }

    memset(vis,false,sizeof(vis));

    dis[1]=0;

    dfs(1);

    int id=1;

    for (int i=1;i<=n;i++)

        if (dis[i]>dis[id]) id=i;

    memset(vis,false,sizeof(vis));

    dis[id]=0;

    dfs(id);

    int ans=0;

    for (int i=1;i<=n;i++)

        ans=max(ans,dis[i]);

    if (ans%3==1) printf("Second\n"); else printf("First\n");

    return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<algorithm>

#include<cstring>

#include<queue>

#include<vector>

#define SIZE 200010



using namespace std;



int n;

int dis[SIZE];

bool vis[SIZE];

vector<int> rec[SIZE];



struct d

{

    int id,dist;

};

int bfs(int from)

{

    int i;

    d tmp;

    queue<d> que;

  //  dis[from]=0;

    que.push({from,1});

    vis[from]=true;

    while(!que.empty())

    {

        tmp=que.front();

    //    printf("id=%d\n",tmp.id);

        que.pop();

        dis[tmp.id]=tmp.dist;

        for(i=rec[tmp.id].size()-1;i>=0;i--)

        {

            if(!vis[rec[tmp.id][i]])

            {

                vis[rec[tmp.id][i]]=true;

                que.push({rec[tmp.id][i],tmp.dist+1});

            }

        }

    }

    return tmp.id;

}



int main()

{

    int i;

    int a,b;

    scanf("%d",&n);

    for(i=1;i<n;i++)

    {

        scanf("%d%d",&a,&b);

        rec[a].push_back(b);

        rec[b].push_back(a);

    }

    int pos=bfs(1);

    memset(vis,false,sizeof(vis));

    pos=bfs(pos);

    if((dis[pos]+1)%3==0)

        puts("Second");

    else

        puts("First");

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.6609392032152424x):
#include <bits/stdc++.h>



using namespace std;

struct Edge {

    int next, to;

} edge[200005 << 1];

int head[200005], n, ss, vis[200005], minn;



inline void add(int x, int y) {

    static int cnt = 1;

    edge[cnt].to = y, edge[cnt].next = head[x], head[x] = cnt++;

}



void DFS(int x, int s) {

    if (s > minn)minn = s, ss = x;

    for (int i = head[x]; i; i = edge[i].next) {

        if (vis[edge[i].to] == 0)vis[edge[i].to] = 1, DFS(edge[i].to, s + 1);

    }

}



queue<int> que;



int main() {

    cin >> n;

    for (int i = 1, x, y; i < n; i++) {

        cin >> x >> y;

        add(x, y), add(y, x);

    }

    DFS(1, 0), minn = 0, memset(vis, 0, sizeof(vis)), DFS(ss, 0);

    if ((minn + 1) % 3 == 2)cout << "Second";

    else cout << "First";

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

 

typedef long long LL;

typedef pair<int, int> PII;

typedef vector<int> VI;



#define MP make_pair

#define PB push_back

#define X first

#define Y second

 

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)

#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)

#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define ALL(a) a.begin(), a.end()

#define SZ(a) (int)((a).size())

#define FILL(a, value) memset(a, value, sizeof(a))

#define debug(a) cout << #a << " = " << a << endl;



const double PI = acos(-1.0);

const LL INF = 1e9 + 47;

const LL LINF = INF * INF;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



const int N = 1 << 18;

int n;

VI g[N];

char used[N];

int d[N];



void bfs(int v)

{

	FILL(used, 0);

	used[v] = 1;

	d[v] = 0;

	queue<int> q;

	q.push(v);

	

	while(!q.empty())

	{

		v = q.front();

		q.pop();

		for(auto i: g[v])

			if (!used[i])

			{

				used[i] = 1;

				d[i] = d[v] + 1;

				q.push(i);

			}

	}

}



int main()

{

	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	//freopen("In.txt", "r", stdin);

	//freopen("In.txt", "w", stdout);

	

	cin >> n;

	FOR(i, 0, n - 1)

	{

		int u, v;

		cin >> u >> v;

		g[u].PB(v);

		g[v].PB(u);

	}

	

	bfs(1);

	int mx = 1;

	FOR(i, 2, n + 1)

		if (d[i] > d[mx])

			mx = i;

	

	bfs(mx);

	mx = 1;

	FOR(i, 2, n + 1)

		if (d[i] > d[mx])

			mx = i;

	

	mx = d[mx];

//	debug(mx)

	if (mx % 3 == 1)

		cout << "Second" << endl;

	else

		cout << "First" << endl;

		

	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.3447750732641737x):
#include <bits/stdc++.h>



using namespace std;

vector<int> g[200001];

int mx  = 0 , vert = 1;

void dfs(int cur , int len = 0, int p = -1) {

    if(len > mx) {

        mx = len;

        vert = cur;

    }

    for(auto to : g[cur]) {

        if(to != p)

            dfs(to , len + 1 , cur);

    }

}



int main() {

    int n;

    cin >> n;

    for(int i = 1; i < n; i ++) {

        int a , b;

        cin >> a >> b;

        g[a].push_back(b);

        g[b].push_back(a);

    }

    dfs(1);

    mx = 0;

    dfs(vert);

    if(mx % 3 == 1)

        cout << "Second";

    else

        cout << "First";

    return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<algorithm>

#include<cstring>

#include<queue>

#include<vector>

#define SIZE 200010



using namespace std;



int n;

int dis[SIZE];

bool vis[SIZE];

vector<int> rec[SIZE];



struct d

{

    int id,dist;

};

int bfs(int from)

{

    int i;

    d tmp;

    queue<d> que;

  //  dis[from]=0;

    que.push({from,1});

    vis[from]=true;

    while(!que.empty())

    {

        tmp=que.front();

    //    printf("id=%d\n",tmp.id);

        que.pop();

        dis[tmp.id]=tmp.dist;

        for(i=rec[tmp.id].size()-1;i>=0;i--)

        {

            if(!vis[rec[tmp.id][i]])

            {

                vis[rec[tmp.id][i]]=true;

                que.push({rec[tmp.id][i],tmp.dist+1});

            }

        }

    }

    return tmp.id;

}



int main()

{

    int i;

    int a,b;

    scanf("%d",&n);

    for(i=1;i<n;i++)

    {

        scanf("%d%d",&a,&b);

        rec[a].push_back(b);

        rec[b].push_back(a);

    }

    int pos=bfs(1);

    memset(vis,false,sizeof(vis));

    pos=bfs(pos);

    if((dis[pos]+1)%3==0)

        puts("Second");

    else

        puts("First");

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 6.710230476075078x):
#include<bits/stdc++.h>

using namespace std;

const int maxn = 2e5 + 7;

int n;



int fir[maxn], nxt[2 * maxn], to[2 * maxn], e = 0;

void add(int x, int y) {

	to[++e] = y; nxt[e] = fir[x]; fir[x] = e;

	to[++e] = x; nxt[e] = fir[y]; fir[y] = e;

}



int dp[maxn];

int dfs(int pos, int f) {

	int y, z, rs = pos, d;

	for (y = fir[pos]; y; y = nxt[y]) {

		if((z = to[y]) == f) continue;

		dp[z] = dp[pos] + 1;

		d = dfs(z, pos);

		if(dp[d] > dp[rs]) rs = d;

	}

	return rs;

}



int main() {

	scanf("%d", &n);

	int x, y;

	for (int i = 1; i < n; ++i) {

		scanf("%d%d", &x, &y);

		add(x, y);

	}

	dp[1] = 0;

	x = dfs(1, 0);

	dp[x] = 0;

	y = dfs(x, 0);

	//printf("%d %d\n", x, y);

	if(dp[y] % 3 == 1) printf("Second\n");

	else printf("First\n");

	return 0;

}