Problem:
Score : 900 points

Problem Statement

There is a tree with N vertices numbered 1 through N.
The i-th of the N-1 edges connects vertices a_i and b_i.

Initially, each vertex is uncolored.

Takahashi and Aoki is playing a game by painting the vertices. In this game, they alternately perform the following operation, starting from Takahashi:

Select a vertex that is not painted yet.

If it is Takahashi who is performing this operation, paint the vertex white; paint it black if it is Aoki.

Then, after all the vertices are colored, the following procedure takes place:

Repaint every white vertex that is adjacent to a black vertex, in black.

Note that all such white vertices are repainted simultaneously, not one at a time.

If there are still one or more white vertices remaining, Takahashi wins; if all the vertices are now black, Aoki wins.
Determine the winner of the game, assuming that both persons play optimally.

Constraints

2 ≤ N ≤ 10^5

1 ≤ a_i,b_i ≤ N

a_i ≠ b_i

The input 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

Print First if Takahashi wins; print Second if Aoki wins.

Sample Input 1

3
1 2
2 3

Sample Output 1

First

Below is a possible progress of the game:

First, Takahashi paint vertex 2 white.

Then, Aoki paint vertex 1 black.

Lastly, Takahashi paint vertex 3 white.

In this case, the colors of vertices 1, 2 and 3 after the final procedure are black, black and white, resulting in Takahashi's victory.

Sample Input 2

4
1 2
2 3
2 4

Sample Output 2

First

Sample Input 3

6
1 2
2 3
3 4
2 5
5 6

Sample Output 3

Second

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<iostream>
#include<vector>
using namespace std;
int N;
vector<int>G[1<<17];
bool re[1<<17];
int d[1<<17];
int pa[1<<17];
void dfs(int u,int p,int di)
{
	pa[u]=p;
	d[u]=di;
	int cnt=0;
	for(int v:G[u])
	{
		if(v!=p)
		{
			cnt++;
			dfs(v,u,di+1);
		}
	}
	re[u]=cnt==0;
}
bool rre[1<<17];
bool ansflag;
pair<pair<int,int>,pair<int,int> >dfs3(int u,int p)
{
	int a=0,aa=0,b=0,bb=0;
	int ecnt=0;
	for(int v:G[u])
	{
		ecnt+=v!=p;
		if(v==p||re[v])continue;
		pair<pair<int,int>,pair<int,int> >q=dfs3(v,u);
		a+=q.first.first>0;
		aa+=q.first.second>0;
		b+=q.second.first>0;
		bb+=q.second.second>0;
		if(rre[u]&&G[v].size()==2&&q.first.first>0)ansflag=true;
	}
	if(rre[u])
	{
		a++;
	}
	if(a>=2&&aa>=1)ansflag=true;
	if(G[u].size()==2&&b>=2&&b>=1)ansflag=true;
	if(G[u].size()>2)b=bb=0;
	if(rre[u])
	{
		a++;
		if(p>=0&&G[p].size()==2)aa++;
	}
	return make_pair(make_pair(b>0,bb>0),make_pair(a>0,aa>0));
}
bool f[2];
vector<int>c[2];
bool reach[1<<17];
void dfs2(int u,int p)
{
	reach[u]=true;
	for(int v:G[u])
	{
		if(v!=p)dfs2(v,u);
	}
}
main()
{
	cin>>N;
	for(int i=1;i<N;i++)
	{
		int a,b;cin>>a>>b;a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	if(N==2)
	{
		cout<<"Second"<<endl;
		return 0;
	}
	int r=0;
	while(G[r].size()<2)r++;
	dfs(r,-1,0);
	for(int i=0;i<N;i++)
	{
		if(i==r)continue;
		int cnt=0;
		for(int v:G[i])cnt+=re[v];
		if(cnt>=2)
		{
			cout<<"First"<<endl;
			return 0;
		}
		else if(cnt==1)
		{
			rre[i]=true;
			c[d[i]%2].push_back(i);
			if(G[pa[i]].size()==2)f[d[i]%2]=true;
		}
	}
	dfs3(r,-1);
	if(ansflag)
	{
		cout<<"First"<<endl;
		return 0;
	}
	int cnt=0;
	for(int v:G[r])cnt+=re[v];
	if(cnt>=2)
	{
		cout<<"First"<<endl;
		return 0;
	}
	else if(cnt==1)
	{
		if(c[0].size()>=1&&f[0])
		{
			cout<<"First"<<endl;
			return 0;
		}
		for(int v:G[r])
		{
			if(G[v].size()!=2)continue;
			dfs2(v,r);
		}
		for(int cc:c[0])
		{
			if(reach[cc])
			{
				cout<<"First"<<endl;
				return 0;
			}
		}
	}
	cout<<"Second"<<endl;
}