human
Give me a Python code to determine the winner of the game when the two players play optimally given the following:
I found an interesting problem on https://atcoder.jp/contests/arc105/tasks/arc105_e:
Given is an undirected graph G consisting of N vertices numbered 1 through N and M edges numbered 1 through M.
Edge i connects Vertex a_i and Vertex b_i bidirectionally.
G is said to be a good graph when both of the conditions below are satisfied. It is guaranteed that G is initially a good graph.
 - Vertex 1 and Vertex N are not connected.
 - There are no self-loops and no multi-edges.
Taro the first and Jiro the second will play a game against each other.
They will alternately take turns, with Taro the first going first.
In each player's turn, the player can do the following operation:
 - Operation: Choose vertices u and v, then add to G an edge connecting u and v bidirectionally.
The player whose addition of an edge results in G being no longer a good graph loses. Determine the winner of the game when the two players play optimally.
You are given T test cases. Solve each of them.

-----Constraints-----
 - All values in input are integers.
 - 1 \leq T \leq 10^5
 - 2 \leq N \leq 10^{5}
 - 0 \leq M \leq \min(N(N-1)/2,10^{5})
 - 1 \leq a_i,b_i \leq N
 - The given graph is a good graph.
 - In one input file, the sum of N and that of M do not exceed 2 \times 10^5.

-----Input-----
Input is given from Standard Input in the following format:
T
\mathrm{case}_1
\vdots
\mathrm{case}_T

Each case is in the following format:
N M
a_1 b_1
\vdots
a_M b_M

-----Output-----
Print T lines. The i-th line should contain First if Taro the first wins in the i-th test case, and Second if Jiro the second wins in the test case.

-----Sample Input-----
3
3 0
6 2
1 2
2 3
15 10
12 14
8 3
10 1
14 6
12 6
1 9
13 1
2 5
3 9
7 2

-----Sample Output-----
First
Second
First

 - In test case 1, Taro the first wins. Below is one sequence of moves that results in Taro's win:
 - In Taro the first's turn, he adds an edge connecting Vertex 1 and 2, after which the graph is still good.
 - Then, whichever two vertices Jiro the second would choose to connect with an edge, the graph would no longer be good.
 - Thus, Taro wins.

I tried it in Python, but could not do it. Can you solve it?
assistant
#Here is Python code to determine the winner of the game when the two players play optimally.

from collections import Counter as C
class F():
 def __init__(self,n):self.n=n;self.p=list(R(n));self.rank=[1]*n
 def f(self,x):
  if self.p[x]==x:return x
  else:self.p[x]=self.f(self.p[x]);return self.p[x]
 def T(self,x,y):
  p=self.f(x);q=self.f(y)
  if p==q:return None
  if p>q:p,q=q,p
  self.rank[p]+=self.rank[q];self.p[q]=p
I,R=input,range
for _ in R(int(I())):
 n,m=map(int,I().split());U=F(n)
 for i in R(m):a,b=map(int,I().split());U.T(a-1,b-1)
 if n%2:print("First"if(n*(n-1)//2-m)%2else"Second")
 else:
  for i in R(n):U.f(i)
  c=C(U.p);x,y=c[U.f(0)],c[U.f(n-1)];print("First"if x%2!=y%2else"First"if(n*(n-1)//2-x*y-m)%2else"Second")