Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

N = int(input())
S = input()
Apre = [1 if(S[i]=='E') else 0 for i in range(N)]
A = [sum(Apre[0:i+1]) for i in range(N)]
ans = min(N-1-A[N-2], A[N-1]-A[0])
for i in range(1,N):
  ans = min(ans, i-A[i-1]+A[N-1]-A[i])
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
A = [1 if S[0]=='E' else 0]
for i in range(1,N):
  A.append(1 if S[i]=='E' else 0)
  A[i] += A[i-1]
ans = min(N-1-A[N-2], A[N-1]-A[0])
for i in range(1,N):
  ans = min(ans, i-A[i-1]+A[N-1]-A[i])
print(ans)
### BUGGY CODE ###

N,K = map(int,input().split())
R,S,P = map(int,input().split())
win = {'r':P,'s':R,'p':S}
T = input()
WAKE = ['']*K

for i in range(N):
    WAKE[i%K] += T[i]

ans = 0
for i in range(K):
    if len(WAKE[i])>=0:
        pre = WAKE[i][0]
        ans += win[pre]
        for j in range(1,len(WAKE[i])):
            now = WAKE[i][j]
            if pre != now:
                ans += win[now]
                pre = now
            else:
                pre = ''
print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
R,S,P = map(int,input().split())
win = {'r':P,'s':R,'p':S}
T = input()
WAKE = ['']*K

for i in range(N):
    WAKE[i%K] += T[i]

ans = 0
for i in range(K):
    if len(WAKE[i])>=0:
        pre = WAKE[i][0]
        ans += win[pre]
        for j in range(1,len(WAKE[i])):
            now = WAKE[i][j]
            if pre != now:
                ans += win[now]
                pre = now
            else:
                pre = ''
print(ans)
### BUGGY CODE ###

import itertools

n, m, R = map(int, input().split())
r = list(map(int, input().split()))

dis = [[float("inf") for i in range(n)] for j in range(n)]
for i in range(n):
    dis[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    dis[a-1][b-1] = c
    dis[b-1][a-1] = c

def warshall_floyd(dis):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j])
    return dis

data = warshall_floyd(dis)
ans = float("inf")
for i in itertools.permutations(r, R):
    num = 0
    for j in range(R - 1):
        num += data[i[j] - 1][i[j + 1] - 1]
    ans = min(ans, num)
print(ans)

### FIXED CODE ###

import itertools

n, m, R = map(int, input().split())
r = list(map(int, input().split()))

dis = [[float("inf") for i in range(n)] for j in range(n)]
for i in range(n):
    dis[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    dis[a-1][b-1] = c
    dis[b-1][a-1] = c

def warshall_floyd(dis):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j])
    return dis

data = warshall_floyd(dis)
ans = float("inf")
for i in itertools.permutations(r, R):
    num = 0
    for j in range(R - 1):
        num += data[i[j] - 1][i[j + 1] - 1]
    ans = min(ans, num)
print(ans)
### BUGGY CODE ###

r,c,n = map(int,input().split())
a = [list(map(int, input().split())) for _ in range(n)]
iru = []
for i in range(n):
  if ((a[i][0] == 0 or a[i][0] == r or a[i][1] == 0 or a[i][1] == c) and (a[i][2] == 0 or a[i][2] == r or a[i][3] == 0 or a[i][3] == c)):
    iru.append(a[i])
if len(iru) <= 1:
  print("YES")
else:
  for i in range(len(iru)):
    b = iru[i]
    b1 = [b[0],b[1]]
    b2 = [b[2],b[3]]
    if b1[0] == 0:
      b1 = b1[1]
    elif b1[1] == c:
      b1 = b1[0] + b1[1]
    elif b1[0] == r:
      b1 = c*2 +r-1 -b1[1]
    else:
      b1 = c*2 + r*2 -2 - b1[0]
      
    if b2[0] == 0:
      b2 = b2[1]
    elif b2[1] == c:
      b2 = b2[0] + b2[1]
    elif b2[0] == r:
      b2 = c*2 +r-1 -b2[1]
    else:
      b2 = c*2 + r*2 -2 - b2[0]
    if b1 > b2:
      tmp = b1 +0
      b1 = b2 +0
      b2 = tmp + 0
    for j in range(i+1,len(iru)):
      d = iru[j]
      d1 = [d[0],d[1]]
      d2 = [d[2],d[3]]
      if d2[0] == 0:
        d2 = d2[1]
      elif d2[1] == c:
        d2 = d2[0] + d2[1]
      elif d2[0] == r:
        d2 = c*2 +r-1 -d2[1]
      else:
        d2 = c*2 + r*2 -2 - d2[0]
      
      if d1[0] == 0:
        d1 = d1[1]
      elif d1[1] == c:
        d1 = d1[0] + d1[1]
      elif d1[0] == r:
        d1 =  c*2 +r-1 -d1[1]
      else:
        d1 = c*2 + r*2 -2 - d1[0]
      if d1 > d2:
        tmp = d1 +0
        d1 = d2 +0
        d2 = tmp + 0
      if (b1 <= d1 and d1 <= b2 and b2 <= d2):
        print("NO")
        exit()
      elif (d1 <= b1 and b1 <= d2 and d2 <= b2):
        print("NO")
        exit()
  print("YES")     

### FIXED CODE ###

r,c,n = map(int,input().split())
a = [list(map(int, input().split())) for _ in range(n)]
iru = []
for i in range(n):
  if ((a[i][0] == 0 or a[i][0] == r or a[i][1] == 0 or a[i][1] == c) and (a[i][2] == 0 or a[i][2] == r or a[i][3] == 0 or a[i][3] == c)):
    b = a[i]
    b1 = [b[0],b[1]]
    b2 = [b[2],b[3]]
    if b1[0] == 0:
      b1 = b1[1]
    elif b1[1] == c:
      b1 = b1[0] + b1[1]
    elif b1[0] == r:
      b1 = c +r+c -b1[1]
    else:
      b1 = c*2 + r*2 - b1[0]
      
    if b2[0] == 0:
      b2 = b2[1]
    elif b2[1] == c:
      b2 = b2[0] + b2[1]
    elif b2[0] == r:
      b2 = c*2 +r -b2[1]
    else:
      b2 = c*2 + r*2 - b2[0]
    if b1 > b2:
      tmp = b1 +0
      b1 = b2 +0
      b2 = tmp + 0
    iru.append([b1,b2])
iru = sorted(iru)
ato = 0
stack = [r+r+c+c]
flag = 'YES'
for a,b in iru:
  while a >= stack[-1]:
    stack.pop()
 
  if b > stack[-1]:
    flag = 'NO'
    break
  else:
    stack.append(b)
 
print(flag)
### BUGGY CODE ###


#素因数分解
def prime_factorization(N):
    n=N
    a=2
    prime_factor=[]
    while a**2<=n:
        while n%a==0:
            prime_factor.append(a)
            n//=a
        a+=1
    if n>1:
        prime_factor.append(n)
    return prime_factor


# N=100
N=int(input())

a=1
b=N//a
dis=abs(a-b)

Li=prime_factorization(N)
# print(Li)

for p in range(2**len(Li)):
    bit=[]
    for e in range(len(Li)):
        if (p>>e)&1==1:
            bit.append(1)
        else:
            bit.append(0)
    # print(bit)
        proindex=[]
        for _ in range(len(bit)):
            if bit[_] ==1:
                proindex.append(_)
        _a=1
        for j in range(len(Li)):
            if proindex.count(j)==1:
                _a*=Li[j]
        _b=N//_a
        _dis=abs(_a-_b)
        if _dis<dis:
            a=_a
            b=_b
            dis=_dis
        if _a>N**0.5:
            break
# print(a,b)

print(a-1+b-1)

### FIXED CODE ###

N=int(input())

a=1
b=N//a
dis=abs(b-a)

for i in range(1,int(N**0.5)+1):
    if N%i==0:
        _a=i
        _b=N//i
        _dis=abs(_b-_a)
        if _dis<dis:
            a=_a
            b=_b
            dis=_dis

print(a-1+b-1)
### BUGGY CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

h, w = MAP()
A = [list(input()) for i in range(h)]

def bfs():
    que = deque([])
    
    dx = [0, 1, 0, -1]
    dy = [1, 0, -1, 0]

    d = [[INF] * w for i in range(h)]
     
    for i in range(h):
        for j in range(w):
            if A[i][j] == "#":
                sy, sx = i, j
                d[sy][sx] = 0
                que.append((sy, sx))
    while que:
        p = que.popleft()
        for i in range(4):
            ny, nx = p[0] + dy[i], p[1] + dx[i]
            
            if 0 <= ny < h and 0 <= nx < w and d[ny][nx] == INF:
                d[ny][nx] = d[p[0]][p[1]] + 1
                A[ny][nx] = "#"
                que.append((ny, nx))
    return d

ans = 0
for l in bfs():
    ans = max(ans, max(l))
print(ans)


    


### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

h, w = MAP()
A = [list(input()) for i in range(h)]


def bfs():
    que = deque([])
    
    dx = [0, 1, 0, -1]
    dy = [1, 0, -1, 0]

    d = [[INF] * w for i in range(h)]
    
    for i in range(h):
        for j in range(w):
            if A[i][j] == "#":
                sy, sx = i, j
                d[sy][sx] = 0
                que.append((sy, sx))
    ans = 0
    while que:
        p = que.popleft()
        for i in range(4):
            ny, nx = p[0] + dy[i], p[1] + dx[i]
            
            if 0 <= ny < h and 0 <= nx < w and d[ny][nx] == INF and A[ny][nx] == ".":
                d[ny][nx] = d[p[0]][p[1]] + 1
                # A[ny][nx] = "#"
                que.append((ny, nx))
 
                ans = max(ans, d[ny][nx])     
#    print(*d, sep="\n")
    return ans


if __name__ == "__main__":
    print(bfs())
### BUGGY CODE ###

def main():
    n,k = map(int, input().split())
    a =  list(map(int, input().split()))

    ans = [1]
    for _ in range(n-1):
        if a[ans[-1]-1] in set(ans):
            start = ans.index(a[ans[-1]-1])
            break
        ans.append(a[ans[-1]-1])

    if k > start:
        index = (k - start) % (len(ans) - start) + start
        t = ans[index]
    else:
        t = ans[k]
    return print(t)

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    a =  list(map(int, input().split()))

    path = [1]
    for _ in range(n-1):
        path.append(a[path[-1]-1])

    if k > n:
        start = path.index(path[-1])
        index = (k - start) % (len(path) - start - 1) + start
        t = path[index]
    else:
        t = path[k]
    return print(t)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import functools
import operator

n = int(input())
a = [int(i) for i in input().split()]

result = functools.reduce(operator.mul, a)

if result > 10 ** 18:
    print(-1)
else:
    print(result)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
answer = 1
for i in range(len(a)):
    answer = answer * a[i]
    if answer > 10 ** 18:
        if 0 in a:
            print(0)
        else:
            print(-1)
        break
else:
    print(answer)
### BUGGY CODE ###

N = int(input())
S = input()
ans = N
for i in range(0, N):
    LR = S[:i].count('W') + S[i+1:].count('E')
    if LR < ans: ans = LR
print(ans)

### FIXED CODE ###

N = int(input())
S = input()
ans = N
E = [0] * (N + 1)
for i in range(N):
    E[i+1] = E[i] + (S[i] == 'E')
for i in range(N):
    LR = i - E[i] + E[N] - E[i+1]
    if LR < ans: ans = LR
print(ans)
### BUGGY CODE ###

import math
n,q = (int(i) for i in input().split())
s = input()
query = [0]*n
for i in range(n-1):
  if s[i] == 'A' and s[i+1] =='C': 
    query[i] = 1
for i in range(q):
  l,r = (int(i) for i in input().split())
  ans = sum(query[(l-1):r])
  if r >= 1:
   if s[r-1] == 'A' and s[r-2] =='C':

     ans -= 1
  print(math.floor(ans))
 

### FIXED CODE ###

n,q = (int(i) for i in input().split())
s = input()
query = [0]*(n+1)
point = [0]*(n+1)
ct = 0
for i in range(n-1):
  if s[i] == 'A' and s[i+1] =='C': 
    ct += 1
    point[i] = -1 
  query[i+1] = ct
query[i+2] = ct  
#print(point)
    
for i in range(q):
  l,r = (int(i) for i in input().split())
  ans = query[r]-query[l-1]
  ans += point[r-1]
  print(ans)
### BUGGY CODE ###

N = int(input())

def get_parent(node):
    parent = -1
    if "parent" in node:
        parent = node["parent"]
    return parent

def get_depth(node):
    depth = 0
    while "parent" in node:
        depth += 1
        parent = node["parent"]
        node = rooted_tree[parent]
    return depth

def get_node_type(node):
    if "parent" not in node:
        return "root"
    if "left" not in node:
        return "leaf"
    return "internal node"

def get_children(node):
    if "left" not in node:
        return "[]"
    left = node["left"]
    siblings = []
    siblings.append(str(left))
    while rooted_tree[left]["right"] > -1:
        right = rooted_tree[left]["right"]
        siblings.append(str(right))
        left = right
    return "[{}]".format(", ".join(siblings))

rooted_tree = [{} for i in range(N)]
for id in range(N):
    row = input()
    _, degree, *children = list(map(int, row.split()))
    if degree > 0:
        rooted_tree[id]["left"] = children[0]
        for i in range(len(children)):
            child_id = children[i]
            right = -1
            if i < len(children)-1:
                right = children[i+1]
            rooted_tree[child_id]["right"] = right
            rooted_tree[child_id]["parent"] = id

for id in range(N):
    node = rooted_tree[id]
    parent = get_parent(node)
    depth = get_depth(node)
    node_type = get_node_type(node)
    children = get_children(node)
    print("node {}: parent = {}, depth = {}, {}, {}".format(id, parent, depth, node_type, children))


### FIXED CODE ###

N = int(input())

def get_parent(node):
    parent = -1
    if "parent" in node:
        parent = node["parent"]
    return parent

def get_depth(node):
    depth = 0
    while "parent" in node:
        depth += 1
        parent = node["parent"]
        node = rooted_tree[parent]
    return depth

def get_node_type(node):
    if "parent" not in node:
        return "root"
    if "left" not in node:
        return "leaf"
    return "internal node"

def get_children(node):
    if "left" not in node:
        return "[]"
    left = node["left"]
    siblings = []
    siblings.append(str(left))
    while rooted_tree[left]["right"] > -1:
        right = rooted_tree[left]["right"]
        siblings.append(str(right))
        left = right
    return "[{}]".format(", ".join(siblings))

rooted_tree = [{} for i in range(N)]
for _ in range(N):
    row = input()
    id, degree, *children = list(map(int, row.split()))
    if degree > 0:
        rooted_tree[id]["left"] = children[0]
        for i in range(len(children)):
            child_id = children[i]
            right = -1
            if i < len(children)-1:
                right = children[i+1]
            rooted_tree[child_id]["right"] = right
            rooted_tree[child_id]["parent"] = id

for id in range(N):
    node = rooted_tree[id]
    parent = get_parent(node)
    depth = get_depth(node)
    node_type = get_node_type(node)
    children = get_children(node)
    print("node {}: parent = {}, depth = {}, {}, {}".format(id, parent, depth, node_type, children))
### BUGGY CODE ###

n,q =map(int,input().split())
s=input()
l=[list(map(int,input().split())) for _ in range(q)]

p=[i+1 for i in range(n-1) if s[i]+s[i+1]=='AC']

for i in range(q):
  cnt=sum([l[i][0]<=x<l[i][1] for x in p])
  print(cnt)


### FIXED CODE ###

n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for _ in range(q)]
a=[0]*n

for i in range(n):
  a[i]=a[i-1]
  if s[i-1:i+1]=='AC':
    a[i]+=1

for i in range(q):
  print(a[l[i][1]-1]-a[l[i][0]-1])
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int):
    from decimal import Decimal
    for i in range(1, 3501):
        for j in range(1, 3501):
            dN, di, dj = Decimal(N), Decimal(i), Decimal(j)
            z = 4*di*dj - dN*dj - dN*di
            if z == 0:
                continue
            h = (dN*di*dj)/z
            if 0 <= h <= 3500:
                print(h, i, j)
                exit()
            

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(1, 3501):
        for j in range(i, 3501):
            z = 4*i*j - N*(j+i)
            if z > 0:
                h, r = divmod((N*i*j), z)
                if r == 0:
                    print(h, i, j)
                    exit()
            

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


# #!/usr/bin/env python3
# n = int(input())
# for i in range(1, 3501):
#   for j in range(1, 3501):
#     seed = 4 * i * j - n * (i + j) 
#     if seed > 0:
#       k, mod = divmod(n * i * j, seed) 
#       if mod == 0:
#         print(i, j, k)
#         exit()
### BUGGY CODE ###

s = input()
ans = 0
while True:
    a = s.replace("ABC", "BCA", 1)
    if s == a:
        break
    else:
        s = a
        ans += 1
print(ans)

### FIXED CODE ###

s = input()
s = s.replace("BC","D")
a,ans = 0,0
#Dより前にあるB,C意外でつながったAの数をカウント
for i in s:
    if i == "A":
        a += 1
    elif i == "D":
        ans += a
    else:
        a = 0
print(ans)
### BUGGY CODE ###

import numpy as np
N = int(input())
A = list(map(int, input().split()))

left = [[0 for _ in range(N)] for _ in range(N)]
right = [[] for _ in range(N)]
for i in range(N):
  right[i].append(2 * A[i] + 2 * A[(i + 1) % N])
  for j in range(N):
    if j == i or j == (i + 2) % N:
      left[i][j] = 1
    if j == (i + 1) % N:
      left[i][j] = 2

A = np.matrix(left)
Y = np.matrix(right)
ans = np.linalg.inv(A) * Y

for i in range(N):
  print(int(round(ans[i,0])), end = "")
  if i == N - 1:
    print()
  else:
    print(" ", end = "")

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
  tmp = ans
  if i == 0:
    for j in range(N):
      if j % 2 == 0:
        ans += A[j]
      else:
        ans -= A[j]
  else:
    ans = 2 * A[i - 1] - tmp

  tmp = ans
  print(ans, end = "")
  if i != N - 1:
    print(" ", end = "")
  else:
    print()
### BUGGY CODE ###

def main() :
    n = int(input())
    A = []
    for _ in range(n) :
        A.append(list(map(int, input().split())))

    ans = sum([sum(_A) for _A in A])
    for k in range(n) :
        for i in range(n) :
            for j in range(n) :
                if i == k :
                    break
                elif j == k :
                    continue
                
                d = A[i][k] + A[k][j]
                if d == A[i][j] :
                    ans -= d
                elif d < A[i][j] :
                    print(-1)
                    exit()

    print(ans//2)

main()

### FIXED CODE ###

def main() :
    n = int(input())
    A = [list(map(int, input().split())) for _ in range(n)]

    ans = 0
    for i in range(n) :
        for j in range(i+1, n) :
            cost = A[i][j]
            for k in range(n) :
                if i == k or j == k:
                    continue

                d = A[i][k] + A[k][j]
                if d == A[i][j] :
                    cost = 0
                elif d < A[i][j] :
                    print(-1)
                    exit()
            ans += cost
    print(ans)

main()
### BUGGY CODE ###

from itertools import product

N, K = map(int, input().split())
x, y = [None] * N, [None] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

ans = float('inf')
for i, j, k, l in product(range(N), repeat=4):
    x1, x2 = x[i], x[j]
    y1, y2 = y[k], y[l]
    cnt = 0
    for xx, yy in zip(x, y):
        if x1 <= xx <= x2 and y1 <= yy <= y2:
            cnt += 1
    if cnt >= K:
        s = abs(x1 - x2) * abs(y1 - y2)
        ans = min(ans, s)
print(ans)



### FIXED CODE ###

from itertools import product

N, K = map(int, input().split())
x, y = [None] * N, [None] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

xary = sorted(x)
yary = sorted(y)

ans = float('inf')
for i, j, k, l in product(range(N), repeat=4):
    if i >= j or k >= l:
        continue
    x1, x2 = xary[i], xary[j]
    y1, y2 = yary[k], yary[l]
    cnt = 0
    for xx, yy in zip(x, y):
        if x1 <= xx <= x2 and y1 <= yy <= y2:
            cnt += 1
    if cnt >= K:
        s = abs(x1 - x2) * abs(y1 - y2)
        ans = min(ans, s)
print(ans)
### BUGGY CODE ###

def fun(n):
    return (n*(n+1))//2
n = int(input())
a = list(map(int,input().split()))
d = {}
for i in range(len(a)):
    d[a[i]] = 0
for i in range(len(a)):
    d[a[i]] += 1
for i in range(len(a)):
    ans = 0
    d[a[i]] -= 1
    for j in d:
        ans += fun(d[j]-1)
    print(ans)
    d[a[i]] += 1

### FIXED CODE ###

def fun(n):
    return (n*(n+1))//2
n = int(input())
a = list(map(int,input().split()))
d = {}
for i in range(len(a)):
    d[a[i]] = 0
for i in range(len(a)):
    d[a[i]] += 1
total = 0
for i in d:
    total += fun(d[i]-1)
for i in d:
    d[i] = total - (d[i] -1)
for i in range(len(a)):
    print(d[a[i]])
### BUGGY CODE ###

def Prime(x):
   if x == 2:
      return 1
   elif (x<2) or (x%2==0):
      return 0
   else:
      i = 3
      while i <= x**0.5:
         if x%i == 0:
            return 0
         i = i + 2
      return 1

Q = int(input())
l_r = []
for i in range(Q):
   l_r.append(list(map(int, input().split())))

like_Number = []

for l_r in l_r:
   l = l_r[0]
   r = l_r[1]
   count = 0
   for x in range(l, r+1):
      if x%2 == 1: # 奇数だけ
         if Prime(x) == 1:
            if Prime((x+1)/2) == 1:
               count = count + 1
   like_Number.append(count)

for i in range(Q):
   print(like_Number[i])
         


### FIXED CODE ###

def main():
    Q = int(input())
    L = [0 for _ in range(Q)]
    R = [0 for _ in range(Q)]
    for i in range(Q):
        L[i], R[i] = map(int, input().split())

    N = 100000
    sosu = [1 for _ in range(N)]
    sosu[0] = 0
    for i in range(1,int(N**0.5)):
        k = i+1
        if sosu[i] == 1:
            j = k + k
            while j <= N:
                sosu[j-1] = 0
                j = j+k
    like = [0 for _ in range(N)]
    for i in range(2, N, 2):
        if sosu[i]==1 and sosu[(i+2)//2-1]==1:
            like[i] = 1
    like_wa = [0 for _ in range(N+1)]
    for i in range(N):
        like_wa[i+1] = like_wa[i] + like[i]

    for i in range(Q):
        print(like_wa[R[i]] - like_wa[L[i]-1])

if __name__ == '__main__':
    main()
### BUGGY CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
ans = [False]*(k+1)
for i in range(1,k+1):
    ok = False
    for j in a:
        if i-j<0:
            continue
        if ans[i-j] == False:
            ans[i] = True

print('First' if ans[k] else 'Second')

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(int,input().split()))
ans = [False]*(k+1)
for i in range(1,k+1):
    ok = False
    for j in a:
        if i-j<0:
            continue
        if ans[i-j] == False:
            ans[i] = True
            break

print('First' if ans[k] else 'Second')