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 <bits/stdc++.h>
#define ls  (n<<1)
#define rs  (ls|1)
using namespace std;

const int N=100010;
struct edge{int s,t,n;}e[2*N],E[N];
int n,h[N],f[N],g[N],siz[N],hs[N],dfn[N],dep[N],t1[4*N],t2[4*N],tag[4*N],Xor[4*N];

void dfs(int x,int fa)
{
	f[x]=fa,siz[x]=1;
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if (y!=fa)
			{
				dfs(y,x),siz[x]+=siz[y];
				if (siz[y]>siz[hs[x]])  hs[x]=y;
			}
}

void dfs2(int x,int gf)
{
	g[x]=gf,dfn[x]=++dfn[0],dep[x]=dep[f[gf]]+1;
	if (hs[x])  dfs2(hs[x],gf);
	for (int i=h[x],y; y=e[i].t,i; i=e[i].n)
		if ((y!=f[x])&&(y!=hs[x]))  dfs2(y,y);
}

void merge(int n)
{
	if (t1[ls]<t1[rs])  t1[n]=t1[ls],t2[n]=min(t2[ls],t1[rs]);
	else  if (t1[ls]>t1[rs])  t1[n]=t1[rs],t2[n]=min(t2[rs],t1[ls]);
	else  t1[n]=t1[ls],t2[n]=min(t2[ls],t2[rs]);
	t1[n]+=tag[n],t2[n]+=tag[n];
}

void modify(int n,int l,int r,int L,int R,int k)
{
	if ((L<=l)&&(r<=R))
		Xor[n]^=k,t1[n]+=k,t2[n]+=k,tag[n]+=k;
	else
		{
			int mid=(l+r)>>1;
			if (L<=mid)  modify(ls,l,mid,L,R,k);
			if (mid<R)  modify(rs,mid+1,r,L,R,k);
			merge(n);
		}
}

int find(int n,int l,int r)
{
	if (tag[n]==1)  return Xor[n];
	int mid=(l+r)>>1;
	return (t1[ls]==1)||(t2[ls]==1)?find(ls,l,mid):find(rs,mid+1,r);
}

void modify(int x,int y,int k)
{
	while (g[x]!=g[y])
		{
			if (dep[x]<dep[y])  swap(x,y);
			modify(1,1,n,dfn[g[x]],dfn[x],k),x=f[g[x]];
		}
	if (dfn[x]>dfn[y])  swap(x,y);
	if (x!=y)  modify(1,1,n,dfn[x]+1,dfn[y],k);
}

void work()
{
	scanf("%d",&n);
	for (int i=1,u,v,tot=0; i<n; i++)
		{
			scanf("%d %d",&u,&v);
			e[++tot]=(edge){u,v,h[u]},h[u]=tot;
			e[++tot]=(edge){v,u,h[v]},h[v]=tot;
		}
	for (int i=1; i<n; i++)  scanf("%d %d",&E[i].s,&E[i].t);
	dfs(1,0),dfs2(1,1),memset(t2,127,sizeof(t2));
	for (int i=1; i<n; i++)  modify(E[i].s,E[i].t,i);
	for (int i=1,j; i<n; i++)
		if (t2[1]==1)  j=find(1,1,n),modify(E[j].s,E[j].t,j);
		else  puts("NO"),exit(0);
	puts("YES");
}

int main()
{
	work();
	return 0;
}