Harryxun/stf_run huggingface dataset:
from __future__ import division
import math

def cross(p1,p2):
    a,b,c,d=p1[0],p1[1],p2[0],p2[1]
    t=pow(a,2)+pow(c,2)+pow(d,2)-pow(b,2)-2*a*c
    alpha=4*(pow(b-d,2)+pow(c-a,2))
    beta=4*(t*(b-d)-2*b*pow(c-a,2))
    gamma=pow(t,2)+4*pow(b,2)*pow(c-a,2)-4*pow(c-a,2)
    judge=pow(beta,2)-4*alpha*gamma
    if judge>0:
        y1=(-beta+math.sqrt(judge))/(2*alpha)
        y2=(-beta-math.sqrt(judge))/(2*alpha)
        x1=(2*(b-d)*y1+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        x2=(2*(b-d)*y2+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        return ((x1,y1),(x2,y2))
    elif judge==0:
        y=-beta/(2*alpha)
        x=(2*(b-d)*y+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        return x,y
    else:
        return -100,-100

def maxNum(P,L):
    ans=0
    for x,y in P:
        cnt=0
        for px,py in L:
            d=math.sqrt(pow(px-x,2)+pow(py-y,2))
            if d<=1:
                cnt+=1
        ans=max(ans,cnt)
    return ans

while True:
    n=input()
    if n==0:break
    L=[map(float,raw_input().split(",")) for i in range(n)]
    ans=0
    P=[]
    for i in range(n-1):
        for j in range(i+1,n):
            points=cross(L[i],L[j])
            if points!=(-100,-100):
                P.extend(points)
    print maxNum(P,L)

### FIXED CODE ###

from __future__ import division
import math

def cross(p1,p2):
    a,b,c,d=p1[0],p1[1],p2[0],p2[1]
    t=pow(a,2)+pow(c,2)+pow(d,2)-pow(b,2)-2*a*c
    alpha=4*(pow(b-d,2)+pow(c-a,2))
    beta=4*(t*(b-d)-2*b*pow(c-a,2))
    gamma=pow(t,2)+4*pow(b,2)*pow(c-a,2)-4*pow(c-a,2)
    judge=pow(beta,2)-4*alpha*gamma
    EPS=1e-5
    if c==a:
        y=(pow(a,2)+pow(b,2)-pow(c,2)-pow(d,2))/(2*(b-d))
        bd=pow(b-d,2)
        a1=4*bd
        b1=-8*a*bd
        c1=4*a*a*bd+pow(a*a-b*b-c*c-d*d+2*b*d,2)-4*bd
        inroot=pow(b1,2)-4*a1*c1
        if inroot<0:
            return None
        x1=(-b1+math.sqrt(inroot))/(2*a1)
        x2=(-b1-math.sqrt(inroot))/(2*a1)
        return ((x1,y),(x2,y))

    if judge>EPS:
        y1=(-beta+math.sqrt(judge))/(2*alpha)
        y2=(-beta-math.sqrt(judge))/(2*alpha)
        x1=(2*(b-d)*y1+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        x2=(2*(b-d)*y2+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        return ((x1,y1),(x2,y2))
    elif -EPS<=judge<=EPS:
        y=-beta/(2*alpha)
        x=(2*(b-d)*y+pow(c,2)+pow(d,2)-pow(a,2)-pow(b,2))/(2*(c-a))
        return ((x,y),)
    else:
        return None

def maxNum(P,L):
    ans=1
    for x,y in P:
        cnt=0
        for px,py in L:
            d=math.sqrt(pow(px-x,2)+pow(py-y,2))
            if d<=1:
                cnt+=1
        ans=max(ans,cnt)
    return ans

while True:
    n=input()
    if n==0:break
    L=[map(float,raw_input().split(",")) for i in range(n)]
    P=[]
    for i in range(n-1):
        for j in range(i+1,n):
            points=cross(L[i],L[j])
            if points:
                P.extend(points)
    print maxNum(P,L)
N=int(input())
sisterN=[]
SISTERn=[]
SIStern=[]
for n in range(N):
    _=int(input())
    if _<30000:
        _s= _
        if sisterN.count(_s)==1:
            sisterN.remove(_s)
        else:
            sisterN.append(_s)
    elif 30001<_<70000:
        _m= _
        if SISterN.count(_m)==1:
            SISterN.remove(_m)
        else:
            SISterN.append(_m)
    else:
        _b= bin(_)
        if SISTERn.count(_b)==1:
            SISTERn.remove(_b)
        else:
            SISTERn.append(_b)
print(len(sisterN)+len(SISTERn)+len(SIStern))

### FIXED CODE ###

N=int(input())
S=set()

for n in range(N):
    _=int(input())
    if _ in S:
        S.remove(_)
    else:
        S.add(_)

print(len(S))
k = int(input())
x = 7%k

flg = True
for i in range(1,k):
  x = x%k
  if x ==0:
    break
  else:
    x = x*10+7
    
if k%2==0:
  flg = False
    
print(i if flg else '-1')



### FIXED CODE ###

k = int(input())
x = 7%k

flg = False
for i in range(1,k+1):
  x = x%k
  if x ==0:
    flg = True
    break
  else:
    x = x*10+7
  
print(i if flg else '-1')
def partition(A, p, r):
    x = A[r]/10
    i = p-1
    for j in range(p, r):
        if A[j]/10 <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    i += 1
    A[i], A[r] = A[r], A[i]
    print A,i,r
    return i

def quicksort(A, p, r):
    if p<r:
        q = partition(A, p, r)
        quicksort(A, p, q-1)
        quicksort(A, q+1, r)
    return

def bubblesort(A):
    for i in range(len(A)):
        for j in range(i+1,len(A))[::-1]:
            if A[j] < A[j-1]:
                A[j],A[j-1] = A[j-1], A[j]
    return

n = int(input())
x = [[] for i in range(n)]
for i in range(n):
    a, b = raw_input().split()
    x[i] = int(b)*10 + 'SHDC'.index(a)

x1 = x + []
quicksort(x1, 0, n-1)
x2 = x + []
bubblesort(x2, 0, n-1)

if x1 == x2:
    print 'Stable'
else:
    print 'Not stable'
for e in x1:
    print 'SHDC'[e % 10], e/10

### FIXED CODE ###

def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j][0] <= x[0]:
            i += 1
            A[i], A[j] = A[j], A[i]
    i += 1
    A[i], A[r] = A[r], A[i]
    return i

def quicksort(A, p, r):
    if p<r:
        q = partition(A, p, r)
        quicksort(A, p, q-1)
        quicksort(A, q+1, r)
    return

def order(A):
    return sorted(A, key = lambda e: e[0])

n = int(input())
x = [[] for i in range(n)]
for i in range(n):
    a, b = raw_input().split()
    x[i] = (int(b), 'SHDC'.index(a))

x1 = x + []
quicksort(x1, 0, n-1)

if x1 == order(x):
    print 'Stable'
else:
    print 'Not stable'
for e in x1:
    print 'SHDC'[e[1]], e[0]
global count
acount = 0


def merge(num_list, left, mid, right):
    a = mid - left
    b = right - mid
    L = []
    R = []

    for i in range(a):
        L.append(num_list[left + i])
    for i in range(b):
        R.append(num_list[mid + i])

    L.append(float("inf"))
    R.append(float("inf"))

    i = 0
    j = 0
    global count

    for k in range(left, right):
        if L[i] <= R[j]:
            num_list[k] = L[i]
            i += 1
        else:
            num_list[k] = R[j]
            j += 1
        count += 1


def mergeSort(num_list, left, right):
    if left+1 < right:
        mid = (left + right) / 2
        mergeSort(num_list, left, mid)
        mergeSort(num_list, mid, right)
        merge(num_list, left, mid, right)

    return num_list


if __name__ == "__main__":
    num = raw_input()
    line = raw_input()

    num_list = line.strip().split()
    num_list = map(int, num_list)

    merge_list = mergeSort(num_list, 0, len(num_list))
    merge_list = map(str, merge_list)
    print " ".join(merge_list)
    print count

### FIXED CODE ###

global count
count = 0


def merge(num_list, left, mid, right):
    a = mid - left
    b = right - mid
    L = []
    R = []

    for i in range(a):
        L.append(num_list[left + i])
    for i in range(b):
        R.append(num_list[mid + i])

    L.append(float("inf"))
    R.append(float("inf"))

    i = 0
    j = 0
    global count

    for k in range(left, right):
        if L[i] <= R[j]:
            num_list[k] = L[i]
            i += 1
        else:
            num_list[k] = R[j]
            j += 1
        count += 1


def mergeSort(num_list, left, right):
    if left+1 < right:
        mid = (left + right) / 2
        mergeSort(num_list, left, mid)
        mergeSort(num_list, mid, right)
        merge(num_list, left, mid, right)

    return num_list


if __name__ == "__main__":
    num = raw_input()
    line = raw_input()

    num_list = line.strip().split()
    num_list = map(int, num_list)

    merge_list = mergeSort(num_list, 0, len(num_list))
    merge_list = map(str, merge_list)
    print " ".join(merge_list)
    print count
n = int(input())

print(pow(n, 3)

### FIXED CODE ###


n = int(input())

print(pow(n, 3))
N=input()

if N[0]==N[1] and N[1]==N[2]:
    print('Yes')
elif N[1]==N[2] and N[2]==N[3]:
    print('Yes')
elif N[2]==N[3] and N[3]==N[0]:
    print('Yes')
elif N[0]==N[2] and N[31]==N[3]:
    print('Yes')
else :
    print('No')

### FIXED CODE ###

N=input()

if N[0]==N[1] and N[1]==N[2]:
    print('Yes')
elif N[1]==N[2] and N[2]==N[3]:
    print('Yes')
else :
    print('No')
#!/usr/bin/env python3


def main():
    N = int(input())
    A = [i for i in map(int, input().split())]
    #print (N, A)
    gsize = 10
    numg = (N - 1) // gsize + 1
    maxg = [0] * numg
    ming = [0] * numg
    size = len(A)
    for g in range(0, numg):
        gA = A[gsize*g:min(gsize*(g+1), size)]
        maxg[g] = max(gA)
        ming[g] = min(gA)

    count = 0
    for g1 in range(0, numg):
        for g2 in range(g1, numg):
            #print('checking group', g1, g2)
            gd = abs(g1 - g2)
            if maxg[g1] + maxg[g2] < gsize * (gd - 1):
                continue
            if ming[g1] + ming[g2] > gsize * (gd + 1):
                continue
            for g1i in range(gsize*g1, min(gsize*(g1+1), size)):
                for g2i in range(max(g1i+1, gsize*g2), min(gsize*(g2+1), size)):
                    d = abs(g1i - g2i)
                    if A[g1i] + A[g2i] == d:
                        count += 1
    print(count)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import math

def solve(X: int):
    lim = 200

    for A in range(-lim, lim):
        for B in range(-lim, lim):
            x = math.pow(A, 5) - math.pow(B, 5)
            if X == int(x):
                print(A, B)
                return
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()
N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        lis.append([x, y, h])
        sx, sy, sh = x, y, h

for i in range(101):
    for j in range(101):
        
        cx, cy = i, j
        for K in range(len(lis)):
            x, y, h = lis[K]
            
            if h > 0 and sh + abs(sx - cx) + abs(sy - cy) != h + abs(cx - x) + abs(cy -y):
                break
            elif sh +  abs(sx - cx) + abs(sy - cy) > abs(cx - x) + abs(cx + y):
                break
            if K == len(lis) - 1:
                print(cx, cy, hight)
                exit()

### FIXED CODE ###

N = int(input())
lis = []
for _ in range(N):
    x, y, h = map(int, input().split())
    if h > 0:
        sx, sy, sh = x, y, h
    lis.append((x, y, h))
for i in range(101):
    for j in range(101):
        high = sh + abs(sx - i) + abs(sy - j)
        judge = -1
        for x, y, h in lis:
            if h > 0 and high != h + abs(x - i) + abs(y - j):
                judge = 0
                break
        if judge == 0:
            continue
        for x, y, h in lis:
            if h == 0 and high > abs(x - i) + abs(y - j):
                judge = 0
                break
        if judge == 0:
            continue
        
        print(i, j, sh + abs(sx - i) + abs(sy - j))
        exit()
# https://atcoder.jp/contests/abc070/tasks/abc070_c

from functools import reduce
import math

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def lcm_base(x, y):
    return (x * y // math.gcd(x, y))

def lcm_list(list):
    return reduce(lcm_base, list, 1)

lcm = lcm_list(T)

print(lcm)


### FIXED CODE ###

N = int(input())
T = []
for i in range(N):
    T.append(int(input()))

def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return y


ans = T[0]
for i in range(1, N):
    ans *= T[i] // gcd(ans, T[i])

print(ans)
n = int(input())
h = list(map(int, input().split()))

m = 0
ans  = []
while m < n - 1:
	c = 0
	for i in range(m, n-1):
		if h[i] >= h[i+1]:
			c += 1
		else:
			break
	m = i + 1
	ans.append(c)


print(max(ans))


### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))

m = 0
ans  = [0]
while m <= n - 3:
	c = 0
	for i in range(m, n-1):
		if h[i] >= h[i+1]:
			c += 1
		else:
			break
	m = i + 1
	ans.append(c)


print(max(ans))
K,S = map(int,input().split())
count=0

for x in range(K+1):
    for y in range(K+1):
        if 0 <= S-x-y <= K:
                count += 1

print(count)


### FIXED CODE ###

s = list(input().split(",",2))
a = " ".join(s)
print(a)
import itertools
import heapq
import sys
import functools
import operator
import numpy as np
input = sys.stdin.readline
#-------------
n,k = map(int,input().split())
a = list(map(int,input().split()))
#-------------
a.sort(reverse = True)
print(a)
w = 10**9 + 7
ans = 1
if k%2 == 1:
  for i in range(k):
    ans *= a[i]
    print(ans % w)

else:
  if n%2 == 0:
    a_new = [a[2*i]*a[2*i+1] for i in range(n//2)]
    a_new.sort(reverse = True)
    print(a_new)
    for j in range(k//2):
      ans *= a_new[j]
      print(ans % w)
      
  else:
    a_plus = heapq.nlargest(k, a)
    a_minus = heapq.nsmallest(k, a)
    a_plus.sort(reverse = True)
    a_minus.sort()
    a_plus_new = [a_plus[2*i]*a_plus[2*i+1] for i in range(len(a_plus))]
    a_minus_new = [a_minus[2*i]*a_minus[2*i+1] for i in range(len(a_minus))]
    a_new = a_plus_new + a_minus_new
    a_new.sort(revserse = True)
    for j in range(k//2):
      ans *= a_new[j]
      print(ans % w)

### FIXED CODE ###

import sys
 
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = pow(10, 9)+7
zero = 0
plus = []
minus = []
for i in range(n):
  if a[i] == 0:
    zero += 1
  elif a[i] > 0:
    plus.append(a[i])
  else:
    minus.append(a[i])
 
P, M = len(plus), len(minus)
plus.sort(reverse=True)
minus.sort()
ans = 1
if n == k:
  for i in range(n):
    ans *= a[i]
    ans %= mod
elif P+M < k:
  ans = 0
elif P == 0:
  if zero and k%2:
    ans = 0
  else:
    if k%2:
      minus.reverse()
    for i in range(k):
      ans *= minus[i]
      ans %= mod
else:
  q = 0
  if k%2:
    ans *= plus[0]
    ans %= mod
    q = 1
  judge = []
  for i in range((len(plus)-q)//2):
    judge.append(plus[2*i+q]*plus[2*i+q+1])
  for i in range(len(minus)//2):
    judge.append(minus[2*i]*minus[2*i+1])
  judge.sort(reverse=True)
  for i in range(k//2):
    ans *= (judge[i]%mod)
    ans %= mod
 
print(ans)
N,L = map(int,input().split())
l = []
ll = []
for i in range(1,N+1):
  l.append(L+i-1)
  ll.append(abs(L+i-1))
a = l.index(min(ll))
print(sum(l)-a)

### FIXED CODE ###

n, l = map(int, input().split())
a = []
b = []
for i in range(1,n+1):
    a.append(l+i-1)
    b.append(abs(l+i-1))
x = b.index(min(b))
print(sum(a)-a[x])
count = 1
while True:
????????x = input().strip()
????????if x == '0':
????????????????break
????????print('Case %s: %s' % (count, x))
????????count = count + 1

### FIXED CODE ###

count = 1                                                                   
while True:
    x = input().strip()
    if x == '0':
        break
    print('Case %s: %s' % (count,x))
    count = count + 1
import datetime

M,D = map(int,input().split())
tdy = datetime.date(2019, M, D)
tmr = now + datetime.timedelta(days=1)

if tmr.day == 1:
    print("1")
else:
    print("0")

### FIXED CODE ###

n = []
for i in range(2):
    n.append(list(map(int, input().split())))
    
if n[1][1] == 1:
    print("1")
else:
    print("0")
s = list(str(input()))
A = int(s[0]+s[1])
B = int(s[2]+s[3])
if 0 < a < 13:
    if 0 < b < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")

else:
    if 0 < b < 13:
        print("YYMM")
    else:
        print("NA")
print(ans)


### FIXED CODE ###

s = list(str(input()))
a = int(s[0]+s[1])
b = int(s[2]+s[3])
if 0 < a < 13:
    if 0 < b < 13:
        print("AMBIGUOUS")
    else:
        print("MMYY")

else:
    if 0 < b < 13:
        print("YYMM")
    else:
        print("NA")
n, k = map(int, input().split())
s = input()

sl = []
c = 1
if (s[0] == "1"):
    sl.append(0)
for i in range(n):
    if (i != 0):
        if (s[i] == s[i-1]):
            c += 1
        else:
            sl.append(c)
            c = 1
sl.append(c)

ruisekiwa = [0]
sums = []
for i in range(len(sl)):
    ruisekiwa.append(ruisekiwa[i] + sl[i])
# print(sl)
# print(ruisekiwa)
for i in range(len(sl)):
    if(k % 2 == 1 and i % 2 == 0 or k % 2 == 0 and i % 2 == 1):
        left = i-k
        if (left < 0):
            left = 0
        right = i + k+1
        if (right >= len(ruisekiwa)):
            right = len(ruisekiwa)-1
        # print(ruisekiwa[right], "-", ruisekiwa[left],
        #      "=", ruisekiwa[right]-ruisekiwa[left])
        sums.append(ruisekiwa[right]-ruisekiwa[left])
print(max(sums))

### FIXED CODE ###

n, k = map(int, input().split())
s = str(input())

sl = []
c = 1
if (s[0] == "1"):
    sl.append(0)
for i in range(n):
    if (i != 0):
        if (s[i] == s[i-1]):
            c += 1
        else:
            sl.append(c)
            c = 1
sl.append(c)

ruisekiwa = [0]
sums = []
ans = 0
w = 2*k+1

if (w > len(sl)):
    print(n)
    exit()
for i in range(len(sl)):
    ruisekiwa.append(ruisekiwa[i] + sl[i])
# print(sl)
# print(ruisekiwa)
for i in range(len(sl)):
    if(k % 2 == 1 and i % 2 == 0 or k % 2 == 0 and i % 2 == 1):
        left = i-k
        if (left < 0):
            left = 0
        right = i + k+1
        if (right >= len(ruisekiwa)):
            right = len(ruisekiwa)-1
        # print(ruisekiwa[right], "-", ruisekiwa[left],
        #      "=", ruisekiwa[right]-ruisekiwa[left])
        ans = max(ans, ruisekiwa[right]-ruisekiwa[left])
print(ans)
S = list(input())

def f(S):
    new_array = []
    mark = False
    if len(S) == 2:
        if S[0] != S[1]:
            return []
        else:
            return S

    for i in range(0, len(S) - 2):
        if i % 3 == 0:
            if S[i] == S[i + 1] and S[i + 1] == S[i + 2]:
                new_array += [S[i], S[i+1], S[i+2]]
            elif S[i] != S[i + 1]:
                new_array += [S[i+2]]
                if mark == False:
                    mark = True
            elif S[i + 1] != S[i + 2]:
                new_array += [S[i]]
                if mark == False:
                    mark = True
    
    if len(S) % 3 == 1:
        if S[-2] != S[-1]:
            new_array.pop(-1)
        else:
            new_array += [S[-1]]
    elif len(S) % 3 == 2:
        if S[-2] == S[-1]:
            new_array += [S[-2], S[-1]]

    if mark == True:
        return f(new_array)
    else:
        return new_array


print(len(S) - len(f(S)))

### FIXED CODE ###

S = list(input())
print(min(S.count('0'), S.count('1')) * 2)
import sys
N, M = map(int, input().split())

a_list = [0] * M

for m in range(M):
    a_list[m] = int(input())

for m in range(M - 1):
    if a_list[m] + 1 == a_list[m + 1]:
        print(0)
        sys.exit()

range_list = [i for i in range(1, N + 1)]
new_list = [0] * (M + 1)

a = 0
if a_list[0] == 1:
    new_list[0] = []
else:
    new_list[0] = [0] + range_list[0: a_list[0] - 1]
new_list[M] = range_list[a_list[M - 1]:]

if M - 1 >= 1:
    for m in range(1, M):
        new_list[m] = range_list[a_list[m - 1]: a_list[m] - 1]

MOD = 1000000007
#print(new_list)1

def fib(n):
    dp_list = [0] * n
    dp_list[0] = 1
    dp_list[1] = 2
    
    for i in range(2, n):
        dp_list[i] = dp_list[i - 1] + dp_list[i - 2]
    return dp_list[n - 1]

count = 1
for item in new_list:
    if not item:
        continue
    else:
        count *= fib(len(item) - 1)
        count %= MOD
print(count)

### FIXED CODE ###

import sys
N, M = map(int, input().split())

MOD = 1000000007

def fib(n):
    dp_list = [0] * n
    dp_list[0] = 1
    if n == 1:
        return 1
    dp_list[1] = 2
    
    for i in range(2, n):
        dp_list[i] = dp_list[i - 1] + dp_list[i - 2]
    return dp_list[n - 1]

if M == 0:
    print(fib(N) % MOD)
    sys.exit()

a_list = [0] * M

for m in range(M):
    a_list[m] = int(input())

for m in range(M - 1):
    if a_list[m] + 1 == a_list[m + 1]:
        print(0)
        sys.exit()
    else:
        continue

range_list = [i for i in range(1, N + 1)]
new_list = [0] * (M + 1)


new_list[0] = [0] + range_list[0: a_list[0] - 1]
new_list[M] = range_list[a_list[M - 1]:]

if M - 1 >= 1:
    for m in range(1, M):
        new_list[m] = range_list[a_list[m - 1]: a_list[m] - 1]

count = 1
for item in new_list:
    if not item or len(item) == 1:
        continue
    else:
        count *= (fib(len(item) - 1) % MOD)
        count %= MOD
        #print(count)
print(count)
s = input()

for i in range(1, 4):
  c = "R" * i
  if c in s:
    ans = c
    
print(ans)
  


### FIXED CODE ###

s = input()
 
if 'RRR' in s:
  i = 3
elif 'RR' in s:
  i = 2
elif 'R' in s:
  i = 1
else:
  i = 0
print(i)
n=int(input())
l=list(map(int, input().split()))
tester=True
for i in range(n):
    for j in range(i+1,n):  
        if l[i]==l[j]:
            tester=False
            break

if tester==True:
    print('YES')
else:
    print('NO')




### FIXED CODE ###

s,t=map(str, input().split())
a,b=map(int, input().split())
u=input()
if s==u:
    if t==u:
        print(a-1,b-1)
    else:
        print(a-1,b)
else:
    if t==u:
        print(a,b-1)
    else:
        print(a,b)
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

N,M=map(int,input().split())

if N%2:
    print(unko)


x,y=N//2,N//2+1
for i in range(M):
    print(x-i,y+i)


### FIXED CODE ###

from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

N,M=map(int,input().split())

if N%2:
    x,y=N//2,N//2+1
    for i in range(M):
        print(x-i,y+i)

else:

    for i in range(M//2+M%2):
        print(1+i,1+M-1*(M%2==0)-i)
    for i in range(M//2):
        print(N-(M-M%2)+i,N-i)
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a-1)]
d=[[]for i in range(a)]
for i in range(a-1):
  ca=c[i][0]
  cb=c[i][1]
  d[ca-1].append(cb-1)
  d[cb-1].append(ca-1)
g=[0 for i in range(a)]
def s(i,d,g):
  g[i]=1
  global e
  f=1
  if i==0:
    for j in range(len(d[i])):
      f=f*(b-1-j)
  else:
    for j in range(len(d[i])-1):
      f=f*(b-2-j)   
  e=e*f
  for j in range(len(d[i])):
    if g[d[i][j]]==0:
      s(d[i][j],d,g)
  return

i=0
e=b
s(i,d,g)
print(e%1000000007)
  

### FIXED CODE ###

from collections import deque
a,b=map(int,input().split())
c=[list(map(int,input().split())) for i in range(a-1)]
d=[[]for i in range(a)]
for i in range(a-1):
  ca=c[i][0]
  cb=c[i][1]
  d[ca-1].append(cb-1)
  d[cb-1].append(ca-1)
g=[0 for i in range(a)]
q=deque()
q.append(0)
e=b
while len(q):
  i=q.pop()
  h=len(d[i])
  g[i]=1
  if i==0:
      f=b-1
  else:
    f=b-2
  g[i]=1
  for j in range(h):
    if g[d[i][j]]==0:
      q.append(d[i][j])
      e=(e*f)%1000000007
      f-=1


print(e%1000000007)
from itertools import permutations

n = int(input())
p=list(map(int, input().split()))
q=list(map(int, input().split()))

cnt=0
for v in permutations(range(1,N+1), N):
    cnt +=1
    if(p==v):
        a = cnt
    if(q==v):
        b = cnt

print(abs(a-b))

### FIXED CODE ###

import itertools
n = int(input())
p = tuple(((map(int,input().split()))))
q = tuple(((map(int,input().split()))))

num = []
for i in range(1,n+1):
    num.append(i)
ans = []
for i in itertools.permutations(num,n):
    ans.append(i)

print(abs(ans.index(p)-ans.index(q)))
import numpy as np
K, N = map(int, input().split())
A = list(map(int, input().split()))
D = np.zeros((N,N))
for i in range(N-1):
  for j in range(i+1,N):
    a = abs(A[i]-A[j])
    D[i][j] = min(a, K-a)
    D[j][i] = min(a, K-a)
ans = 10 ** 12
print (int(min(np.sum(D, axis=0))))


### FIXED CODE ###

K, N = map(int, input().split())
A = list(map(int, input().split()))
ans = min(A[-1]-A[0],K-(A[-1]-A[0]))
for i in range(N-1):
  ans = max(ans,A[i+1]-A[i])
print (K-ans)