Problem:
		
B: たぬきつね

				
問題

				

					謎の装置 $M$ があり,この装置に Tanuki と Fox を入れると, 装置から一匹の動物が出てくる（以下, Tanuki を $T$ ,Foxを $F$ とする）.
				

				

					$M(x, y)$ は,装置 $M$ に $x, y$ の順で動物を入れて出てきた動物を表す.
				

				

					色々試した結果,以下のことがわかった.

					

						$M(T, T) = T$ 

						$M(T, F) = F$ 

						$M(F, T) = T$ 

						$M(F, F) = T$ 

					

				

				

					あなたは,一列に並んでいる動物たち $P_1, P_2, ... , P_N$ を以下のように装置に入れていった.

					$M(....M(M(P_1,P_2), P_3)...., P_N)$
				

				

					最後に出てくる動物を答えよ.
				

				
制約

				

					
$2 \leq N \leq 10^{5}$

					

						$P_i$ は $T$ か $F$ の一文字
					

				

				
入力形式

				
 入力は以下の形式で与えられる. 

				

					$N$

					$P_1\ P_2\ ...\ P_N$
				

				
出力

				
最後に出てくる動物を表す文字 $T$ または $F$ を出力せよ.また,末尾に改行も出力せよ.

				
サンプル

				
サンプル入力 1

				

3
F T T

				
サンプル出力 1

				

T

				
サンプル入力 2

				

7
F T T F T T F

				
サンプル出力 2

				

F



Sample input:
3
F T T


Sample output:
T

Submission status: Accepted

Solution code:
from functools import reduce


def M(x, y):
    if x == 'T' and y == 'T':
        return 'T'
    elif x == 'T' and y == 'F':
        return 'F'
    elif x == 'F' and y == 'T':
        return 'T'
    else:
        return 'T'


_ = input()
P = input().split()

print(reduce(M, P))

Submission status: Accepted

Solution code:
from functools import reduce


def M(x, y):
    if x == 'T' and y == 'F':
        return 'F'
    else:
        return 'T'


_ = input()
P = input().split()

print(reduce(M, P))

Submission status: Accepted

Solution code:
n=int(input())
p=list(map(str,input().split()))
m=p[0]
for i in range(1,n):
    if m+p[i]=="TF":
        m="F"
    else:
        m="T"
print(m)

Submission status: Accepted

Solution code:
N = int(input())
P = input().split()
if P[0]=="T" and P[1]=="F":
    out = "F"
else:
    out = "T"
for i in range(N-2):
    if out == "T" and P[i+2] == "F":
        out = "F"
    else:
        out = "T"
print(out)

Submission status: Accepted

Solution code:
from functools import reduce


def M(x, y):
    if x == 'T' and y == 'F':
        return 'F'
    else:
        return 'T'


_ = input()
P = input().split()

print(reduce(M, P))

Submission status: Accepted

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
P = raw_input().split()

ans = P[0]
for i in range(1, N):
    if ans + P[i] == 'TF':
        ans = 'F'
    else:
        ans = 'T'

print ans

Submission status: Accepted

Solution code:
n = int(input())
li = input().split()
bef = li[0]
for i in range(1, n):
    bef = "F" if bef == "T" and li[i] == "F" else "T"
print(bef)

Submission status: Accepted

Solution code:
n=int(input())
tf=list(map(str,input().split()))
tf_r=tf[::-1]
while n!=1:
    if tf_r[-1]=="T" and tf_r[-2]=="F":
        del tf_r[-2:]
        tf_r.append("F")
        n-=1
    else:
        del tf_r[-2:]
        tf_r.append("T")
        n-=1
print(tf_r[0])

Submission status: Accepted

Solution code:
# /usr/bin/python
# -*- coding: utf-8 -*-
import sys


def machine(x,y):
  if x=='T' and y=='F':
    return 'F'
  else:
    return 'T'


N = int(input())
Pn = list(map(str, sys.stdin.readline().rstrip().split()))

for i in range(1, N):
  Pn[i] = machine(Pn[i-1], Pn[i])

print(Pn[-1])

Submission status: Accepted

Solution code:
def M(i,j):
    return "F" if i=="T" and j=="F" else "T"

n = int(input())
p = input().split()

ret = p[0]
for i in range(1,n):
    ret = M(ret,p[i])
print(ret)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
h,w = LI()
a,b = LI()
y = h//a
x = w//b
ans = h*w-a*y*b*x
print(ans)
"""

#B
def m(x,y):
    if x == y:
        return "T"
    if x == "F":
        return "T"
    return "F"
n = I()
p = input().split()
ans = p[0]
for i in range(1,n):
    ans = m(ans,p[i])
print(ans)

#C
"""
s = [[1]*8 for i in range(4)]
for i in range(4):
    s.insert(2*i,[1,0,1,0,1,0,1,0])
for j in range(8):
    for i in range(1,8):
        s[j][i] += s[j][i-1]
for j in range(8):
    for i in range(1,8):
        s[i][j] += s[i-1][j]
s.insert(0,[0,0,0,0,0,0,0,0,0])
for i in range(1,9):
    s[i].insert(0,0)
q = I()
for _ in range(q):
    a,b,c,d = LI()
    print(s[c][d]-s[c][b-1]-s[a-1][d]+s[a-1][b-1])
"""

#D
"""
n = I()
a = LI()
dp = [float("inf") for i in range(n)]
b = [[] for i in range(n)]
ind = [0 for i in range(100001)]
for i in range(n):
    k = bisect.bisect_left(dp,a[i])
    dp[k] = a[i]
    b[k].append(a[i])
    ind[a[i]] = max(i,ind[a[i]])
for i in range(n):
    if dp[i] == float("inf"):break
    b[i].sort()
    b[i] = b[i][::-1]
i -= 1
ans = b[i][0]
now_ind = ind[b[i][0]]
now_v = b[i][0]
while i >= 0:
    for j in b[i]:
        if ind[j] < now_ind and j < now_v:
            ans += j
            now_ind = ind[j]
            now_v = j
    i -= 1
print(ans)
"""
#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Accepted

Solution code:
N=int(input())
kekka=list(input().split())
#print(kekka)
base=kekka[0]
#result=0
for i in range(1,N):
    if base=="F":
        base="T"
        #print(1)
    elif base=="T":
        if kekka[i]=="T":
            base="T"
            #print(2)
        else:
            base="F"
            #print(3)
            
print(base)

Submission status: Accepted

Solution code:
f = [[1, 1], [0, 1]]

N = input()
A = map(lambda x: [0, 1][x=='T'], raw_input().split())

v = A[0]

for i in xrange(1, N):
    v = f[v][A[i]]

print 'T' if v else 'F'

Submission status: Accepted

Solution code:
def inpl(): return list(map(int, input().split()))

N = int(input())
P = input().split()

def calc(a, b):
    if a == "T" and b == "F":
        return "F"
    else:
        return "T"

a = P[0]
for b in P[1:]:
    a = calc(a, b)
print(a)