Harryxun/stf_run huggingface dataset:
import sys
import random
s = input()
t = input()
sl = len(s)
tl = len(t)

if s*tl == t*sl:
    print(-1)
    sys.exit()
    
l = 0
r = 1000000//tl + 1
s *= 999999//sl + 1
n = len(s)
base1 = 1007
mod1 = 10**9+7
modTank1 = [3000012541,3000012553,3000012563,3000012649,3000012683,3000012709]
mod1 = modTank1[random.randint(0,5)]
base1 = 1007
mod1 = 10**9+7
hash1 = [0]*(n+1)
power1 = [1]*(n+1)
for i,e in enumerate(s):
    hash1[i+1] = (hash1[i]*base1 + ord(e))%mod1
    power1[i+1] = (power1[i]*base1)%mod1

def rolling_hash(i, j):
    return (hash1[j]-hash1[i]*power1[j-i]%mod1)%mod1


while r - l > 1:
    m = l + (r-l)//2
    lt = len(t)*m
    hash2 = [0]*(lt+1)
    power2 = [1]*(lt+1)
    for i,e in enumerate(t*m):
        hash2[i+1] = (hash2[i]*base1 + ord(e))%mod1
        power2[i+1] = (power2[i]*base1)%mod1
    r_hash = hash2[-1]%mod1

    lt = len(t)*m
    flag = 0
    for i in range(len(s)-lt+1):
        if r_hash == rolling_hash(i, i+lt):
            flag = 1
            break

    if flag == 1:
        l = m
    else:
        r = m


print(l)


### FIXED CODE ###

import sys
import random
s = input()
t = input()
sl = len(s)
tl = len(t)

l = 0
r = 1500000//tl + 1
r2 = r
s *= 1499999//sl + 1
n = len(s)

base1 = 1007
mod1 = 10**9+7
modTank1 = [3000012541,3000012553,3000012563,3000012649,3000012683,3000012709]
mod1 = modTank1[random.randint(0,5)]
base1 = 1007
mod1 = 10**9+7
hash1 = [0]*(n+1)
power1 = [1]*(n+1)
for i,e in enumerate(s):
    hash1[i+1] = (hash1[i]*base1 + ord(e))%mod1
    power1[i+1] = (power1[i]*base1)%mod1

def rolling_hash(i, j):
    return (hash1[j]-hash1[i]*power1[j-i]%mod1)%mod1


while r - l > 1:
    m = l + (r-l)//2
    lt = len(t)*m
    hash2 = [0]*(lt+1)
    power2 = [1]*(lt+1)
    for i,e in enumerate(t*m):
        hash2[i+1] = (hash2[i]*base1 + ord(e))%mod1
        power2[i+1] = (power2[i]*base1)%mod1
    r_hash = hash2[-1]%mod1

    lt = len(t)*m
    flag = 0
    for i in range(len(s)-lt+1):
        if r_hash == rolling_hash(i, i+lt):
            flag = 1
            break

    if flag == 1:
        l = m
    else:
        r = m

if l*tl >= 1000000:
    print(-1)
else:
    print(l)
a,b,c=map(int,input())
if b>c:
    print("Yes")
else:print("No")


### FIXED CODE ###

a,b,c=map(int, input().split())
if a>c>b or b>c>a:
    print("Yes")
else:print("No")
#A
"""
a,b = map(int, input().split())
if b % a == 0:
    print(b + a)
else:
    print(b-a)
"""

#B
"""
n, m = map(int, input().split())
ans = list(map(int, input().split()))
del ans[0]
ans = set(ans)
for i in range(n-1):
    a = list(map(int, input().split()))
    del a[0]
    ans = ans & set(a)
print(len(ans))
"""


#C
"""
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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

#D
n,m = map(int, input().split())
a = list(map(int, input().split()))
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
ans = [-float("inf") for i in range(n + 1)]
num_ans = []
if 5 in a:
    if 3 in a:
        a.remove(3)
    if 2 in a:
        a.remove(2)
if 3 in a:
    if 2 in a:
        a.remove(2)
if 9 in a:
    if 6 in a:
        a.remove(6)
a.sort(reverse=True)
for i in a:
    num_ans.append(num[i])
ans[0] = 0
for i in range(n + 1):
    xmax = 0
    for y, b in enumerate(num_ans):
        if i - b >= 0:
            ans[i] = max(ans[i - b] + 1, ans[i])
anse = ""
while ans[n] > 0:
    for k, i in enumerate(num_ans):
        if ans[n] - 1 == ans[n - i]:
            anse += str(a[k])
            n -= i
            break
            
print(anse)

### FIXED CODE ###

#A
"""
a,b = map(int, input().split())
if b % a == 0:
    print(b + a)
else:
    print(b-a)
"""

#B
"""
n, m = map(int, input().split())
ans = list(map(int, input().split()))
del ans[0]
ans = set(ans)
for i in range(n-1):
    a = list(map(int, input().split()))
    del a[0]
    ans = ans & set(a)
print(len(ans))
"""


#C
"""
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

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

#D
n,m = map(int, input().split())
a = list(map(int, input().split()))
num = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
ans = [-float("inf") for _ in range(n + 1)]
num_ans = []
a.sort(reverse=True)
for i in a:
    num_ans.append(num[i])
ans[0] = 0
for i in range(n + 1):
    for b in num_ans:
        if i - b >= 0:
            ans[i] = max(ans[i - b] + 1, ans[i])
anse = ""
while ans[n] > 0:
    for k, i in enumerate(num_ans):
        if n - i >= 0:
            
            if ans[n] - 1 == ans[n - i]:
                anse += str(a[k])
                n -= i
                break
    if n < 0:
        break
            
print(anse)
import math

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

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


for i in range(1,k+1):
    a = comb(k-1, i-1)
    b = comb(n-k+1, i)
    print((a*b)%(10**9+7))

    




### FIXED CODE ###

import math

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

def comb(n, r):
    if n-r>=0:
        return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
    else: 
        return 0

for i in range(1,k+1):
    a = comb(k-1, i-1)
    b = comb(n-k+1, i)
    print((a*b)%(10**9+7))
import random
class Dice:
    def __init__(self, ls):
        self.top,   self.bottom = ls[0], ls[5]
        self.right, self.left   = ls[2], ls[3]
        self.front, self.back   = ls[1], ls[4]

    def rot(self, d):
        if   d == "N":
            (self.top, self.back, self.bottom, self.front) = (
             self.front, self.top, self.back, self.bottom)
        elif d == "S":
            (self.top, self.back, self.bottom, self.front) = (
             self.back, self.bottom, self.front, self.top)
        elif d == "E":
            (self.top, self.right, self.bottom, self.left) = (
             self.left, self.top, self.right, self.bottom)
        elif d == "W":
            (self.top, self.right, self.bottom, self.left) = (
             self.right, self.bottom, self.left, self.top)

    def show(self):
        return (self.top, self.bottom, self.right,
                self.left, self.front, self.back)

S = set()
N = int(raw_input())
judge = True
for i in xrange(N):
    dice = Dice(map(int, raw_input().split()))
    s = set()
    for loop in xrange(1000):
        nums = dice.show()
        if nums in S:
            judge = False
            break
        s.add(nums)
        dice.rot("NSEW"[random.randint(0, 3)])
    if not judge:
        break
    S |= s
print "Yes" if judge else "No"

### FIXED CODE ###

class Dice:
    def __init__(self, top, front, right, left, back, bottom):
        self.top,   self.bottom = top, bottom
        self.right, self.left   = right, left
        self.front, self.back   = front, back

    def rot(self, d):
        if   d == "N":
            self.top, self.back, self.bottom, self.front = self.front, self.top, self.back, self.bottom
        elif d == "S":
            self.top, self.back, self.bottom, self.front = self.back, self.bottom, self.front, self.top
        elif d == "E":
            self.top, self.right, self.bottom, self.left = self.left, self.top, self.right, self.bottom
        elif d == "W":
            self.top, self.right, self.bottom, self.left = self.right, self.bottom, self.left, self.top

ls = map(int, raw_input().split())
dice = Dice(ls[0], ls[1], ls[2], ls[3], ls[4], ls[5])
for d in raw_input():
    dice.rot(d)
print dice.top
N = int(input())

v = list(map(int, input().split()))

v = sorted(v, reverse = False)

sum = v[0] / 2**(N-1)
for i in range(1, N):
    sum += v[i]/2**(N-i)

pprint(sum)

### FIXED CODE ###

N = int(input())

v = list(map(int, input().split()))

v = sorted(v, reverse = False)

sum = v[0] / pow(2, N-1)
for i in range(1, N):
    sum += v[i]/pow(2, (N-i))

print(sum)
from collections import deque
import sys
input=sys.stdin.readline
def main():
  a=int(input())
  b=[[]for i in range(a)]
  for i in range(a):
    b[i]=deque(list(map(int,input().split())))
  c=[[]for i in range(a)]
  ans=0
  d=[0 for i in range(a)]
  while sum(len(v) for v in b)!=0:
    f=[0 for i in range(a)]
    ans+=1
    T=0
    for i in range(a):
      if d[i]==0 and f[i]==0 or len(b[i])>0:
        e=b[i][0]-1
        if e in c[i]:
          c[i].pop(c[i].index(e))
          T=1
          b[e].popleft()
          b[i].popleft()
          d[i]=0
          d[e]=0
          f[i]=1
          f[e]=1
        else:
          c[e].append(i)
          d[i]=1
    if T==0:
      print(-1)
      exit()
      
      
  print(ans)  
if __name__ == '__main__':  
  main()      

        




### FIXED CODE ###

from collections import deque
import sys
input=sys.stdin.readline
def main():
  a=int(input())
  b=[[]for i in range(a)]
  for i in range(a):
    b[i]=deque(list(map(int,input().split())))
  c=[[]for i in range(a)]
  ans=0
  d=[i for i in range(a)]
  while d:
    nextd=[]
    f=set()
    ans+=1
    T=0
    for i in d:
      if i not in f and len(b[i])>0:
        e=b[i][0]-1
        if e in c[i]:
          c[i].pop(c[i].index(e))
          T=1
          b[e].popleft()
          b[i].popleft()
          if len(b[i])>0:
            nextd.append(i)
          if len(b[e])>0:
            nextd.append(e)
          f|={i,e}
        else:
          c[e].append(i)
    if T==0:
      print(-1)
      exit()
    d=nextd
      
      
  print(ans)  
if __name__ == '__main__':  
  main()
h,w=map(int,input().split())
l=[input() for i in range(h)]
li=[]
li4=[]
for L in l:
  if (L=="."*w):
    continue
  li.append(L)
  li2=[list(x) for x in zip(*li)]
  ll=len(li2[0])
for i in range(h):
  li3=[''.join(li2[i])]
  for L in li3:
    if (L=="."*ll):
      continue
    li4.append(L)
    li5=[list(x) for x in zip(*li4)]
for i in range(ll):
  li6=[''.join(li5[i])]
  for L in li6:
    print(L)

### FIXED CODE ###

H,W=map(int,input().split())
L=[list(input()) for _ in range(H)]
L=[l for l in L if "#" in l]
#リストの中のリストで#を含まないリストは取り除く
LL=list(zip(*L))
#同じサブインデックスをもつ要素からなる配列を作る
LL=[l for l in LL if "#" in l]
L=list(zip(*LL))
for l in L:
  print("".join(l))
from sys import stdin

n, k = map(int, stdin.readline().rstrip().split())
a = map(int, stdin.readline().rstrip().split())

class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
  
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
  
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
bit = Bit(n*k)
ans = 0
a = list(a)*k
for i, p in enumerate(a):
    ans += (i - bit.sum(p)) % (10^9+7)
    bit.add(p, 1)
print(ans)

### FIXED CODE ###

from sys import stdin

n, k = map(int, stdin.readline().rstrip().split())
a = map(int, stdin.readline().rstrip().split())

a = list(a) 
count = 0 
for i in range(1, n):
    for j in range(i):
        if a[j] > a[i]:
            count += 1
import copy
b = copy.copy(a)
b.sort()
count *= k
import bisect
ans2 = 0
for i in range(n):
  ans2 += bisect.bisect_left(b, a[i])
print((count + ans2 * (((k-1)* k)//2))%(1000000007))
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = map(int, readline().split())
    a = []
    for i in range(n):
        a.append(list(map(int, readline().split())))

    ans = INF
    for _ in range(n - 1):
        cnt = [0] * (m + 1)
        for i in range(n):
            cnt[a[i][0]] += 1
        max_cnt = max(cnt)
        ans = min(ans, max_cnt)
        max_num = cnt.index(max_cnt)
        for i in range(n):
            a[i].remove(max_num)

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = map(int, readline().split())
    a = []
    for i in range(n):
        a.append(list(map(int, readline().split())))

    ans = INF
    for _ in range(m):
        cnt = [0] * (m + 1)
        for i in range(n):
            cnt[a[i][0]] += 1
        max_cnt = max(cnt)
        ans = min(ans, max_cnt)
        max_num = cnt.index(max_cnt)
        for i in range(n):
            a[i].remove(max_num)

    print(ans)


if __name__ == '__main__':
    main()
import networkx as nx

N,M=map(int,input().split())
S = [input() for _ in range(N)]

index = lambda i,j: i*M+j

G=nx.DiGraph()
dx,dy=(1,0),(0,1)
for i in range(N):
  for j in range(M):
    if S[i][j]=='#':continue
    if (i+j) %2:
      G.add_edge(index(i,j),'sink',capacity=1)
    else:
      G.add_edge('source',index(i,j),capacity=1)
    for k in range(2):
      v1,v2 = index(i,j),index(i+dx[k],j+dy[k])
      if not (0<=i+dx[k]<N and 0<=j+dy[k]<M):
        continue
      if S[i+dx[k]][j+dy[k]] == '#': continue
      if (i+j) % 2:
        G.add_edge(v2,v1,capacity=1)
      else:
        G.add_edge(v1,v2,capacity=1)
        
flow_value, flow_dict = nx.maximum_flow(G, "source", "sink")

ans = [list(S[i]) for i in range(N)]
for v1 in flow_dict.keys():
  if v1 in ('sink','source'):continue
  for v2 in flow_dict[v1]:
    if v2 in ('sink','source'):continue
    if flow_dict[v1][v2]:
      i1,j1 = divmod(v1,N)
      i2,j2 = divmod(v2,N)
      (i1,j1),(i2,j2) = sorted([(i1,j1),(i2,j2)])
      if i1 + 1 == i2:
        ans[i1][j1] = 'v'
        ans[i2][j2] = '^'
      else:
        ans[i1][j1] = '>'
        ans[i2][j2] = '<'
        
for i in range(N):
  print(''.join(ans[i]))

### FIXED CODE ###

import networkx as nx

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

  if N == M == 1:
    print(0)
    print(S[0][0])
    exit()

  index = lambda i,j: i*M+j

  G=nx.Graph()
  dx,dy=(1,0),(0,1)
  E = []
  n1,n2 = [],[]
  for i in range(N):
    for j in range(M):
      if S[i][j]=='#':continue
      if (i+j)%2:
        n1.append(index(i,j))
      else:
        n2.append(index(i,j))
      for k in range(2):
        v1,v2 = index(i,j),index(i+dx[k],j+dy[k])
        if not (0<=i+dx[k]<N and 0<=j+dy[k]<M):
          continue
        if S[i+dx[k]][j+dy[k]] == '#': continue
        if (i+j) % 2:
          E.append((v2,v1))
        else:
          E.append((v1,v2))
     
  G.add_nodes_from(n1, bipartite=0)
  G.add_nodes_from(n2, bipartite=1)
  G.add_edges_from(E)
  u = [n for n in G.nodes if G.nodes[n]['bipartite'] == 0]
  match = nx.bipartite.maximum_matching(G, top_nodes=u)
  match = {v:match[v] for v in match.keys() if v < match[v]}
 
  for v in match.keys():
    i1,j1 = divmod(v,M)
    i2,j2 = divmod(match[v],M)
    if i1 > i2 or j1 > j2:
      (i1,j1),(i2,j2) = (i2,j2),(i1,j1)
    if i1 < i2:
      S[i1][j1] = 'v'
      S[i2][j2] = '^'
    else:
      S[i1][j1] = '>'
      S[i2][j2] = '<'

  print(len(match))
  for i in range(N):
    print(''.join(S[i]))
    
if __name__ == "__main__":
  main()
a = int(input())
b = int(input())

print(a*b, 2*(a+b), end=' ')

### FIXED CODE ###

(a,b) = list(map(int, input().split()))
print ("%d %d" % (a * b, a * 2 + b * 2))
a,b=input().split()
if a=="H":
  print(b):
else:
  if b=="H":
    print("D")
  else:
    print("H")

### FIXED CODE ###

a,b=input().split()
if a=="H":
  print(b)
else:
  if b=="H":
    print("D")
  else:
    print("H")
n, a, b, c, d = map(int, input().split())
s = list(input())

def check():
    for i in range(a-1, d):
        if s[i-1] == s[i] == '#':
            return False
    return True


def check_2():
    for i in range(b-1, c):
        if s[i-1] == s[i] == s[i+1] == ".":
            return True
    return False


if check() is True:
    if c < d:
        print('Yes')
        exit()
    else:
        if check_2() is True:
            print('Yes')
            exit()
print('No')


### FIXED CODE ###

n, a,b,c,d = map(int, input().split())
s = input()

def check_twice(left, right, l):
    for i in range(left-1, right):
        if l[i] == '#' and l[i+1] == '#':
            return False
    return True

def check_triple(left, right, l):
    f = False
    for i in range(left-1, right-2):
        if l[i] == '.' and l[i+1] == '.' and l[i+2] == '.':
            f = True
            break
        else:
            continue
    return f

if c < d:
    flg = check_twice(a, c, s) & check_twice(b, d, s)
    if flg is True:
        print('Yes')
    else:
        print('No')

else:
    flg = check_twice(a, c, s) & check_triple(b-1, d+1, s)
    if flg is True:
        print('Yes')
    else:
        print('No')
from collections import deque


def bfs(S):  # 幅優先探索  # キュー
    dist = [-1] * (w * h)  # 前処理
    que = deque()
    for i, Si in enumerate(S):
        for j, Sij in enumerate(Si):
            if Sij == '#':
                dist[i + (w * j)] = 0
                que.append((i, j))

    while len(que) > 0:
        (x, y) = que.popleft()
        near = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]
        for i, j in near:  # 移動先の候補
            if 0 <= i < h and 0 <= j < w and dist[i][j] < 0:
                dist[i + (w * j)] = dist[x + (w * y)] + 1
                que.append((i, j))
    return dist[x][y]


h, w = map(int, input().split())
a = [input() for _ in range(h)]
print(bfs(a))


### FIXED CODE ###

from collections import deque


def bfs(S):  # 幅優先探索  # キュー
    dist = [[-1] * w for _ in range(h)]  # 前処理
    que = deque()
    for i, Si in enumerate(S):
        for j, Sij in enumerate(Si):
            if Sij == '#':
                dist[i][j] = 0
                que.append((i, j))

    while len(que) > 0:
        (x, y) = que.popleft()
        near = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]
        for i, j in near:  # 移動先の候補
            if 0 <= i < h and 0 <= j < w and dist[i][j] < 0:
                dist[i][j] = dist[x][y] + 1
                que.append((i, j))
    return dist[x][y]


h, w = map(int, input().split())
a = [input() for _ in range(h)]
print(bfs(a))
T=[(map(int,input().split()))]
T.sort()
print(T[0]+T[1])

### FIXED CODE ###

T=list(map(int,input().split()))
T.sort()
print(T[0]+T[1])
n=int(input())
s=str(input())
t=str(input())
for i in range(n):
    print(s[i], end='')
    print(t[i], end='')

### FIXED CODE ###

n=int(input())
s,t=input().split(' ')
for i in range(n):
    print(s[i], end='')
    print(t[i], end='')
import fractions

a, b, x = map(int, input().split())
s1 = fractions.degrees(fractions.atan(2*b/a - 2*x/(a*a*a)))
s2 = 90 - fractions.degrees(fractions.atan(2 * x / (a * b * b)))

if(a*a*b/2 <= x):
    print(s1)
else:
    print(s2)

### FIXED CODE ###

from math import degrees
from math import atan

a, b, x = map(int, input().split())
s1 = degrees(atan(2*b/a - 2*x/(a*a*a)))
s2 = 90 - degrees(atan(2 * x / (a * b * b)))

if(a*a*b/2 <= x):
    print(s1)
else:
    print(s2)
def main():
    n = int(input())
    h = list(map(int, input().split()))

    score = []

    for i in range(n-1):
        j = i
        cnt = 0
        while True:
            if j >= n-1 or h[j] < h[j+1]:
                score.append(cnt)
                break
            else:
                h[j] >= h[j+1]
                cnt += 1
                j += 1

    print(max(score))


if __name__ == '__main__':
    main()

### FIXED CODE ###

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

    score = []

    j = 0
    for i in range(n-1):
        if i != 0:
            j = next_j
        cnt = 0
        while True:
            if j >= n-1 or h[j] < h[j+1]:
                score.append(cnt)
                next_j = j+1
                break
            else:
                h[j] >= h[j+1]
                cnt += 1
                j += 1

    if n == 1:
        print(0)
    else:
        print(max(score))

if __name__ == '__main__':
    main()
n=int(input())
rowdata=[int(i) for i in input().split()]
rowdata.sort()

#nが偶数の時
if n%2==0:
    check=[]
    for i in range(1,n,2):
        check.append(i)
        check.append(i)
    if check==rowdata:
        print(int(2**(n/2)))
    else:
        print(0)
else:
    check=[]
    for i in range(0,n,2):
        if i==0:
            check.append(i)
        else:
            check.append(i)
            check.append(i)
    if check==rowdata:
        print(int(2**((n-1)/2)))
    else:
        print(0)
        

### FIXED CODE ###

a,op,b=input().split()
a=int(a)
b=int(b)
if op=="+":
    print(a+b)
else:
    print(a-b)
line=(input())
line.split()
a=int(line[0])
b=int(line[2])
p=(a+b)*2
Area=a*b
print(Area,p)



### FIXED CODE ###

a,b=map(int,input().split())
p=(a+b)*2
Area=a*b
print(Area,p)
n = input()
 
d = [0 for i in range(n)]
f = [0 for i in range(n)]
X = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
color = [0 for i in range(n)]
t = 0
 
def DFS_v(u):
  color[u] = 1
  t += 1
  d[u] = t
  for v in range(n):
    if M[u][v] == 1 and color[v] == 0:
      DFS_v(v)
  color[u] = 2
  t += 1
  f[u] = t
 
def DFS():
  for u in range(n):
    if color[u] == 0:
        DFS_v(u)
  for u in range(n):
    print "%d %d %d" %(u+1, d[u], f[u])
     
for i in range(n):
  X = map(int, raw_input().split())
  for j in range(X[1]):
    M[X[0]-1][X[2+j]-1] = 1
 
DFS()

### FIXED CODE ###

n = int(raw_input())
 
d = [0 for i in range(n)]
f = [0 for i in range(n)]
G = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
col = [0 for i in range(n)]
t = [0]
 
def DFS_visit(u):
    col[u] = 1
    t[0] += 1
    d[u] = t[0]
    for v in range(n):
        if M[u][v] == 1 and col[v] == 0:
            DFS_visit(v)
    col[u] = 2
    t[0] += 1
    f[u] = t[0]
 
def DFS():
    for u in range(n):
        if col[u] == 0:
            DFS_visit(u)
    for u in range(n):
        print'{0} {1} {2}'.format(u+1, d[u], f[u])
     
for i in range(n):
    X = map(int, raw_input().split())
    for j in range(X[1]):
        M[X[0]-1][X[2+j]-1] = 1
 
DFS()
from math import gcd

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

print(3*(N - gcd(N, X)))


### FIXED CODE ###

def gcd(a, b):
        while a != b:
                if a == 0:
                        return b
                elif b == 0:
                        return a
                if a > b :
                        a %= b
                else:
                        b %= a
        return a

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

print(3*(N - gcd(N, X)))
#AtCoder *** Contest
def ABC_48_A():
    A,B,C = map(str, input().split())
    print('A' + B[0] + 'C')


if __name__ == '__main__':


### FIXED CODE ###

def ABC_48_A():
    A,B,C = map(str, input().split())
    print('A' + B[0] + 'C')


if __name__ == '__main__':

    ABC_48_A()
S = input()
T = input()

Min = 100000

for i in range(len(S)):
    if i + len(T) > len(S) - 1:
        break
    count = 0
    for n in range(len(T)):
        if S[i + n] != T[n]:
            count += 1
    if count < Min:
        Min = count

print(count)

### FIXED CODE ###

S = input()
T = input()

Min = 100000

for i in range(len(S) - len(T) + 1):
    count = 0
    for n in range(len(T)):
        if S[i + n] != T[n]:
            count += 1
    if count < Min:
        Min = count

print(Min)