stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#define st first

#define nd second



using namespace std;



void debug_out() { cerr << endl; }

template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}

template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }

template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }

template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }

template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }

template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}



#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)

#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)

#define dbg_ok cerr<<"OK!\n"



const int N = 200100;

int n, op, maxd, a, b;

vector <int> v[N];



void dfs(int node, int d = 1, int t = -1) {



	if(d > maxd) {

		maxd = d; 

		op = node;

	}



	for(auto i : v[node])

		if(i != t)

			dfs(i, d + 1, node);

}



int main() {

	ios_base::sync_with_stdio(false);

	cin >> n;

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

		cin >> a >> b;

		v[a].push_back(b);

		v[b].push_back(a);

	}



	maxd = 0;

	dfs(1);

	maxd = 0;

	dfs(op);

	cout << (maxd % 3 != 2 ? "First" : "Second") << '\n';

}	






// Optimized solution to the same problem (faster):
#include<bits/stdc++.h> 

const int maxn=202020;

struct Edge{

	int to;

	int last;

}a[maxn<<1];

int n,m;

int tot;

int d[maxn];

int head[maxn];

inline void HA(int x,int y)

{

	a[++tot]={y,head[x]};

	head[x]=tot;

	a[++tot]={x,head[y]};

	head[y]=tot;

}

#define y a[i].to

inline void Dfs(int x,int prt){

	for(int i=head[x];i;i=a[i].last)

		if(y!=prt)d[y]=d[x]+1,Dfs(y,x);

	if(d[x]>d[m])m=x;

}

#undef y

int main()

{

	scanf("%d",&n);

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

	{

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

		HA(x,y);

	}

	m=0,Dfs(1,0);

	int temp=m;d[m]=0;

	m=0,Dfs(temp,0);

	puts(d[m]%3==1 ? "Second" : "First");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



int D[200001];

vector<int> E[200001];

void dfs(int A, int B) {

	if (D[A] == 0) {

		D[A] = B;

		for (int i : E[A]) {

			dfs(i, B + 1);

		}

	}

}





int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N;

	cin >> N;

	rep(i, N - 1) {

		int a, b;

		cin >> a >> b;

		E[a].pb(b);

		E[b].pb(a);

	}



	dfs(1, 1);



	int saidai = 0;

	int k;

	rep1(i, N) {

		if (saidai < D[i]) {

			saidai = D[i];

			k = i;

		}

	}

	rep1(i, N) D[i] = 0;



	dfs(k, 1);



	saidai = 0;

	rep1(i, N) {

		if (saidai < D[i]) {

			saidai = D[i];

		}

	}



	saidai++;



	if (saidai % 3 == 0) co("Second");

	else co("First");



	Would you please return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



bool D1[200001], D2[200001];

int K, saidai1, saidai2;

pair<int, int> E[400001];

int H[200001];

void dfs1(int A, int B) {

	if (*(D1 + A) == false) {

		*(D1 + A) = true;

		if (B > saidai1) {

			saidai1 = B;

			K = A;

		}

		for (int k = *(H + A); k; k = (*(E + k)).second) {

			dfs1((*(E + k)).first, B + 1);

		}

	}

}

void dfs2(int A, int B) {

	if (*(D2 + A) == false) {

		*(D2 + A) = true;

		saidai2 = max(saidai2, B);

		for (int k = *(H + A); k; k = (*(E + k)).second) {

			dfs2((*(E + k)).first, B + 1);

		}

	}

}



const int cm = 1 << 17;

char cn[cm], *ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline int getint() {

	int A = 0;

	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N = getint();

	int k = 1;

	rep(i, N - 1) {

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

		*(E + k) = mp(a, *(H + b));

		*(H + b) = k++;

		*(E + k) = mp(b, *(H + a));

		*(H + a) = k++;

	}



	dfs1(1, 1);

	dfs2(K, 1);

	saidai2++;



	if (saidai2 % 3 == 0) co("Second");

	else co("First");



	Would you please return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



int D[200001];

pair<int, int> E[400001];

int H[200001];

void dfs(int A, int B) {

	if (D[A] == 0) {

		D[A] = B;

		for (int k = H[A]; k; k = E[k].second) {

			dfs(E[k].first, B + 1);

		}

	}

}





int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N;

	cin >> N;

	int k = 1;

	rep(i, N - 1) {

		int a, b;

		cin >> a >> b;

		E[k] = mp(a, H[b]);

		H[b] = k;

		k++;

		E[k] = mp(b, H[a]);

		H[a] = k;

		k++;

	}



	dfs(1, 1);

	int saidai = 0;

	rep1(i, N) {

		if (saidai < D[i]) {

			saidai = D[i];

			k = i;

		}

	}



	memset(D, 0, sizeof(D));

	dfs(k, 1);

	saidai = 0;

	rep1(i, N) saidai = max(saidai, D[i]);

	saidai++;



	if (saidai % 3 == 0) co("Second");

	else co("First");



	cin >> N;



	Would you please return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)

#define rep1(i, n) for(int i = 1; i <= (n); i++)

#define co(x) cout << (x) << "\n"

#define cosp(x) cout << (x) << " "

#define ce(x) cerr << (x) << "\n"

#define cesp(x) cerr << (x) << " "

#define pb push_back

#define mp make_pair

#define Would

#define you

#define please



bool D1[200001], D2[200001];

int K, saidai1, saidai2;

pair<int, int> E[400001];

int H[200001];

void dfs1(int A, int B) {

	if (*(D1 + A) == false) {

		*(D1 + A) = true;

		if (B > saidai1) {

			saidai1 = B;

			K = A;

		}

		for (int k = *(H + A); k; k = (*(E + k)).second) {

			dfs1((*(E + k)).first, B + 1);

		}

	}

}

void dfs2(int A, int B) {

	if (*(D2 + A) == false) {

		*(D2 + A) = true;

		saidai2 = max(saidai2, B);

		for (int k = *(H + A); k; k = (*(E + k)).second) {

			dfs2((*(E + k)).first, B + 1);

		}

	}

}



const int cm = 1 << 17;

char cn[cm], *ci = cn + cm, ct;

inline char getcha() {

	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }

	return *ci++;

}

inline int getint() {

	int A = 0;

	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';

	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';

	return A;

}



int main() {

	cin.tie(0);

	ios::sync_with_stdio(false);





	int N = getint();

	int k = 1;

	rep(i, N - 1) {

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

		*(E + k) = mp(a, *(H + b));

		*(H + b) = k++;

		*(E + k) = mp(b, *(H + a));

		*(H + a) = k++;

	}



	dfs1(1, 1);

	dfs2(K, 1);

	saidai2++;



	if (saidai2 % 3 == 0) co("Second");

	else co("First");



	Would you please return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

  

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
//树的直径板子 

#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem: