Harryxun/stf_run huggingface dataset:
n, m = map(int, input().split())
cnt = 0
like = []
frag = 1
for i in range(n):
  s = list(map(int, input().split()))
  like.append(s[1:])
for i in range(m):
  for j in range(n):
  	if(!(i+1 in like[j])):
      frag = 0
    if(frag == 0):
      break
  if(frag == 1):
    cnt += 1
print(cnt)
  

### FIXED CODE ###

n, m = map(int, input().split())
cnt = 0
like = []
frag = 1
for i in range(n):
  s = list(map(int, input().split()))
  like.append(s[1:])
for i in range(m):
  for j in range(n):
    if(not(i+1 in like[j])):
      frag = 0
      break
  if(frag == 1):
    cnt += 1
  frag = 1
print(cnt)
import itertools


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

if n == 2:
    print(max(a), min(a))
else:
    a = list(set(a))
    num = 0
    for x in itertools.combinations(a, 2):
        if num < len(list(itertools.combinations(range(max(x)), min(x)))):
            num = len(list(itertools.combinations(range(max(x)), min(x))))
            x1 = max(x)
            x2 = min(x)
    print(x1, x2)

### FIXED CODE ###

n = input()
a = sorted(int(x) for x in input().split())
max_a = a[-1]
print(max_a, min(a, key=lambda x: abs(max_a - x * 2)))
from itertools import combinations

line = input()
ant = [int(n) for n in line.split()]
comb = tuple(combinations(ant[:5], 2))

for i,j in comb:
    if j-i > ant[5]:
        a = -1
        print(":(")
        break
    else:
        pass
if a != -1:
    print("Yay!")



### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if a<b<c<d<e :
  if e - a <= k :
    if d - a <= k:
      if c - a <= k:
        if b - a <= k:
          print('Yay!')
  else:
    print(":(")
s=input()[::-1]

phrase=("dream"[::-1],
        "dreamer"[::-1],
        "erase"[::-1],
        "eraser"[::-1])


def dayDream(word):
    if word[:7] in phrase:
        return dayDream(word[7:])
    elif word[:6] in phrase:
        return dayDream(word[6:])
    elif word[:5] in phrase:
        return dayDream(word[5:])
    
    if len(word)==0:
        return True
    else:
        return False


print(dayDream(s))

### FIXED CODE ###

s=input()[::-1]

isOk=False
while len(s)>=5:
    if s[:5]=="maerd" or s[:5]=="esare":
        s=s[5:]
    elif len(s)>=6 and s[:6]=="resare":
        s=s[6:]
    elif len(s)>=7 and s[:7]=="remaerd":
        s=s[7:]
    else:
        break
    
    if len(s)==0:
        isOk=True

print("YES") if isOk else print("NO")
n,k=[int(x) for x in input().split()]
#Sequence decreases first then starts increasing.This point has to be identified.
prev,cur=n+1,n
if k<=0:
  print(n)
else:
	rem = n%k
    print(abs(rem-k))


### FIXED CODE ###

n,k=[int(x) for x in input().split()]
#Sequence decreases first then starts increasing.This point has to be identified.
prev,cur=n+1,n
if k<=0:
  print(n)
else:
	rem = n%k
	print(min(rem,abs(rem-k)))
import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(M)]

    root = [[] for _ in range(M + 1)]
    for a, b in AB:
        root[a].append(b)
        root[b].append(a)

    que = deque()
    que.append(1)
    front = [-1] * (N + 1)
    front[1] = 1
    while que:
        point = que.popleft()
        for i in root[point]:
            if front[i] > 0:
                continue
            front[i] = point
            que.append(i)

    if min(front[2:]) < 0:
        print('No')
    else:
        print('Yes')
        for i in range(2, N + 1):
            print(front[i])

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

def main():
    N, M = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(M)]

    root = [[] for _ in range(N + 1)]
    for a, b in AB:
        root[a].append(b)
        root[b].append(a)

    que = deque()
    que.append(1)
    front = [-1] * (N + 1)
    front[1] = 1
    while que:
        point = que.popleft()
        for i in root[point]:
            if front[i] > 0:
                continue
            front[i] = point
            que.append(i)

    if min(front[1:]) < 0:
        print('No')
    else:
        print('Yes')
        for i in range(2, N + 1):
            print(front[i])

if __name__ == '__main__':
    main()
n=int(input())
a=int(input())
n%500=m
if m<=a:
    print("Yes")
else :
    print("No")


### FIXED CODE ###

n=int(input())
a=int(input())

if n<500:
    if n<=a:
        print("Yes")
    else:
        print("No")
elif n>500 and (n%500)<=a:
    print("Yes")
else :
    print("No")
N, K = (int(i) for i in input().split())
D = 0
for i in range(1, N + 1):
    for j in range(1, N + 1):
        A = i + j
        if A % K == 0:
          for k in range(1, N + 1):
            B = j + k
            C = i + k
            if B % K == 0 and C % K == 0:
              D += 1
print(D)

### FIXED CODE ###

K = int(input())
if K % 2 == 0:
    A = (K // 2) * (K // 2)
    print(A)
else:
    B = ((K // 2) + 1) * (K // 2)
    print(B)
import math
#N = int(input())
a,b= map(int,input().split())
#v =list(map(int,input().split()))
# [list(map(int,input().split())) for i in range(N)]

print(a * b / math.gcd(a, b))


### FIXED CODE ###

a,b= map(int,input().split())
#v =list(map(int,input().split()))
# [list(map(int,input().split())) for i in range(N)]
from fractions import gcd
def lcm(a,b): return a*b//gcd(a,b)

print(lcm(a,b))
import numpy as np
N, M = [int(i) for i in input().split()]

gate = np.zeros(N+1)
for i in range(0, M):
    L, R = [int(j) for j in input().split()]
    gate[L-1] += 1
    gate[R] -=1

count = 0
for i in range(1, len(gate)):
    gate[i] = gate[i] + gate[i-1]

for i in range(0, M):
    if gate[i] == M:
        count += 1

print(count)

### FIXED CODE ###

import numpy as np
N, M = [int(i) for i in input().split()]

gate = np.zeros(N+1)
for i in range(0, M):
    L, R = [int(j) for j in input().split()]
    gate[L-1] += 1
    gate[R] -=1

count = 0
for i in range(1, len(gate)):
    gate[i] = gate[i] + gate[i-1]
    if gate[i] == M:
        count += 1

if gate[0] == M:
    count += 1
print(count)
n = int(input())
S = list(map(int, input().split()))
SENTINEL = 10 ** 9 + 1
count = 0

def merge(S, left, mid, right):
    n1 = mid - left
    n2 = right - mid
    for i in range(n1):
        L[i] = S[left + i]
    for i in range(n2):
        R[i] = S[mid + i]
    L[n1] = R[n2] = SENTINEL
    i = j = 0
    for k in range(left, right):
        count += 1
        if(L[i] <= R[i]):
            S[k] = L[i]
            i += 1
        else:
            S[k] = R[j]
            j += 1

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

mergeSort(S, 0, n)
print(*S)
print(count)

### FIXED CODE ###

n = int(input())
S = list(map(int, input().split()))
SENTINEL = 10 ** 9 + 1
count = 0
 
def merge(S, left, mid, right):
    L = S[left:mid] + [SENTINEL]
    R = S[mid:right] + [SENTINEL]
    i = j = 0
    global count
    for k in range(left, right):
        count += 1
        if (L[i] <= R[j]):
            S[k] = L[i]
            i += 1
        else:
            S[k] = R[j]
            j += 1
 
def mergeSort(S, left, right):
    if(left + 1 < right):
        mid = (left + right) // 2
        mergeSort(S, left, mid)
        mergeSort(S, mid, right)
        merge(S, left, mid, right)
 
mergeSort(S, 0, n)
print(*S)
print(count)
S=input()

if S=='Sunny':
  print('Cloudy')
elif S=='Cloudy':
  ptint('Rainy')
elif S=='Rainy':
  print('Sunny')

### FIXED CODE ###

S=input()

if S=='Sunny':
  print('Cloudy')
elif S=='Cloudy':
  print('Rainy')
elif S=='Rainy':
  print('Sunny')
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

def main():
    from sympy import sieve
    import sys
    import math
    import copy
    input=sys.stdin.readline
    n=I()
    a=L()
    
    primelist=[i for i in sieve.primerange(1,int(math.sqrt(1e+6))+1)]
    
    dic={}
    for i in range(n):
        for j in primelist:
            if a[i]%j==0:
                if j in dic:
                    dic[j].add(a[i])
                else:
                    dic[j]={a[i]}
    ans=0
    a=list(set(a))
    keyset=set([i for i in dic.keys()])
    if len(a)==1:
        print(0)
        exit()
    for i in range(len(a)):
        tmpset=copy.copy(keyset)
        seta=set(a)
        tmp=[]
        for j in primelist:
            if a[i]%j==0:tmp.append(j)
        tmpset=tmpset - set(tmp)
        for j in tmpset:
            seta=seta-dic[j]
        ans+=1 if(min(seta)==a[i]) else 0 
    print(ans)
    
if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import sys
    input=sys.stdin.readline
    n=int(input())
    a=list(map(int,input().split()))
    adic={}
    for i in range(n):
        if a[i] in adic:
            adic[a[i]]+=1
        else:
            adic[a[i]]=1
    ans=0
    a=list(set(a))
    a.sort()
    maxa=max(a)
    dp=[True for i in range(maxa+1)]
    for i in a:
        if dp[i] and adic[i]==1:ans+=1
        j=i+i
        while j<=maxa:
            dp[j]=False
            j+=i
    print(ans)

if __name__ == '__main__':
    main()
from sys import stdin
from itertools import accumulate
readline = stdin.readline

N, W = map(int, input().split())
vs = [[] for _ in range(4)]
w, v = map(int, input().split())
w1 = w
vs[0].append(v)
for _ in range(N - 1):
    w, v = map(int, input().split())
    vs[w - w1].append(v)

for i in range(4):
    vs[i].sort(reverse=True)
    vs[i] = [0] + list(accumulate(vs[i]))

result = 0
for i in range(len(vs[0]) + 1):
    a = W - w1 * i
    if a < 0:
        break
    for j in range(len(vs[1]) + 1):
        b = a - (w1 + 1) * j
        if b < 0:
            break
        for k in range(len(vs[2]) + 1):
            c = b - (w1 + 2) * k
            if c < 0:
                break
            t = vs[0][i] + vs[1][j] + vs[2][k]
            for l in range(len(vs[3]) + 1):
                d = c - (w1 + 3) * l
                if d < 0:
                    break
                result = max(result, t + vs[3][l])
print(result)


### FIXED CODE ###

from sys import stdin
from itertools import accumulate
readline = stdin.readline

N, W = map(int, input().split())
vs = [[] for _ in range(4)]
w, v = map(int, input().split())
w1 = w
vs[0].append(v)
for _ in range(N - 1):
    w, v = map(int, input().split())
    vs[w - w1].append(v)

for i in range(4):
    vs[i].sort(reverse=True)
    vs[i] = list(accumulate(vs[i]))

result = 0
for i in range(len(vs[0]) + 1):
    a = W - w1 * i
    if a < 0:
        break
    for j in range(len(vs[1]) + 1):
        b = a - (w1 + 1) * j
        if b < 0:
            break
        for k in range(len(vs[2]) + 1):
            c = b - (w1 + 2) * k
            if c < 0:
                break
            t = 0
            if i != 0:
              t += vs[0][i - 1]
            if j != 0:
              t += vs[1][j - 1]
            if k != 0:
              t += vs[2][k - 1]
            for l in range(len(vs[3]) + 1):
                d = c - (w1 + 3) * l
                if d < 0:
                    break
                if l == 0:
                    result = max(result, t)
                else:
                    result = max(result, t + vs[3][l -1])
print(result)
N = int(input())
M = int(input())

A = 0

for i in range(M):
    A += int(input())

if M < A:
    print(N-A)

else:
    print(-1)

### FIXED CODE ###

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

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

B = sum(A)

if N >= B:
  print(N-B)

else:
  print('-1')
n,m,k = list(map(int,input().split()))
a = list(map(int,input().split()))[::-1]
b = list(map(int,input().split()))[::-1]
cnt_book=0
cnt_time=0

while cnt_time<k:
  if not a or a[-1]>=b[-1]:
    cnt_time+=b.pop()
  else:
    cnt_time+=a.pop()
  if cnt_time>k:
    break    
  cnt_book+=1

print(cnt_book)


### FIXED CODE ###

import bisect

n,m,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
b = [0]+list(map(int,input().split()))

for i in range(1,n+1):
  a[i] = a[i]+a[i-1]
for j in range(1,m+1):
  b[j] = b[j]+b[j-1]

book_cnt=0
for a_cnt in range(n+1):
  if a[a_cnt]>k:
    continue
  rest=k-a[a_cnt]
  b_cnt=bisect.bisect(b,rest)-1
  book_cnt=max(book_cnt,a_cnt+b_cnt)

print(book_cnt)
def intinput(): return map(int,input().split())

def ab(i):
    global c,l,x
    while len(l[i])>0:
        x[l[i][0]]=c.pop(0)
        l[l[i][0]].remove(i)
        ab(l[i][0])
        l[i].pop(0)
    return

n=int(input())
l = [[] for _ in range(n+1)]
for i in range(n-1):
    a,b=intinput()
    l[a].append(b)
    l[b].append(a)
c = list(intinput())
c.sort(reverse=1)
x = [0 for _ in range(n+1)]
x[1]=c.pop(0)
for i in range(1,n+1):
    ab(i)
print(sum(x[2:]))
f = ""
q= len(x[1:])
for i in range(q):
    if i != q-1:
        f += str(x[i+1])+" "
    else:
        f += str(x[i+1])
print(f)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000) 

def intinput(): return map(int,input().split())

def ab(i):
    global c,l,x
    while len(l[i])>0:
        x[l[i][0]] = c.pop(0)
        l[l[i][0]].remove(i)
        ab(l[i][0])
        l[i].pop(0)
    return

n=int(input())
l = [[] for _ in range(n+1)]
for i in range(n-1):
    a,b=intinput()
    l[a].append(b)
    l[b].append(a)
c = list(intinput())
c.sort(reverse=1)
x = [0 for _ in range(n+1)]
x[1]=c.pop(0)
for i in range(1,n+1):
    ab(i)
print(sum(x[2:]))
f = ""
q= len(x[1:])
for i in range(q):
    if i != q-1:
        f += str(x[i+1])+" "
    else:
        f += str(x[i+1])
print(f)
foods = [int(input()) for i in range(5)]

li = []
for i in range(5):
    if foods[i] % 10 != 0:
        li.append(10-foods[i]%10)
        foods[i] += (10-foods[i]%10)
if li = []:
    ans = sum(foods)
else:    
    ans = sum(foods) - max(li)
print(ans)

### FIXED CODE ###

foods = [int(input()) for i in range(5)]

li = []
for i in range(5):
    if foods[i] % 10 != 0:
        li.append(10-foods[i]%10)
        foods[i] += (10-foods[i]%10)
if li == []:
    ans = sum(foods)
else:    
    ans = sum(foods) - max(li)
print(ans)
n,m = map(int,input().split())
a_ls = list(map(int, input().split()))
n_b = 0
b_ls = [[0,0] for _ in range(m)]
for i in range(m):
    num, c = map(int,input().split())
    n_b += num
    b_ls[i] = [num,c]
d_ls = [0] * (n+n_b)
c_ls = [0] * n_b
j = 0
rest = b_ls[0][0]
i = 0
while j < n_b:
    c_ls[j] = b_ls[i][1]
    j += 1
    rest -= 1
    if rest <= 0:
        i += 1
        if i == m:
            break
        rest = b_ls[i][0]
for i in range(n+n_b):
    if i < n:
        d_ls[i] = a_ls[i]
    else:
        d_ls[i] = c_ls[i-n]
d_ls.sort(reverse= True)
print(sum(d_ls[:n]))



### FIXED CODE ###

from collections import Counter
n,m = map(int,input().split())
a_ls = list(map(int, input().split()))
counter = Counter(a_ls)
for i in range(m):
    b,c = map(int,input().split())
    counter[c] += b

cards = sorted(counter.items(), key = lambda x:x[0], reverse=True)
rest = n
Sum = 0
for num, count in cards:
    if count < rest:
        Sum += num * count
        rest -= count
    else:
        Sum += rest * num
        break
print(Sum)
a1 = input()
a2 = input()
a3 = input()
if(a1+a2+a3<22):
 print("win")
else:
 print("bust")


### FIXED CODE ###

a1,a2,a3 = map(int,input().split())
if(a1+a2+a3<22):
 print("win")
else:
 print("bust")
D=int(input('D='))
T=int(input('T='))
S=int(input('S='))

if (D/S)<=T:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

D,T,S = map(int, input().split())

if (D/S)<=T:
    print('Yes')
else:
    print('No')
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
answer = [[0] * W] * H
# True_answer = []
input_list = []
for i in range(1, N+1):
    for _ in range(a[i-1]):
        input_list.append(i)

for i in range(H):
    for j in range(W):
        if i % 2 == 0:
            # print('2')
            answer[i][j] = input_list[5 * i + j]
            # print(answer[0], answer[1], answer[2])
        else:
            # print('not2')
            answer[i][W-j-1] = input_list[5 * i + j]
            # print(answer)
        if (j+1) % W == 0:
            # True_answer[i] += answer[i]
            print(*answer[i])



# print(input_list)
# print(answer)
# print(True_answer)


### FIXED CODE ###

H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
answer = [[0] * W] * H
# True_answer = []
input_list = []
for i in range(1, N+1):
    for _ in range(a[i-1]):
        input_list.append(i)

for i in range(H):
    for j in range(W):
        if i % 2 == 0:
            # print('2')
            answer[i][j] = input_list[W * i + j]
            # print(answer[0], answer[1], answer[2])
        else:
            # print('not2')
            answer[i][W-j-1] = input_list[W * i + j]
            # print(answer)
        if (j+1) % W == 0:
            # True_answer[i] += answer[i]
            print(*answer[i])



# print(input_list)
# print(answer)
# print(True_answer)
# Problem C - Tsundoku

# input
N, M, K = map(int, input().split())
a_nums = list(map(int, input().split()))
b_nums = list(map(int, input().split()))

# initialization
a_i = -1
b_i = -1
max_count = 0
cur_count = 0

# dfs search
def dfs(a_i, b_i):
    global max_count
    global cur_count
    global K

    if a_i>=N or b_i>=M:
        if cur_count>max_count:
            max_count = cur_count
        return

    # right check
    if a_i+1<N:
        if K - a_nums[a_i+1]>=0:
            K -= a_nums[a_i + 1]
            cur_count += 1
            dfs(a_i+1, b_i)
            cur_count -= 1
            K += a_nums[a_i + 1]
        else:
            if cur_count>max_count:
                max_count = cur_count
    else:
        if cur_count>max_count:
            max_count = cur_count

    # left check
    if b_i + 1<M:
        if K - b_nums[b_i + 1]>=0:
            K -=b_nums[b_i + 1]
            cur_count += 1
            dfs(a_i, b_i+1)
            cur_count -= 1
            K += b_nums[b_i + 1]
        else:
            if cur_count>max_count:
                max_count = cur_count
    else:
        if cur_count>max_count:
            max_count = cur_count

dfs(a_i, b_i)

# output
print(max_count)


### FIXED CODE ###

# Problem C - Tsundoku

# input
N, M, K = map(int, input().split())
a_nums = list(map(int, input().split()))
b_nums = list(map(int, input().split()))

# initialization
max_count = 0
b_i = M
a_cums = [0]*(N+1)
b_cums = [0]*(M+1)
for i in range(1, N+1):
    if i>1:
        a_cums[i] = a_cums[i-1] + a_nums[i-1]
    else:
        a_cums[i] = a_nums[i-1]
for i in range(1, M+1):
    if i>1:
        b_cums[i] = b_cums[i-1] + b_nums[i-1]
    else:
        b_cums[i] = b_nums[i-1]

for i in range(N+1):
    if a_cums[i]<=K:
        while b_i>0 and a_cums[i]+b_cums[b_i]>K:
            b_i -= 1
        if i+b_i>max_count:
            max_count = i+b_i

# output
print(max_count)
s=input()
count=0
for i in range(len(s)):
    if s[i]=="A" or s[i]=="?":
        for j in range(len(s)-1,i,-1):
            if s[j]=="C" or s[j]=="?":
                k=s[i+1:j]
                bb=k.count("B")
                dd=k.count("?")
                count=(count+bb*3**dd+dd*3**(dd-1))%(10**9+7)
print(count)

### FIXED CODE ###

import sys
input = sys.stdin.readline
MOD = 10 ** 9 + 7

def main():
    string = input().strip()
    n = len(string)
    dp = [[0, 0, 0, 0] for _ in range(n + 1)]
    dp[0][0] = 1
    for i, s in enumerate(string):
        if s == "A":
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1] + dp[i][0]
            dp[i + 1][2] = dp[i][2]
            dp[i + 1][3] = dp[i][3]
        elif s == "B":
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]
            dp[i + 1][2] = dp[i][2] + dp[i][1]
            dp[i + 1][3] = dp[i][3]
        elif s == "C":
            dp[i + 1][0] = dp[i][0]
            dp[i + 1][1] = dp[i][1]
            dp[i + 1][2] = dp[i][2]
            dp[i + 1][3] = dp[i][3] + dp[i][2]
        else:
            dp[i + 1][0] = 3 * dp[i][0]
            dp[i + 1][1] = 3 * dp[i][1] + dp[i][0]
            dp[i + 1][2] = 3 * dp[i][2] + dp[i][1]
            dp[i + 1][3] = 3 * dp[i][3] + dp[i][2]
        for j in range(4):
            dp[i + 1][j] %= MOD
    print(dp[-1][-1] % MOD)
    
main()
n = int(input())
home_list = input().split()
home_list.sort()
print(home_list[n-1] - home_list[0])

### FIXED CODE ###

n = int(input())
home_list = list(map(int, input().split()))
home_list.sort()
print(home_list[n-1] - home_list[0])
def main():
    import math
    import collections
    N = int(input())

    mod = 10**9+7
    AB = [tuple(map(int, input().split())) for i in range(N)]

    d = collections.defaultdict(set)
    i = 0
    ab = []
    for a, b in AB:
        g = math.gcd(a, b)
        a = a // g
        b = b // g
        # d[(a, b)] += 1
        if a > 0 and b < 0:
            a = -a
            b = -b
        d[(a, b)].add(i)
        ab.append((a, b))
        i += 1

    ans = 0
    r = set()

    dd = [1]
    for i in range(1, N+1):
        dd.append(dd[i-1]*2 % mod)

    r = set()
    ans = 1
    for (a, b) in d:
        if (a, b) in r:
            continue
        l1 = len(d[(a, b)])

        tmp = dd[l1]
        s = set()
        if (-b, a) in d:
            s |= d[(-b, a)]
        if (b, -a) in d:
            s |= d[(b, -a)]
        l2 = len(s)
        if l2:
            ans *= tmp + dd[l2] - 1
            N -= l1 + l2
            ans %= mod

            r.add((-b, a))
            r.add((b, -a))
        else:
            continue
    if N:
        ans *= dd[N]
    ans -= 1

    print(ans % mod)


main()


### FIXED CODE ###

def main():
    import math
    import collections
    N = int(input())

    mod = 10**9+7
    AB = [tuple(map(int, input().split())) for i in range(N)]

    d = collections.defaultdict(set)
    i = 0
    ans2 = 0
    for a, b in AB:
        if a == 0 and b == 0:
            N -= 1
            ans2 += 1
            continue
        g = math.gcd(a, b)
        if g != 0:
            a = a // g
            b = b // g

        d[(a, b)].add(i)
        i += 1

    ans = 0
    r = set()

    dd = [1]
    for i in range(1, N+1):
        dd.append(dd[i-1]*2 % mod)

    r = set()
    ans = 1
    for a, b in d:
        if (a, b) in r:
            continue
        s1 = d[(a, b)]
        if (-a, -b) in d:
            s1 |= d[(-a, -b)]
        l1 = len(s1)
        r.add((-a, -b))
        if l1:
            s2 = set()
            if (-b, a) in d:
                s2 |= d[(-b, a)]
            if (b, -a) in d:
                s2 |= d[(b, -a)]
            s2 -= s1
            l2 = len(s2)
            if l2:
                ans *= dd[l1] + dd[l2] - 1
                N -= l1 + l2
                ans %= mod
                r.add((-b, a))
                r.add((b, -a))
            else:
                continue
    if N:
        ans *= dd[N]
    ans += ans2
    ans -= 1
    print(ans % mod)


main()
A, B, C, D = map(int, input().split())

rad = 2 * math.pi * ((C / 12) - (D / 60))
cos = math.cos(rad)

if math.cos(rad) == 1:
    print(abs(A - B))
elif math.cos(rad) == -1:
    print(A + B)
else:
    print(math.sqrt(A**2 + B**2 - 2*A*B*cos))

### FIXED CODE ###

import math
A, B, C, D = map(int, input().split())

rad = 2 * math.pi * (((C / 12)+((5 / 60)*(D / 60))) - (D /60))

if math.cos(rad) == 1:
    print(abs(A - B))
elif math.cos(rad) == -1:
    print(A + B)
else:
    print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(rad)))