stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <vector>

#include <algorithm>

#include <queue>

#include <set>

#include <string>

#include <cmath>

#include <map>

#include <iomanip>

#include <tuple>

#include <functional>

#define INF 1000000009

#define LINF 1000000000000000009

#define double long double

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

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

typedef pair<P, ll> PP;

template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }

template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }

ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }

ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }



vector<vector<int>> graph(200010, vector<int>());

vector<int> x(200010), y(200010);



void dfs(int n, int par, int dis, int flag) {

	if(flag) x[n] = dis;

	else y[n] = dis;

	for (auto i : graph[n]) {

		if (i != par) {

			dfs(i, n, dis + 1, flag);

		}

	}

}



int main() {

	int n;

	cin >> n;

	vector<int> a(n), b(n);

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

		cin >> a[i] >> b[i];

		a[i]--; b[i]--;

		graph[a[i]].push_back(b[i]);

		graph[b[i]].push_back(a[i]);

	}

	dfs(0, -1, 0, 1);

	int p = -1, d = -1;

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

		if (x[i] > d) {

			p = i; d = x[i];

		}

	}

	dfs(p, -1, 0, 0);

	int ans = 0;

	for (auto i : y) chmax(ans, i);

	cout << (ans % 3 == 1 ? "Second" : "First") << endl;

}

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

#include <vector>

#include <algorithm>

#include <queue>

#include <set>

#include <string>

#include <cmath>

#include <map>

#include <iomanip>

#include <tuple>

#include <functional>

#define INF 1000000009

#define LINF 1000000000000000009

#define double long double

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

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

typedef pair<P, ll> PP;

template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }

template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }

ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }

ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }



vector<vector<int>> graph(200010, vector<int>());



void dfs(int n, int par, int dis, vector<int> &res) {

	res[n] = dis;

	for (auto i : graph[n]) {

		if (i != par) {

			dfs(i, n, dis + 1, res);

		}

	}

}



int main() {

	int n;

	cin >> n;

	vector<int> a(n), b(n);

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

		cin >> a[i] >> b[i];

		a[i]--; b[i]--;

		graph[a[i]].push_back(b[i]);

		graph[b[i]].push_back(a[i]);

	}

	vector<int> x(n), y(n);

	dfs(0, -1, 0, x);

	int p = -1, d = -1;

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

		if (x[i] > d) {

			p = i; d = x[i];

		}

	}

	dfs(p, -1, 0, y);

	int ans = 0;

	for (auto i : y) chmax(ans, i);

	cout << (ans % 3 == 1 ? "Second" : "First") << endl;

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

#include <iostream>

#include <algorithm>

#include <cstring>

#include <vector>

using namespace std;



const int maxn = 2e5+100;



vector<int> f[maxn];

int id1,dth,id2;

void dfs(int u,int fa,int deep)

{

	if(deep>dth) {

		dth = deep; id1=u;

	}

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

	{

		int v=f[u][i];

		if(v==fa) continue;

		dfs(v,u,deep+1);

	}

}

int n,x,y;

int main()

{

	ios::sync_with_stdio(false);

	cin>>n;

	if(n==1){

		cout<<"First"<<endl;

		return 0;

	}

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

	{

		cin>>x>>y;

		f[x].push_back(y);

		f[y].push_back(x);

	}

	dfs(1,-1,1);dth=0;

	dfs(id1,-1,1);

	if(dth%3==2) cout<<"Second"<<endl;

	else cout<<"First"<<endl;

	return 0;

}

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

using namespace std;



int fst[433333], nxt[433333], tot = 0;



struct qer

{

    int f, t;

} es[433333];



void build(int f, int t)

{

    es[++tot] = (qer){f, t};

    nxt[tot] = fst[f];

    fst[f] = tot;

}



int ans = 0, st = 0;



void dfs(int u, int fa, int len)

{

    if (len > ans)

        st = u, ans = len;

    for (int i = fst[u]; i; i = nxt[i])

        if (es[i].t != fa)

            dfs(es[i].t, u, len + 1);

}



int main()

{

    int n;

    cin >> n;

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

    {

        int f, t;

        scanf("%d%d", &f, &t);

        build(f, t);

        build(t, f);

    }

    dfs(1, 0, 0);

    ans = 0;

    dfs(st, 0, 0);

    if (ans % 3 == 1)

        puts("Second");

    else

        puts("First");

    return 0;

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

#include <iostream>

#include <algorithm>

#include <cstring>

#include <vector>

using namespace std;



const int maxn = 2e5+100;



vector<int> f[maxn];

int id1,dth,id2;

void dfs(int u,int fa,int deep)

{

	if(deep>dth) {

		dth = deep; id1=u;

	}

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

	{

		int v=f[u][i];

		if(v==fa) continue;

		dfs(v,u,deep+1);

	}

}

int n,x,y;

int main()

{

	ios::sync_with_stdio(false);

	cin>>n;

	if(n==1){

		cout<<"First"<<endl;

		return 0;

	}

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

	{

		cin>>x>>y;

		f[x].push_back(y);

		f[y].push_back(x);

	}

	dfs(1,-1,1);dth=0;

	dfs(id1,-1,1);

	if(dth%3==2) cout<<"Second"<<endl;

	else cout<<"First"<<endl;

	return 0;

}

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

#include<cstdio>

#include<cmath>

#include<algorithm>

#include<cstdlib>

#include<cstring>

#include<string>

#include<iomanip>

#include<queue>



using namespace std;



#define N 400040

struct edge{

	int v, next;

}e[N];

int head[N];

int vis[N];

int n, len, depth, depid;

void add_edge(int u, int v){

	e[len].v = v;

	e[len].next = head[u];

	head[u] = len++;

}

void dfs(int now, int d){

	if(depth < d){

		depth = d;

		depid = now;

	}

	int i;

	vis[now] = 1;

	for(i = head[now]; i != -1; i =e[i].next){

		int v = e[i].v;

		if(vis[v]) continue;

		dfs(v, d + 1);

	}

	return ;

}



int main(){

	int i,u,v;

	memset(head, -1, sizeof(head));

	len = 0;

	cin>>n;

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

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

		add_edge(u, v);

		add_edge(v, u);

	}

	depth = 0;

	dfs(1, 1);

	memset(vis, 0, sizeof(vis));

	depth = 0;

	dfs(depid, 1);

	if(depth % 3 == 2){

		printf("Second\n");

	}

	else printf("First\n");



	return 0;

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

#include <iostream>

#include <algorithm>

#include <cstring>

#include <vector>

using namespace std;



const int maxn = 2e5+100;



vector<int> f[maxn];

int id1,dth,id2;

void dfs(int u,int fa,int deep)

{

	if(deep>dth) {

		dth = deep; id1=u;

	}

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

	{

		int v=f[u][i];

		if(v==fa) continue;

		dfs(v,u,deep+1);

	}

}

int n,x,y;

int main()

{

	ios::sync_with_stdio(false);

	cin>>n;

	if(n==1){

		cout<<"First"<<endl;

		return 0;

	}

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

	{

		cin>>x>>y;

		f[x].push_back(y);

		f[y].push_back(x);

	}

	dfs(1,-1,1);dth=0;

	dfs(id1,-1,1);

	if(dth%3==2) cout<<"Second"<<endl;

	else cout<<"First"<<endl;

	return 0;

}

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

#include <cstdlib>

#include <cstring>

#include <cstdio>

using namespace std;

#define ll long long 

int read(){

	int x=0,f=1;char ch=getchar();

	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}

	while(ch>='0'&&ch<='9'){x=x*10+ch-48,ch=getchar();}

	return x*f;

}

const int maxn = 200100;

struct edge{int to,next;}e[maxn*2];

int tot,head[maxn];

void add(int u,int v){

	e[++tot].to=v;

	e[tot].next=head[u];

	head[u]=tot;

}

int deep[maxn],f[maxn];

void dfs(int u,int fa){

	for(int i=head[u];i;i=e[i].next){

		int to=e[i].to;

		if(to==fa) continue;

		deep[to]=deep[u]+1;

		dfs(to,u);

	}

}

int main(){

	

	int n=read();

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

		int a=read(),b=read();

		add(a,b);add(b,a);

	}

	dfs(1,0);

	int mx=0;

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

		if(deep[i]>deep[mx]) mx=i;

	}

	memset(deep,0,sizeof deep);

	deep[mx]=1;

	dfs(mx,0);

	int len=0;

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

		if(deep[i]>len) len=deep[i];

	}

	

	f[0]=1,f[1]=1,f[2]=0;

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

		if((f[i-1])&&(f[i-2])) f[i]=0;

		else f[i]=1;

	}

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

	else printf("Second\n");

	return 0;

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

#include<cstdio>

#include<cmath>

#include<algorithm>

#include<cstdlib>

#include<cstring>

#include<string>

#include<iomanip>

#include<queue>



using namespace std;



#define N 400040

struct edge{

	int v, next;

}e[N];

int head[N];

int vis[N];

int n, len, depth, depid;

void add_edge(int u, int v){

	e[len].v = v;

	e[len].next = head[u];

	head[u] = len++;

}

void dfs(int now, int d){

	if(depth < d){

		depth = d;

		depid = now;

	}

	int i;

	vis[now] = 1;

	for(i = head[now]; i != -1; i =e[i].next){

		int v = e[i].v;

		if(vis[v]) continue;

		dfs(v, d + 1);

	}

	return ;

}



int main(){

	int i,u,v;

	memset(head, -1, sizeof(head));

	len = 0;

	cin>>n;

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

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

		add_edge(u, v);

		add_edge(v, u);

	}

	depth = 0;

	dfs(1, 1);

	memset(vis, 0, sizeof(vis));

	depth = 0;

	dfs(depid, 1);

	if(depth % 3 == 2){

		printf("Second\n");

	}

	else printf("First\n");



	return 0;

}


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

#include <cstdlib>

#include <cstring>

#include <cstdio>

using namespace std;

#define ll long long 

int read(){

	int x=0,f=1;char ch=getchar();

	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}

	while(ch>='0'&&ch<='9'){x=x*10+ch-48,ch=getchar();}

	return x*f;

}

const int maxn = 200100;

struct edge{int to,next;}e[maxn*2];

int tot,head[maxn];

void add(int u,int v){

	e[++tot].to=v;

	e[tot].next=head[u];

	head[u]=tot;

}

int deep[maxn],f[maxn];

void dfs(int u,int fa){

	for(int i=head[u];i;i=e[i].next){

		int to=e[i].to;

		if(to==fa) continue;

		deep[to]=deep[u]+1;

		dfs(to,u);

	}

}

int main(){

	

	int n=read();

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

		int a=read(),b=read();

		add(a,b);add(b,a);

	}

	dfs(1,0);

	int mx=0;

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

		if(deep[i]>deep[mx]) mx=i;

	}

	memset(deep,0,sizeof deep);

	deep[mx]=1;

	dfs(mx,0);

	int len=0;

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

		if(deep[i]>len) len=deep[i];

	}

	

	f[0]=1,f[1]=1,f[2]=0;

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

		if((f[i-1])&&(f[i-2])) f[i]=0;

		else f[i]=1;

	}

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

	else printf("Second\n");

	return 0;

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

#include <iostream>

#include <algorithm>

#include <cstring>

#include <vector>

using namespace std;



const int maxn = 2e5+100;



vector<int> f[maxn];

int id1,dth,id2;

void dfs(int u,int fa,int deep)

{

	if(deep>dth) {

		dth = deep; id1=u;

	}

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

	{

		int v=f[u][i];

		if(v==fa) continue;

		dfs(v,u,deep+1);

	}

}

int n,x,y;

int main()

{

	ios::sync_with_stdio(false);

	cin>>n;

	if(n==1){

		cout<<"First"<<endl;

		return 0;

	}

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

	{

		cin>>x>>y;

		f[x].push_back(y);

		f[y].push_back(x);

	}

	dfs(1,-1,1);dth=0;

	dfs(id1,-1,1);

	if(dth%3==2) cout<<"Second"<<endl;

	else cout<<"First"<<endl;

	return 0;

}

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

#define maxn 200005



using namespace std;



struct edge{

    int to,next;

}edge[maxn*2];

int head[maxn];int top = 1;

int n;



void add(int s,int t)

{

    edge[top].next = head[s];

    edge[top].to = t;

    head[s] = top;

    top++;

}



int maxx,ii;

bool vis[maxn];

void DFS(int s,int step)

{

    if(step > maxx){

        maxx = step;

        ii = s;

    }

    vis[s] = 1;

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

        if(!vis[edge[i].to])DFS(edge[i].to,step+1);

}



int main()

{

    int a,b;

    cin >> n;

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

    {

        cin >> a >> b;

        add(a,b);

        add(b,a);

    }

    DFS(1,0);

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

        vis[i] = 0;

    DFS(ii,0);

    maxx++;

    if(maxx % 3 == 2)cout << "Second" << endl;

    else cout << "First" << endl;

    return 0;

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

#include<cstdio>

#include<cmath>

#include<algorithm>

#include<cstdlib>

#include<cstring>

#include<string>

#include<iomanip>

#include<queue>



using namespace std;



#define N 400040

struct edge{

	int v, next;

}e[N];

int head[N];

int vis[N];

int n, len, depth, depid;

void add_edge(int u, int v){

	e[len].v = v;

	e[len].next = head[u];

	head[u] = len++;

}

void dfs(int now, int d){

	if(depth < d){

		depth = d;

		depid = now;

	}

	int i;

	vis[now] = 1;

	for(i = head[now]; i != -1; i =e[i].next){

		int v = e[i].v;

		if(vis[v]) continue;

		dfs(v, d + 1);

	}

	return ;

}



int main(){

	int i,u,v;

	memset(head, -1, sizeof(head));

	len = 0;

	cin>>n;

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

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

		add_edge(u, v);

		add_edge(v, u);

	}

	depth = 0;

	dfs(1, 1);

	memset(vis, 0, sizeof(vis));

	depth = 0;

	dfs(depid, 1);

	if(depth % 3 == 2){

		printf("Second\n");

	}

	else printf("First\n");



	return 0;

}


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

#define maxn 200005



using namespace std;



struct edge{

    int to,next;

}edge[maxn*2];

int head[maxn];int top = 1;

int n;



void add(int s,int t)

{

    edge[top].next = head[s];

    edge[top].to = t;

    head[s] = top;

    top++;

}



int maxx,ii;

bool vis[maxn];

void DFS(int s,int step)

{

    if(step > maxx){

        maxx = step;

        ii = s;

    }

    vis[s] = 1;

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

        if(!vis[edge[i].to])DFS(edge[i].to,step+1);

}



int main()

{

    int a,b;

    cin >> n;

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

    {

        cin >> a >> b;

        add(a,b);

        add(b,a);

    }

    DFS(1,0);

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

        vis[i] = 0;

    DFS(ii,0);

    maxx++;

    if(maxx % 3 == 2)cout << "Second" << endl;

    else cout << "First" << endl;

    return 0;

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

#include <cstdlib>

#include <cstring>

#include <cstdio>

using namespace std;

#define ll long long 

int read(){

	int x=0,f=1;char ch=getchar();

	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}

	while(ch>='0'&&ch<='9'){x=x*10+ch-48,ch=getchar();}

	return x*f;

}

const int maxn = 200100;

struct edge{int to,next;}e[maxn*2];

int tot,head[maxn];

void add(int u,int v){

	e[++tot].to=v;

	e[tot].next=head[u];

	head[u]=tot;

}

int deep[maxn],f[maxn];

void dfs(int u,int fa){

	for(int i=head[u];i;i=e[i].next){

		int to=e[i].to;

		if(to==fa) continue;

		deep[to]=deep[u]+1;

		dfs(to,u);

	}

}

int main(){

	

	int n=read();

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

		int a=read(),b=read();

		add(a,b);add(b,a);

	}

	dfs(1,0);

	int mx=0;

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

		if(deep[i]>deep[mx]) mx=i;

	}

	memset(deep,0,sizeof deep);

	deep[mx]=1;

	dfs(mx,0);

	int len=0;

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

		if(deep[i]>len) len=deep[i];

	}

	

	f[0]=1,f[1]=1,f[2]=0;

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

		if((f[i-1])&&(f[i-2])) f[i]=0;

		else f[i]=1;

	}

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

	else printf("Second\n");

	return 0;

}

  

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

#define maxn 200005



using namespace std;



struct edge{

    int to,next;

}edge[maxn*2];

int head[maxn];int top = 1;

int n;



void add(int s,int t)

{

    edge[top].next = head[s];

    edge[top].to = t;

    head[s] = top;

    top++;

}



int maxx,ii;

bool vis[maxn];

void DFS(int s,int step)

{

    if(step > maxx){

        maxx = step;

        ii = s;

    }

    vis[s] = 1;

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

        if(!vis[edge[i].to])DFS(edge[i].to,step+1);

}



int main()

{

    int a,b;

    cin >> n;

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

    {

        cin >> a >> b;

        add(a,b);

        add(b,a);

    }

    DFS(1,0);

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

        vis[i] = 0;

    DFS(ii,0);

    maxx++;

    if(maxx % 3 == 2)cout << "Second" << endl;

    else cout << "First" << endl;

    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(){

	scanf("%d",&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) printf("Second\n"); 

	else	printf("First\n");

    return 0;

}


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

#define maxn 200005



using namespace std;



struct edge{

    int to,next;

}edge[maxn*2];

int head[maxn];int top = 1;

int n;



void add(int s,int t)

{

    edge[top].next = head[s];

    edge[top].to = t;

    head[s] = top;

    top++;

}



int maxx,ii;

bool vis[maxn];

void DFS(int s,int step)

{

    if(step > maxx){

        maxx = step;

        ii = s;

    }

    vis[s] = 1;

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

        if(!vis[edge[i].to])DFS(edge[i].to,step+1);

}



int main()

{

    int a,b;

    cin >> n;

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

    {

        cin >> a >> b;

        add(a,b);

        add(b,a);

    }

    DFS(1,0);

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

        vis[i] = 0;

    DFS(ii,0);

    maxx++;

    if(maxx % 3 == 2)cout << "Second" << endl;

    else cout << "First" << endl;

    return 0;

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

  #include <algorithm>

  #include <vector>

  #include <cmath>

#include <string>

  #include <set>

  #include <map>

  #include <unordered_map>

  #include <iomanip>

  #include <stack>

  #include <queue>

  #include <deque>

  using namespace std;

  vector <int> g[200005];

  bool used[200005];

  int dst[200005];

  void solve(int k){

      for (int i = 0; i <= 200005; i++) {

          dst[i] = -1;

          used[i]=0;

      }

      queue <int> q;

      q.push(k);

      used[k] = true;

      dst[k] = 0;

      while (!q.empty()) {

          int cur = q.front();

          q.pop();

          for (int neighbor: g[cur]) {

              if (!used[neighbor]) {

                  q.push(neighbor);

                  used[neighbor] = true;

                  dst[neighbor] = dst[cur] + 1;

              }

          }

      }

  }

    int main(){

        int n;

        cin>>n;

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

            int x,y;

            cin>>x>>y;

            g[x].push_back(y);

            g[y].push_back(x);

        }

        solve(1);

        int mx=0;

        int pos=1;

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

            if(dst[i]>mx){

                mx=dst[i];

                pos=i;

            }

        }

        solve(pos);

        mx=0;

        pos=1;

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

            if(dst[i]>mx){

                mx=dst[i];

                pos=i;

            }

        }

        if(mx%3==1){

            cout<<"Second";

            return 0;

        }

        cout<<"First";

        return 0;

}


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

#define x first

#define y second

#define pb push_back

#define ppb pop_back

#define mp make_pair

#define ins insert

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

#define sz(v) (int)v.size()

#define up_b upper_bound

#define low_b lower_bound

#define rep(i,a,b) for(ll i=a;i<=b;i++)

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

#define boost ios_base::sync_with_stdio(NULL),cin.tie(NULL),cout.tie(NULL)

#define nl '\n'



using namespace std;



typedef long long ll;

typedef long double ld;

typedef pair<int,int> pii;

typedef pair<ll,int> pli;

typedef pair<int,ll> pil;

typedef pair<ll,ll> pll;

typedef vector<int> vi;

typedef vector<pii> vii;



const int N=200001;

const int MXN=1000001;

const int inf=1e9;

const ll INF=1e18;



vi g[N];

int d[N];



void dfs(int v,int p){

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

  for(int i=0;i<sz(g[v]);i++){

    int to=g[v][i];

    if(to==p)continue;

    dfs(to,v);

  }

}



int main(){

  boost;

  int n;

  cin>>n;

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

    int u,v;

    cin>>u>>v;

    g[u].pb(v);

    g[v].pb(u);

  }

  dfs(1,1);

  int len=0,u=0;

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

    if(len<d[i]){

      len=d[i];

      u=i;

    }

    d[i]=0;

  }

  dfs(u,u);

  int D=0;

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

    D=max(D,d[i]);

  }

  D--;

  if(D%3==1)cout<<"Second";

  else cout<<"First";

  return 0;

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

  #include <algorithm>

  #include <vector>

  #include <cmath>

#include <string>

  #include <set>

  #include <map>

  #include <unordered_map>

  #include <iomanip>

  #include <stack>

  #include <queue>

  #include <deque>

  using namespace std;

  vector <int> g[200005];

  bool used[200005];

  int dst[200005];

  void solve(int k){

      for (int i = 0; i <= 200005; i++) {

          dst[i] = -1;

          used[i]=0;

      }

      queue <int> q;

      q.push(k);

      used[k] = true;

      dst[k] = 0;

      while (!q.empty()) {

          int cur = q.front();

          q.pop();

          for (int neighbor: g[cur]) {

              if (!used[neighbor]) {

                  q.push(neighbor);

                  used[neighbor] = true;

                  dst[neighbor] = dst[cur] + 1;

              }

          }

      }

  }

    int main(){

        int n;

        cin>>n;

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

            int x,y;

            cin>>x>>y;

            g[x].push_back(y);

            g[y].push_back(x);

        }

        solve(1);

        int mx=0;

        int pos=1;

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

            if(dst[i]>mx){

                mx=dst[i];

                pos=i;

            }

        }

        solve(pos);

        mx=0;

        pos=1;

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

            if(dst[i]>mx){

                mx=dst[i];

                pos=i;

            }

        }

        if(mx%3==1){

            cout<<"Second";

            return 0;

        }

        cout<<"First";

        return 0;

}


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

#include <queue>

#include <vector>

#include <set>

#include <algorithm>

#define pll pair<ll,ll>

#define NMAX 200001



using namespace std;

typedef long long ll;

typedef long double ld;

int dist[NMAX];

bool win[NMAX];

vector<int>v[NMAX];

void DFS(int nod)

{

    for(auto &vec:v[nod])

    {

        if(dist[vec]==0)

        {

            dist[vec]=dist[nod]+1;

            DFS(vec);

        }

    }

}

int main()

{

    ios::sync_with_stdio(false);

    int x,y,i,n;

    cin>>n;

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

    {

        cin>>x>>y;

        v[x].push_back(y);

        v[y].push_back(x);

    }

    dist[1]=1;

    DFS(1);

    x=1;

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

    {

        if(dist[i]>dist[x])

        {

            dist[x]=0;

            x=i;

            continue;

        }

        dist[i]=0;

    }

    dist[x]=1;

    DFS(x);

    int ma=0;

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

    {

        ma=max(ma,dist[i]);

    }

    win[0]=0;

    win[1]=1;

    win[2]=0;

    for(int i=3;i<=ma;i++)

    {

        if(!win[i-1] || !win[i-2])

            win[i]=1;

        else

            win[i]=0;

    }

    if(win[ma]==1)

    {

        cout<<"First"<<'\n';

    }

    else

    {

        cout<<"Second"<<'\n';

    }

    

    return 0;

}