Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,M = inputIL()
S = inputS()

if M>=N:
  print(N)
  exit()
  
  
max_n = [0 for i in range(N+1)]

for i in range(1,N+1):
  s = S[max(0,i-M):i]
  l = len(s)
  mask = (1<<l) -1
  b = (~int(s, 2)) & mask
  if b == 0:
    max_n[i] = 0
    continue
  max_n[i] = math.floor(math.log(b)/math.log(2))+1
  
now = N
deme = []
while now != 0:
  x = max_n[now]
  if x == 0:
    print(-1)
    exit()
  now = now-x
  deme.append(x)

print(*deme[::-1])

### FIXED CODE ###

import sys
input = sys.stdin.readline

import math
import bisect

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

if "1"*M in S:
  print(-1)
  exit()  

S = [int(S[i]) for i in range(N+1)]

L = [(1<<i) -1 for i in range(1,M+1)]

max_n = [0]
mask = (1<<M) -1
b = 0
for i in range(N):
  b = ((b<<1) + (1- S[i])) & mask
  max_n.append(bisect.bisect_left(L,b)+1)

now = N
deme = []
while now != 0:
  x = max_n[now]
  now -= x
  deme.append(x)
print(*deme[::-1])
import sys
print(sys.stdin[::-1])

### FIXED CODE ###

a = 1
while a:
    print(input()[::-1])
    a = 0
n = int(input())
cnt_tb = [0]*n
for i in range(1, n + 1):
    j = 1
    tmp = i*j
    while (tmp <= n):
        cnt_tb[tmp] += 1
        j += 1
ans = 0
for i, cnt in enumerate(cnt_tb):
    ans += (i + 1) * cnt
print(ans)
    

### FIXED CODE ###

n = int(input())

L = [0] * (n + 1)

for i in range(1, n + 1):
    for j in range(1, (n // i)+1):
        L[i * j] += 1

i = 0
ans = 0
for i in range(len(L)):
    ans += i *L[i]

print(ans)
n = int(input())
 
ai = []
for i in range(n):
    ai.append(int(input()))

sorted_ai = sorted(ai, reverse=True)

alice = 0
bob = 0

for index, x in enumerate(sorted_ai):
    if (index % 2 == 0):
        alice += x
    else:
        bob += x
        
print(alice - bob)

### FIXED CODE ###

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

sorted_ai = sorted(ai, reverse=True)

alice = 0
bob = 0

for index, x in enumerate(sorted_ai):
    if (index % 2 == 0):
        alice += x
    else:
        bob += x
        
print(alice - bob)
string=input

string=string.split(' ')
A= int(A[0])
B= int(A[1])

if A>9 or B>9:
    print(-1)
    else:
        print(A*B)



### FIXED CODE ###


string=input()
string=string.split(' ')
A= int(string[0])
B= int(string[1])

if A>9 or B>9:
    print(-1)
else:
        print(A*B)
a,b=map(float,input().split())
print(trunc(a*b))

### FIXED CODE ###

import decimal
a,b=input().split()
a=int(a)
b=decimal.Decimal(b)
print(int(a*b))
s="".join(sorted(list(input())))
t="".join(sorted(list(input()),reverse=True))


if len(s)<len(t) and s==t[:len(s)]:
    print("Yes")
else:
    for i in range(len(s)):
        if s[i]!=t[i]:
            if s[i]<t[i]:
                print("Yes")
            else:
                print("No")
            break
        if i==len(s)-1:
            print("No")


### FIXED CODE ###

s="".join(sorted(list(input())))
t="".join(sorted(list(input()),reverse=True))


if len(s)<len(t) and s==t[:len(s)]:
    print("Yes")
else:
    for i in range(min([len(s),len(t)])):
        if s[i]!=t[i]:
            if s[i]<t[i]:
                print("Yes")
            else:
                print("No")
            break
        if i==min([len(s),len(t)])-1:
            print("No")
n, m = map(int, input().split(' '))
ai = list(sorted(map(int, input().split(' '))))
required_maches = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}

used_numbers = dict()

def evaluate(l):
    if l == None:
        return -9999999999999999999999999999999
    if l == []:
        return 0
    return int(''.join(reversed([str(i) for i in sorted(l)])))

min_maches = min([required_maches[x] for x in ai])
def find(matches_count_to_use):
    if matches_count_to_use not in used_numbers:
        if matches_count_to_use < 0:
            used_numbers[matches_count_to_use] = None
        elif matches_count_to_use == 0:
            used_numbers[matches_count_to_use] = []
        else:
            candidates = list(filter(
                lambda x: find(matches_count_to_use - required_maches[x]) != None, ai))
            if len(candidates) == 0:
                used_numbers[matches_count_to_use] = None
            else:
                number_to_use = max(candidates,
                    key=lambda x: evaluate(find(matches_count_to_use - required_maches[x]) + [x]))
                prev = find(matches_count_to_use - required_maches[number_to_use])
                used_numbers[matches_count_to_use] = prev + [number_to_use]
                
    return used_numbers[matches_count_to_use]
    
print(evaluate(find(n)))

### FIXED CODE ###

a, b = map(int, input().split(' '))
if b%a == 0 :
    print(a+b)
else:
    print(b-a)
n=int(input())
t,a=map(int,input().split())
H=list(map(int,inpt().split()))
minn=10**10
for i in range(n):
  if minn>abs((t*(1000)-6*H[i])-a):
    ans = H[i]
    minn=t*(1000)-6*H[i]
print(ans)
  

### FIXED CODE ###

n=int(input())
t,a=map(int,input().split())
H=list(map(int,input().split()))
minn=10**10
for i in range(n):
  if minn>abs((t*(1000)-6*H[i])-a*1000):
    ans = i
    minn=abs((t*(1000)-6*H[i])-a*1000)
print(ans+1)
from math import ceil
class sqrt_tree:
    def __init__(self,dat,f):
        self.dat = dat
        self.sq = int(len(dat) ** 0.5)
        self.f = f
        self.baqet = [self.f(dat[i * self.sq:(i + 1) * self.sq]) for i in range(self.sq)]
    
    #query
    def q(self,l,r):
        r += 1
        if ceil(l / self.sq) >= r // self.sq:
            return self.f(self.dat[l:r])
        ret = self.f(self.baqet[ceil(l / self.sq):r // self.sq])
        if l % self.sq:
            ret = self.f(ret,self.f(self.dat[l:l + self.sq]))
        if r % self.sq:
            ret = self.f(ret,self.f(self.dat[r - r % self.sq:r]))
        return ret

import sys
f = sys.stdin

_, d = map(int, f.readline().split())

x,y = {},{}
for line in f:
    xi, yi, bi = map(int, line.split())
    if bi not in x:
        x[bi],y[bi] = [],[]
    x[bi].append(xi)
    y[bi].append(yi)

b = sorted(x.keys())

xmax = sqrt_tree([max(x[bi]) for bi in b],max)
xmin = sqrt_tree([min(x[bi]) for bi in b],min)
ymax = sqrt_tree([max(y[bi]) for bi in b],max)
ymin = sqrt_tree([min(y[bi]) for bi in b],min)

def get_lr(b,d):
    l = r = 0
    while r < len(b) - 1:
        while b[l] + d < b[r]:
            l += 1
        for k in range(l,len(b)):
            if b[l] + d < b[k]:
                break
            r = k
        yield l,r
        r += 1
        l += 1
   
max_size = max((xmax.q(l,r) - xmin.q(l,r)) * (ymax.q(l,r) - ymin.q(l,r)) for l,r in get_lr(b,d))
print(max_size)

### FIXED CODE ###

import math
def segmentTree(dat, f, sentinel):
        pad = 2 ** math.ceil(math.log(len(dat),2))
        dat = [0] * pad + dat + [sentinel] * (pad - len(dat))
        for i in range(pad - 1, 0, -1):
            dat[i] = f(dat[i * 2],dat[i * 2 + 1])
        return dat

def get_lr(b,d):
    l = r = 0
    while r < len(b):
        while b[l] + d < b[r]:
            l += 1
        for r in range(r,len(b)):
            if b[l] + d < b[r]:
                r -= 1
                break
        r += 1
        yield l,r
        l += 1
    
import sys
f = sys.stdin

_, d = map(int, f.readline().split())

xyb = []
for line in f:
    xyb.append(tuple(map(int, line.split())))
from operator import itemgetter
xyb.sort(key=itemgetter(2))

x = [xybi[0] for xybi in xyb]
y = [xybi[1] for xybi in xyb]
b = [xybi[2] for xybi in xyb]

xmax = segmentTree(x,max,sentinel = 0)
xmin = segmentTree(x,min,sentinel = 2000000)
ymax = segmentTree(y,max,sentinel = 0)
ymin = segmentTree(y,min,sentinel = 2000000)


pad = len(xmax) // 2
max_size = 0
def create_index(l,r):
    index = []
    ia = index.append
    while l < r:
        if r & 1:
            r -= 1
            ia(r)
        if l & 1:
            ia(l)
            l += 1
        l >>= 1
        r >>= 1
    return index

for l,r in get_lr(b,d):
    l += pad 
    r += pad
    index = create_index(l,r)

    now_xmax = max(xmax[i] for i in index)
    now_ymax = max(ymax[i] for i in index)
    if max_size < now_xmax * now_ymax:
        max_size = max(max_size,((now_xmax - min(xmin[i] for i in index)) * (now_ymax - min(ymin[i] for i in index))))
print(max_size)
# coding: utf-8
import sys


def main():
  n = int(input())
  a = int(input())
  b = n // a
  

  if (n - b * 500) <= a:
    print('Yes')
  
  else:
    print('No')
  
  return 0


if __name__ == '__main__':
  main()

### FIXED CODE ###

# coding: utf-8
import sys


def main():
  n = int(input())
  a = int(input())
  
  if n % 500 != 0 and a == 0:
    print('No')
  
  elif (n - (n // 500) * 500) <= a:
    print('Yes')
    
  else:
    print('No')
  
  return 0


if __name__ == '__main__':
  main()
A,B,C,D = map(int,input().split())
#print(A,B,C,D)
def judge(A,B,C,D):
    while(True):
        C = C-B
        A = A - D
        if C<=0:
            return 1
            break
        elif A<=0:
            return 0
            break
if judge(A,B,C,D)==1:
    print("Yes")
else:
    print("No")



### FIXED CODE ###

S,W= map(int,input().split())

if W>=S:
    print("unsafe")
else:
    print("safe")
def prime(a):
    prime = []
    for p in range(2, a):
        if a % p == 0:
            prime.append(p)
            while a % p == 0:
                a /= p
    return prime

def keynumber(prime):
    sum = 0
    for i in range(len(prime) - 1):
        sum += prime[i]
    key = prime[-1] - sum
    return key

while 1:
    ab = raw_input().split()
    a = int(ab[0])
    b = int(ab[1])
    if a == 0 and b == 0:
        break
    pa = prime(a)
    pb = prime(b)
    ka = keynumber(pa)
    kb = keynumber(pb)
    if ka > kb:
        print('a')
    else:
        print('b')

### FIXED CODE ###

def prime(a):
    prime = []
    for p in range(2, a+1):
        if a % p == 0:
            prime.append(p)
            while a % p == 0:
                a /= p
    return prime

def keynumber(prime):
    sum = 0
    for i in range(len(prime) - 1):
        sum += prime[i]
    key = prime[-1] - sum
    return key

while 1:
    ab = raw_input().split()
    a = int(ab[0])
    b = int(ab[1])
    if a == 0 and b == 0:
        break
    pa = prime(a)
    pb = prime(b)
    ka = keynumber(pa)
    kb = keynumber(pb)
    if ka > kb:
        print('a')
    else:
        print('b')
# coding: utf-8
# Your code here!
K = int (input())
line= list(map(int,input().split()))
a,b = line[0],line[1]
if B<K:
  print("NG")
if (b-a+1)>=K:
    print("OK")

else:
    for i in range(a,b+1):
        if i%K==0:
            print("OK")
            break
    print("NG")

### FIXED CODE ###

# coding: utf-8
# Your code here!
K = int (input())
line= list(map(int,input().split()))
a,b = line[0],line[1]
if b<K:
    print("NG")
    

else:
    for i in range(a,b+1):
        if i%K==0:
            print("OK")
            break
        elif i==b:
            print("NG")
def main():
    INF = 10**9
    N = int(input())
    h = list(map(int,input().split()))
    dp = [INF]*N
    dp[0] = 0
    dp[1] = h[0]
    for i in range(2,N):
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
    print(dp[N])

if __name__ == '__main__':
    main()

### FIXED CODE ###

N = int(input())
h = list(map(int,input().split()))
INF = 10**9
dp = [INF]*N
dp[0] = 0
dp[1] = abs(h[0]-h[1])
for i in range(2,N):
    dp1 = abs(h[i]-h[i-1])+dp[i-1]
    dp2 = abs(h[i]-h[i-2])+dp[i-2]
    dp[i] = min([dp1,dp2])
print(dp[N-1])
import functools
import fractions

n,x = map(int,input().split())
cities = list(map(int,input().split()))
if n == x:
    ans = cities[0] - x
    print(ans)
else:
    cities.sort()
    dist = []
    for i in range(1,len(cities)):
        dist.append(cities[i] - cities[i-1])
    ans = functools.reduce(fractions.gcd, dist)
    print(ans)

### FIXED CODE ###

import functools
import fractions
 
n,x = map(int,input().split())
cities = list(map(int,input().split()))
if n == 1:
    ans = abs(cities[0] - x)
    print(ans)
else:
    cities.append(x)
    cities.sort()
    dist = []
    for i in range(1,len(cities)):
        dist.append(cities[i] - cities[i-1])
    ans = functools.reduce(fractions.gcd, dist)
    print(ans)
from sympy import divisors
n = int(input())

cnt = 0
for i in range(1, n):
    k = n-i
    cnt += len(divisors(k))
print(cnt)


### FIXED CODE ###

n = int(input())
cnt = 0
for a in range(1,n):
    cnt += (n-1)//a
print(cnt)
l=map(int(),input().split())
c=l[0]*l[1]
if c%2==1:
  print('Odd')
else:
  print('Even')

### FIXED CODE ###

a, b=(int(i) for i in input().split())
c=a*b
if c%2==1:
  print('Odd')
else:
  print('Even')
N,Z,W=map(int, input().split())
INL = list(map(int,input().split()))
INVL = {v:i for i, v in enumerate(INL)}

class BitMAX:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s = max(self.tree[i],s)
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] = max(x, self.tree[i])
            i += i & -i
    
    def reset(self):
        t = self.tree
        for i in range(len(t)):
            t[i] = 0

class BitMIN:
    def __init__(self, n):
        self.size = n
        self.tree = [10**9+1] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s = min(self.tree[i],s)
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] = min(x, self.tree[i])
            i += i & -i
    
    def reset(self):
        t = self.tree
        for i in range(len(t)):
            t[i] = 0

bit_max = BitMAX(3000)
bit_min = BitMIN(3000)

offset = 2500

for i, v in enumerate(INL):
    bit_max.add(offset-i, v)
    bit_min.add(offset-i, v)

pos = 0
while pos < len(INL):
    ma = bit_max.sum(offset-pos)
    mi = bit_min.sum(offset-pos)
    if abs(W-ma) > abs(W-mi):
        Z = ma
        pos = INVL[ma]+1
    else:
        Z = mi
        pos = INVL[mi]+1
    # print("A pos: {}".format(pos))

    if pos < len(INL):
        ma = bit_max.sum(offset-pos)
        mi = bit_min.sum(offset-pos)
        if abs(Z-ma) < abs(Z-mi):
            W = ma
            pos = INVL[ma]+1
        else:
            W = mi
            pos = INVL[mi]+1
        # print("B pos: {}".format(pos))

print(abs(Z-W))


### FIXED CODE ###

N,Z,W=map(int, input().split())
INL = list(map(int,input().split()))

if N == 1:
    print(abs(INL[0]-W))
else:
    print(max(abs(W-INL[-1]), abs(INL[-2]-INL[-1])))
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from functools import cmp_to_key
import itertools

N, T = map(int, readline().split())
m = map(int, read().split())
AB0 = []
AB1 = []
for a,b in zip(m,m):
    if a == 0:
        AB0.append(b)
    else:
        AB1.append((a,b))

if N == 1:
    raise

def sort_func(ab0, ab1):
    a0, b0 = ab0
    a1, b1 = ab1
    return a1*b0 - a0*b1

AB0.sort()
AB1.sort(key=cmp_to_key(sort_func))
AB0, AB1

def compute_0():
    INF = T + 1
    dp = [INF] * 40
    dp[0] = 0
    for a,b in AB1:
        for n in range(39, -1, -1):
            if dp[n] > T:
                continue
            x = (dp[n] + 1) * (a + 1) + b
            if x < dp[n+1]:
                dp[n+1] = x
    return dp

def compute_1():
    return [0] + list(itertools.accumulate(x + 1 for x in AB0))

dp0 = compute_0()
dp1 = compute_1()

R = len(dp1) - 1
answer = 0
for i,x in enumerate(dp0):
    if x > T:
        break
    while x + dp1[R] > T:
        R -= 1
    value = i + R
    if answer < value:
        answer = value

print(answer)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from functools import cmp_to_key
import itertools

N, T = map(int, readline().split())
m = map(int, read().split())
AB0 = []
AB1 = []
for a,b in zip(m,m):
    if a == 0:
        AB0.append(b)
    else:
        AB1.append((a,b))

def sort_func(ab0, ab1):
    a0, b0 = ab0
    a1, b1 = ab1
    return a1*(1+b0) - a0*(1+b1)

AB0.sort()
AB1.sort(key=cmp_to_key(sort_func))
AB0, AB1

def compute_0():
    INF = T + 1
    dp = [INF] * 40
    dp[0] = 0
    for a,b in AB1:
        for n in range(39, -1, -1):
            if dp[n] > T:
                continue
            x = (dp[n] + 1) * (a + 1) + b
            if x < dp[n+1]:
                dp[n+1] = x
    return dp

def compute_1():
    return [0] + list(itertools.accumulate(x + 1 for x in AB0))

dp0 = compute_0()
dp1 = compute_1()

R = len(dp1) - 1
answer = 0
for i,x in enumerate(dp0):
    if x > T:
        break
    while x + dp1[R] > T:
        R -= 1
    value = i + R
    if answer < value:
        answer = value

print(answer)
if (int(input())%9 == 0:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

N, X, T = map(int,input().split())
if N % X == 0:
  print( T*N // X )
else:
  print( T*(N // X + 1))
a = input()
b = input()

seki = int(a) * int(b)
sa = int(a) - int(b)
wa = int(a) + int(b)

if wa >= seki and wa >= sa:
    print(wa)
elif sa >= wa and sa >= seki:
    print(sa)
else:
    print(seki)


### FIXED CODE ###

a, b = input().split()

seki = int(a) * int(b)
sa = int(a) - int(b)
wa = int(a) + int(b)

if wa >= seki and wa >= sa:
    print(wa)
elif sa >= wa and sa >= seki:
    print(sa)
else:
    print(seki)
a=(input())
b=float(input())
print(a*b 2*(a+b))

### FIXED CODE ###

a,b=list(map(int,input().split()))
print(str(a*b) + " " + str(2*a+2*b))
h, w = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(h)]

ansl = []
n = 0
for i in range(h):
    for j in range(w-1):
        if a[i][j] % 2 == 0:
            pass
        else:
            n += 1
            ansl.append([i+1, j+1, i+2, j+1])
            a[i][j] -= 1
            a[i][j+1] += 1

for i in range(h-1):
    if a[i][-1] % 2 == 0:
        pass
    else:
        n += 1
        ansl.append([i+1, j+1, i+1, j+2])
        a[i][-1] -= 1
        a[i+1][-1] += 1

print(n)
[print(*x) for x in ansl]


### FIXED CODE ###

h, w = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(h)]

ansl = []
n = 0
for i in range(h):
    for j in range(w-1):
        if a[i][j] % 2 == 0:
            pass
        else:
            n += 1
            ansl.append([i+1, j+1, i+1, j+2])
            a[i][j] -= 1
            a[i][j+1] += 1

for i in range(h-1):
    if a[i][w-1] % 2 == 0:
        pass
    else:
        n += 1
        ansl.append([i+1, w, i+2, w])
        a[i][w-1] -= 1
        a[i+1][w-1] += 1

print(n)
[print(*x) for x in ansl]
N = int(input().strip())
A = list(map(int, input().strip().split(' ')))

c_even = len(1 for a in A if a % 2 == 0)
ans = 3**len(A) - 2**c_even
print(ans)


### FIXED CODE ###

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

c_even = len([1 for a in A if a % 2 == 0])
ans = 3**len(A) - 2**c_even
print(ans)
N, M = map(int, input().split())
fav = [0]*M
for n in range(N):
    KA = list(map(int, input().split()))
    for i in range(len(KA)-1):
        fav[KA[i+1]] += 1

counter = 0
for f in fav:
    if f == N:
        counter += 1
    
print(counter)

### FIXED CODE ###

n,m=map(int,input().split())
l=[0]*(m+1)
for i in range(n):
    a=list(map(int,input().split()))
    for j in range(1,a[0]+1):
        l[a[j]]+=1
if max(l)==n:
    print(l.count(max(l)))
else:
    print(0)
a,b,c = list(map(int, input().split()))
if a==b==c:
  print(1)
elif (a==b and b != c) or (a!=b and b==C) or (a==c and a!=b):
  print(2)
else:
  print(3)

### FIXED CODE ###

x,y,z = map(int,input().split())
if x == y and y==z:
  print(1)
elif x == y or y == z or z ==x :
  print(2)
else:
  print(3)
r = input()
print ( r * r )

### FIXED CODE ###

r = int(input())
print (r*r)
import numpy as np

num_i, num_j = input().split()
num_i = int(num_i)
num_j = int(num_j)
inputs = [input() for i in range(num_i)]

x = []
for _ in inputs:
    for value in _:
        x.append(value)
x = np.array(x)
x = x.reshape(num_i, num_j)

count = 0
boolean = True
while (boolean):
    count += 1
    i_arr = []
    j_arr = []
    for i in range(num_i):
        for j in range(num_j):
            if (x[i][j] == "#"):
                i_arr.append(i)
                j_arr.append(j)
    for i, j in zip(i_arr, j_arr):
        if (i == 0) & (j == 0):
            x[1][0] = "#"
            x[0][1] = "#"
        elif (i == num_i - 1) & (j == num_j - 1):
            x[i - 1][j] = "#"
            x[i][j - 1] = "#"
        elif (i == num_i - 1) & (j == 0):
            x[i - 1][0] = "#"
            x[i][1] = "#"
        elif (i == 0) & (j == num_j - 1):
            x[1][j] = "#"
            x[0][j - 1] = "#"
        elif (i == 0):
            x[1][j] = "#"
            x[0][j - 1] = "#"
            x[0][j + 1] = "#"
        elif (j == 0):
            x[i - 1][0] = "#"
            x[i + 1][0] = "#"
            x[i][1] = "#"
        elif (i == num_i - 1):
            x[i - 1][j] = "#"
            x[i][j + 1] = "#"
            x[i][j - 1] = "#"
        elif (j == num_j - 1):
            x[i - 1][j] = "#"
            x[i + 1][j] = "#"
            x[i][j - 1] = "#"
        else:
            x[i - 1][j] = "#"
            x[i + 1][j] = "#"
            x[i][j - 1] = "#"
            x[i][j + 1] = "#"
    if len(set(list(x.flatten()))) == 1:
        return(count)
        boolean = False
    else:
        boolean = True

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())

# input black cells
black_cells = []

for h in range(H):
    line = list(input())
    for w in range(W):
        if line[w] == "#":
            black_cells.append(h * W + w)


# Graph
def r(p):
    q_list = []
    h = p // W
    w = p % W
    if h != 0:
        q_list.append(p - W)
    if h != H-1:
        q_list.append(p + W)
    if w != 0:
        q_list.append(p - 1)
    if w != W-1:
        q_list.append(p + 1)
    return q_list


queue = deque(black_cells)
d = [10000] * (H * W)
for i in black_cells:
    d[i] = 0

# dijkstra
while len(queue) > 0:
    p = queue.popleft()
    for q in r(p):
        if d[q] > d[p] + 1:
            d[q] = d[p] + 1
            queue.append(q)

print(max(d))