Harryxun/stf_run huggingface dataset:
set1=set()
setn=set()
for i in [None]*M:
    ipt=[int(x) for x in input().split()]
    if 1 in ipt:
        set1 = set1.union(ipt)
    if N in ipt:
        setn = setn.union(ipt)
if set1.symmetric_difference(setn):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

N,M=[int(x) for x in input().split()]
set1=[]
setn=[]
for i in [None]*M:
    ipt=[int(x) for x in input().split()]
    if 1 in ipt:
        set1 += ipt
    if N in ipt:
        setn += ipt
if set(set1) & set(setn):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
A,B = list(map(int,input().split()))
s =""
for i in range(int(math.log2(B))+1):
    if i == 0:
        a =0
        for j in range(A,4*(divmod(A,4)[0]+1)):
            #print(divmod(j,2)[1])
            a += divmod(j,2)[1]
        for j in range(4*(divmod(B,4)[0]),B+1):
            #print(divmod(j,2)[1])
            a += divmod(j,2)[1]
        s = str(divmod(a,2)[1])
    else:
        # int(divmod(16/16 ,2)[1])
        s = str(divmod((2**i-divmod(A,2**i)[1]) * int(divmod(A/2**i ,2)[1])+(divmod(B,2**i)[1]+1) * int(divmod(B/2**i ,2)[1]),2)[1]) + s
print(int(s,2))

### FIXED CODE ###

import math
A,B = list(map(int,input().split()))
s =""
if B == 0:
    print(0)
else:
    for i in range(int(math.log2(B))+1):
        if i == 0:
            a =0
            for j in range(A,4*(divmod(A,4)[0]+1)):
                #print(divmod(j,2)[1])
                a += divmod(j,2)[1]
            for j in range(4*(divmod(B,4)[0]),B+1):
                #print(divmod(j,2)[1])
                a += divmod(j,2)[1]
            s = str(divmod(a,2)[1])
        else:
            # int(divmod(16/16 ,2)[1])
            s = str(divmod((2**i-divmod(A,2**i)[1]) * int(divmod(A/2**i ,2)[1])+(divmod(B,2**i)[1]+1) * int(divmod(B/2**i ,2)[1]),2)[1]) + s
    print(int(s,2))
from itertools import permutations

n,m=map(int,input().split())
tree=[[] for i in range(m)]
for i in range(m):
    a,b=map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

cnt=0
for i in permutations(range(1,n)):
    if i[0] in tree[0]:
        t_cnt=1
        for j in range(1,len(i)):
            if i[j] in tree[i[j-1]]:
                t_cnt+=1
            else:
                break
        if t_cnt==m-1:
            cnt+=1
print(cnt)

### FIXED CODE ###

from itertools import permutations

n,m=map(int,input().split())
tree=[[] for i in range(m+1)]
for i in range(m):
    a,b=map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

cnt=0
for i in permutations(range(1,n)):
    if i[0] in tree[0]:
        t_cnt=1
        for j in range(1,len(i)):
            if i[j] in tree[i[j-1]]:
                t_cnt+=1
            else:
                break
        if t_cnt==n-1:
            cnt+=1
print(cnt)
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i],y[i] = map(int,input().split())

memo = {}

for i in range(N-1):
    for j in range(i+1,N):
        dx = x[j] - x[i]
        dy = y[j] - y[i]
        if ((dx,dy) in memo) or ((-dx,-dy) in memo):
            memo[(dx,dy)] += 1
        else:
            #memo[(dx,dy)] = 1
        print(memo)

M = max(memo.values())

print(N-M)


### FIXED CODE ###

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

if N == 1:
    print(1)
else:
    memo = {}

    for i in range(N-1):
        for j in range(i+1,N):
            dx = x[j] - x[i]
            dy = y[j] - y[i]
            if (dx,dy) in memo:
                memo[(dx,dy)] += 1
            elif (-dx,-dy) in memo:
                memo[(-dx,-dy)] += 1
            else:
               memo[(dx,dy)] = 1
            #print(memo)

    M = max(memo.values())

    print(N-M)
import numpy as np
n, m = [int(i) for i in input().split(" ")]

pre_res = np.array([0 for i in range(m)])

for i in range(n):
    sel = [int(i-1) for i in input(().split(" "))][1:]
    for s in sel:
        pre_res[s] += 1

res = 0
for i in range(m):
    if pre_res[s] == n:
        res += 1

print(res)


### FIXED CODE ###

n, m = [int(i) for i in input().split(" ")]

pre_res = [0 for i in range(m)]

for i in range(n):
    sel = [int(i)-1 for i in input().split(" ")][1:]
    for s in sel:
        pre_res[s] += 1

res = 0
for i in range(m):
    if pre_res[i] == n:
        res += 1

print(res)
n,a,b =map(int, input().split())
c=2**n-1
from scipy.special import comb
A= comb(n, a, exact=True)
B= comb(n, b, exact=True)
c=c-A-B
print(c)

### FIXED CODE ###

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

def combination(n, a, mod):
    bunbo = 1
    bunshi = 1
    for i in range(a):
        bunshi *= n-i
        bunshi = bunshi%mod
        bunbo *= a-i
        bunbo = bunbo%mod
        
    return bunshi*pow(bunbo, mod-2, mod)%mod
        
        
mod = 1000000007
answer = pow(2, n, mod)
answer -= 1
answer -= combination(n, a, mod)
answer -= combination(n, b, mod)
print(answer%mod)
# -*- coding: utf-8 -*-
import sys


MAX_INT = 2**62-1
sys.setrecursionlimit(10**7)

input = sys.stdin.readline

# @profile
MOD = 10**9 + 7


def mul_mod(a, b, mod=MOD):
    return (a * b) % mod

@profile
def solve(g, f, fi, m):
    mul = mul_mod

    stack = [(0, 1)]
    pre_order = []
    n = len(g) - 1

    while stack:
        pre, cur = stack.pop()
        pre_order.append((pre, cur))

        for nxt in g[cur]:
            if nxt == pre:
                continue
            stack.append((cur, nxt))

    size = [1] * (n+1)
    dp = [1] * (n+1)

    for pre, cur in reversed(pre_order):
        dp[cur] = mul(dp[cur], f[size[cur]-1])
        dp[pre] = mul(mul(dp[pre], dp[cur]), fi[size[cur]])
        size[pre] += size[cur]

    ans = [1] * (n+1)
    ans[1] = dp[1]

    for pre, cur in pre_order[1:]:
        ans[cur] = mul(ans[pre], size[cur]) // (n-size[cur])
    print(*ans[1:], sep='\n')


# @profile
def main():
    mul = mul_mod
    mod = MOD
    n = int(input())
    g = [[] for _ in range(n+1)]

    fact = [1] * (n+1)
    fact_inv = [0] * (n+1)

    for i in range(1, n+1):
        fact[i] = mul(fact[i-1], i)

    fact_inv[-1] = pow(fact[-1], mod-2, mod)

    for i in range(n)[::-1]:
        fact_inv[i] = mul(fact_inv[i+1], (i+1))

    for _ in range(n-1):
        a, b = map(int, input().split())
        g[a].append(b)
        g[b].append(a)

    solve(g, fact, fact_inv, mod)


if __name__ == "__main__":

    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from functools import reduce

MAX_INT = 2**62-1
sys.setrecursionlimit(10**7)

input = sys.stdin.readline

# @profile
MOD = 10**9 + 7


def mul_mod(*args, mod=MOD):
    return reduce(lambda a, b: a * b % mod, args)


def solve(g, f, fi, m):
    mul = mul_mod

    stack = [(0, 1)]
    pre_order = []
    n = len(g) - 1

    while stack:
        pre, cur = stack.pop()
        pre_order.append((pre, cur))

        for nxt in g[cur]:
            if nxt == pre:
                continue
            stack.append((cur, nxt))

    size = [1] * (n+1)
    dp = [1] * (n+1)

    for pre, cur in reversed(pre_order):
        dp[cur] = mul(dp[cur], f[size[cur]-1])
        dp[pre] = mul(dp[pre], dp[cur], fi[size[cur]])
        size[pre] += size[cur]

    ans = [1] * (n+1)
    ans[1] = dp[1]

    for pre, cur in pre_order[1:]:
        i = size[cur]
        temp = mul(ans[pre], f[n-i-1], fi[n-1], f[i], pow(dp[cur], m-2, m))
        ans[cur] = mul(f[n-1], temp, fi[n-i], dp[cur], fi[i-1])
    print(*ans[1:], sep='\n')


# @profile
def main():
    mul = mul_mod
    mod = MOD
    n = int(input())
    g = [[] for _ in range(n+1)]

    fact = [1] * (n+1)
    fact_inv = [0] * (n+1)

    for i in range(1, n+1):
        fact[i] = mul(fact[i-1], i)

    fact_inv[-1] = pow(fact[-1], mod-2, mod)

    for i in range(n)[::-1]:
        fact_inv[i] = mul(fact_inv[i+1], (i+1))

    for _ in range(n-1):
        a, b = map(int, input().split())
        g[a].append(b)
        g[b].append(a)

    solve(g, fact, fact_inv, mod)


if __name__ == "__main__":

    main()
import sys
s = input()
t = input()
s.sort()
t.sort()
for x, y in zip(s, t[::-1]):
    if x > y:
        print('No')
        sys.exit()
    elif x == y:
        continue
    else:
        print('Yes')
        sys.exit()
if len(s) <= len(t):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s, t = list(input()), list(input())
s.sort()
t.sort(reverse=True)
S = ''.join(s)
T = ''.join(t)
if S < T:
    print('Yes')
else:
    print('No')
import math


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

dp = [math.inf] * N
dp[0] = 0
for i in range(N):
    for j in (i + 1, i + 2):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(dp[N-1])

### FIXED CODE ###

N = int(raw_input())
h_str = raw_input()
h = []
for h_i in h_str.split(" "):
    h.append(int(h_i))

dp = [10 ** 9 + 1] * N
dp[0] = 0
for i in range(N):
    for j in (i + 1, i + 2):
        if j < N:
            dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(dp[N-1])
while(True):
    H,W = (map(int,input().split()))   
    
　　if H == 0 and W == 0:
        break
    elif H == 1 and W == 1:
        print('#')
        print()
        continue
    else:
        for i in range(H-1):
            print('#' * W)
        print()
    


### FIXED CODE ###

while(True):
    H,W = (map(int,input().split()))   
    if H == 0 and W == 0:
        break
 
    for i in range(H):
        print('#'*W)
    print('')
# -*- coding:utf-8 -*-
# /usr/bin/python3

from collections import defaultdict
from bisect import insort
from collections import deque

def main():
  n, m = map(int, input().strip().split(' '))
  liAB = sorted([tuple(map(int, input().strip().split(' '))) for _ in range(n)], 
                key=lambda x:x[0])

  k = 1
  top = deque()
  s = 0
  for a, b in liAB:
    if a >= m+1:
      break

    if k < a:
      for i in range(len(top)):
        if i < a-k:
          s += top[-1]
          del top[-1]
      k = a

    insort(top, b)


  s += top[-1]
  for i in range(m - k):
    s += top[-(i+1)]

  print(s)
  
  pass

if __name__=='__main__':
  main()



### FIXED CODE ###

# -*- coding:utf-8 -*-
# /usr/bin/python3

from heapq import heappush, heappop

def main():
  n, m = map(int, input().strip().split(' '))
  liAB = [tuple(map(int, input().strip().split(' '))) for _ in range(n)]
  liAB.sort(key=lambda x:x[0])

  k = 1
  top = []
  s = 0
  for a, b in liAB:
    if a >= m+1:
      break

    if k < a:
      s += (-sum([heappop(top) for _ in range(a-k) if len(top) != 0]))
      k = a
    heappush(top, -b)

  s += (-sum([heappop(top) for _ in range(m-k+1) if len(top) != 0]))
  print(s)

if __name__=='__main__':
  main()
k,m = map(int,input().split())
a = input().split()
a =[int(s) for s in a]

a.insert(0,k)

dis = []

for i in range(m):
  part = int(a[i]) - int(a[i+1])
  dis.append(part)
  del part

dis.append(int(a[m-1]))
distance = dis*2

c =[]
for j in range(m):
  c = int(sum(distance[j:j+5]))

print(min(c))

### FIXED CODE ###

#12
k,n = map(int,input().split())
a = list(map(int,input().split()))
b = []
for i in range(n-1):
    b.append(a[i+1]-a[i])

b.append(int(k-a[n-1]+a[0]))

c = max(b)
b.remove(c)

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

from collections import defaultdict

MOD = 10**9 + 7

primes = defaultdict(int)

for a in A:
    p = 2
    while p * p <= a:
        if a % p == 0:
            cnt = 0
            while a % p == 0:
                cnt += 1
                a //= p
            primes[p] = max(primes[p], cnt)
        p += 1
    if a != 1:
        primes[a] = 1

lcm = 1
for p in primes.value():
    lcm *= pow(p, primes[p], MOD) % MOD

ans = 0
for a in A:
    ans += lcm * pow(a, MOD-2, MOD) % MOD
    ans %= MOD

print(ans)

### FIXED CODE ###

from functools import reduce
from fractions import gcd

N = int(input())
A = list(map(int, input().split()))
 
MOD = 10 ** 9 + 7
 
lcm = reduce(lambda x,y: x*(y//gcd(x,y)), A)
lcm %= MOD

coef = sum(pow(a, MOD-2, MOD) for a in A)
ans = lcm * coef % MOD

print(ans)
import sys
import copy
#import math
#import itertools
#import numpy as np
#import re

def func(x,m):
    return x**2%m

N,X,M=[int(c) for c in input().split()]
myset = {X}
mydict = {0:X}
A = []
A.append(X)
s = X
#i=0は計算したので1から
for i in range(1,N):
    A.append(func(A[i-1],M))
    if A[i] in myset:
        i_stop = i
        break
    myset.add(A[i])
    mydict[A[i]] = i
    s+=A[i]
    if i == N-1:
        print(s)
        sys.exit(0)

#最後にA[i]が出現したのは？
A_repeat = A[mydict[A[i_stop]]:i_stop]

s+=((N-1)-(i_stop-1))//len(A_repeat)*sum(A_repeat)

for k in range(((N-1)-(i_stop-1))%len(A_repeat)):
   s+=A_repeat[k]

print(s) 

### FIXED CODE ###

import sys
import copy
#import math
#import itertools
#import numpy as np
#import re

def func(x,m):
    return x**2%m

N,X,M=[int(c) for c in input().split()]
myset = {X}
mydict = {X:0}
A = []
A.append(X)
s = X
i = 0
i_stop = i
#i=0は計算したので1から
for i in range(1,N):
    A.append(func(A[i-1],M))
    if A[i] in myset:
        i_stop = i
        break
    myset.add(A[i])
    mydict[A[i]] = i
    s+=A[i]
    if i == N-1:
        print(s)
        sys.exit(0)
    if A[i] == 0:
        print(s)
        sys.exit(0)

if i!=0:
    #最後にA[i]が出現したのは？
    A_repeat = A[mydict[A[i_stop]]:i_stop]
    s+=((N-1)-(i_stop-1))//len(A_repeat)*sum(A_repeat)

    for k in range(((N-1)-(i_stop-1))%len(A_repeat)):
        s+=A_repeat[k]

print(s)
X, N = map(int,input().split())
if N == 0:
  print(X)
else:
  q = list(map(int,input().split()))
  q = list(set(q))
  p = [i for i in range(-1 , 102)]
  for i in range(len(q)):
    p.remove(q[i])

  S = 100
  for i in range(len(p)):
    if abs(X - p[i]) < S :
      ans = p[i]
      S = X - ans
    elif abs(X - p[i]) == S :
      if p[i] < ans :
        ans = p[i]
  print(ans)      

### FIXED CODE ###

X, N = map(int,input().split())
if N == 0:
  print(X)
else:
  q = list(map(int,input().split()))
  q = list(set(q))
  p = [i for i in range(-2 , 102)]
  for i in range(len(q)):
    p.remove(q[i])

  S = 103
  for i in range(len(p)):
    if abs(X - p[i]) < S :
      ans = p[i]
      S = X - ans
    elif abs(X - p[i]) == S :
      if p[i] < ans :
        ans = p[i]
  print(ans)
N = int(input())
A,B = map(int,input().split())
P=list(map(int,input().split()))
a = sum(x<=A for x in P)
b = sum(x<=B and x>A for x in P) 
c = sum(x>B for x in P)

print(min(a,b,c))

### FIXED CODE ###

N = int(input())
H = int(input())
W = int(input())
print((N-H+1)*(N-W+1))
s = input()
if s[-1] != "s":
  print(s+'s')
elif s[-1] == 's'
  print(s[:-1]+'es')

### FIXED CODE ###

S = input()
if S[-1] == "s":
	print(S + "es")
else:
  	print(S + "s")
N, M = map(int, input().split())
A = list(map(int, input().split()))
b = []
for i in range(M):
    b.append(list(map(int, input().split())))
ans = 0
A.sort()
b.sort(key=lambda x: x[1], reverse=True)
j = 0
for i in range(M):
    if b[i][1] <= A[j]:
        break
    while A[j] < b[i][1] and b[i][0]:
        ans += b[i][1]
        b[i][0] -= 1
        j += 1
print(ans + sum(A[j:]))

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
b = []
for i in range(M):
    b.append(list(map(int, input().split())))
ans = 0
A.sort()
b.sort(key=lambda x: x[1], reverse=True)
j = 0
for i in range(M):
    if j >= N or b[i][1] <= A[j]:
        break
    while j < N and b[i][0] and b[i][1] > A[j]:
        ans += b[i][1]
        b[i][0] -= 1
        j += 1
if j >= N:
    print(ans)
else:
    print(ans + sum(A[j:]))
n = int(input())
 
for i in range(1, 9)
	for j in range(1, 9)
		if n == i * j:
			print("Yes")
			break
 
print("No")

### FIXED CODE ###

n = int(input())
ans = ('No')
for i in range(1,10):
    for j in range(1,10):
        if i * j == n:
            ans = ('Yes')
            break
print(ans)
n=map(int,input().split())
xlist=[]
ylist=[]
v=list(map(int,input().split()))
c=list(map(int,input().split()))
for i in range(n):
  if v[i]>c[i]:
    xlist.append(v[i])
    ylist.append(c[i])
ans=sum(xlist)-sum(ylist)
print(ans)

### FIXED CODE ###

n=int(input())
xlist=[]
ylist=[]
v=list(map(int,input().split()))
c=list(map(int,input().split()))
for i in range(n):
  if v[i]>c[i]:
    xlist.append(v[i])
    ylist.append(c[i])
ans=0
ans=sum(xlist)-sum(ylist)
print(ans)
X, N = map(int, input().split())
p_int_list = []

if N == 0:
    print(X)
    exit()
else:
    p_int_list = list(map(int, input().split()))
    p_int_list = sorted(p_int_list)


ans_range = []
for i, j in zip(p_int_list[:-1], p_int_list[1:]):
    if j < 0:
        if abs(j) <= X <= abs(i):
            ans_range = [abs(j), abs(i)]
    else:
        if i <= X <= j:
            ans_range = [i, j]
            if i < 0:
                print(0)
                exit()

ans = 0
p_int_set = set(p_int_list)

if ans_range[1] - ans_range[0] != 1:
    if ans_range[1] == X:
        print(ans_range[1] - 1)
        exit()
    elif ans_range[0] == X:
        if X - 1 in p_int_set:
            print(X + 1)
            exit()
        else:
            print(X + 1)
            exit()
elif ans_range[1] - ans_range[0] == 1:
    for i in range(1, N):
        if ans_range[0] - i not in p_int_set:
            print(ans_range[0] - i)
            exit()
        elif ans_range[1] + i not in p_int_set:
            print(ans_range[1] + i)
            exit()


### FIXED CODE ###

X, N = map(int, input().split())
p_int_list = []

if N == 0:
    print(X)
    exit()
else:
    p_int_list = list(map(int, input().split()))

p_int_set = set(p_int_list)

if X not in p_int_set:
    print(X)
    exit()

for i in range(1, 10000):
    if X - i not in p_int_set:
        print(X - i)
        exit()
    elif X + i not in p_int_set:
        print(X + i)
        exit()
a,b,c,k = list(map(int, input().split()))

ans = 0

while(k > 0):
  {
    if (a > 0)
      a-=1
      ans+=1
      k-=1
    if (a == 0 & b > 0){
      b-=1
      k-=1
    }
    if (a == 0 & b == 0 & c > 0) {
      c-=1
      ans-=1
      k-=1
    }
  }
print(ans)

### FIXED CODE ###

a,b,c,k = list(map(int, input().split()))

ans = 0

if a >= k:
  print(k)
elif a+b >=k:
  print(a)
else:
  print(a-(k-a-b))
a, b = int(raw_input())
a = int(raw_input())
 
b, c  = divmod(a, 3600)
d, e = divmod(c, 60)

print ("%d:%d:%d") % (b,d,e)

### FIXED CODE ###

a, b = map(int, raw_input().split())
if a > b:
	print "a > b"
elif a < b:
	print "a < b"
else:
	print "a == b"
n = list(int, input().split())
if 7 in n:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n = list(input())
n = list(map(int, n))
if 7 in n:
    print('Yes')
else:
    print('No')
w = input('')
h = input('')
print(w*h)


### FIXED CODE ###

w,h = map(int, raw_input().split())

print(str(w*h) + ' ' + str((w+h)*2))
from itertools import combinations

# input
L, R = map(int, input().split())
mod0 = [n for n in range(0, R + 1, 2019) if L <= n <= R]
# check
target_num = list(range(L, R + 1))
if mod0:
    print(0)
else:
    nC2 = list(combinations(target_num, 2))
    mods_ans = [(i * j) % 2019 for i, j in nC2]

    print(min(mods_ans))

### FIXED CODE ###

from itertools import combinations

# input
L, R = map(int, input().split())

# check
mod0 = [n for n in range(0, R + 1, 2019) if L <= n]
if not mod0:
    target_num = list(range(L, R + 1))
    nC2 = list(combinations(target_num, 2))
    mods_ans = [(i * j) % 2019 for i, j in nC2]

    print(min(mods_ans))
else:
    print(0)
s = input()
ans = ""
for char in s:
    if char != 'B':
        ans += char
    else:
        if ans == "":
            pass
        else:
            len = len(ans)
            ans = ans[0:len - 1]
print(ans)


### FIXED CODE ###

s = input()
ans = ""
for char in s:
    if char != 'B':
        ans += char
    else:
        if ans == "":
            pass
        else:
            le = len(ans)
            ans = ans[0:le - 1]
print(ans)
c = input()
lst = [a,e,i,o,u]
if c in lst:
	print("vowel")
else:
	print("consonant")

### FIXED CODE ###

c = input()
lst = ["a","e","i","o","u"]
if c in lst:
	print("vowel")
else:
	print("consonant")
import math
N = int(input())
if math.log(25*N+26, 26) == int(math.log(25*N+26, 26)):
    d = int(math.log(25*N+26, 26)) -1
else:
    d = int(math.log(25*N+26, 26))
pre = (pow(26,d)-26)//25
diff = N - pre
ans = [97 for _ in range(d)]
for i in range(d):
    if i == d-1:
        ans[i] += diff -1
        break
    if diff % pow(26, d-1-i) == 0:
        x = 25
    else:
        x = diff // pow(26, d-1-i)
    ans[i] += x
    diff -= x*pow(26, d-1-i)
for a in ans:
    print(chr(a), end='')

### FIXED CODE ###

N = int(input())
ans = ''
while N >0:
    N -= 1
    ans += chr(97 + N%26)
    N //= 26
print(ans[::-1])
S, T = map(int, input().split())

cnt = 0
for s, t in zip(S, T):
  if s != t:
    cnt += 1

print(cnt)

### FIXED CODE ###

S = input()
T = input()

cnt = 0
for s, t in zip(S, T):
  if s != t:
    cnt += 1

print(cnt)
N,M,V,P = map(int,input().split())
A = list(map(int,input().split()))

#二分探索するからAをsortする
A = sorted(A,reverse=True)

left=0
right=N

while left<=right:
    mid = (left+right)//2

    if mid<P:#そもそも入っている
        left = mid + 1
    elif A[mid] + M < A[P-1]:
        right = mid - 1
    else:
        voted = P * M
        voted += (N-mid-1)*M

        for v in A[P-1:mid]:
            voted += min(max(A[mid]+M-v,0),M)

        if voted <=M*V:
            right = mid-1
        else:
            left= mid+1

print(left)


### FIXED CODE ###

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

#二分探索するからAをsortする
A = sorted(A,reverse=True)

left=0
right=N-1

while left<=right:
    mid = (left+right)//2

    if mid<P:#そもそも入っている
        left = mid + 1
    elif A[mid] + M < A[P-1]:
        right = mid -1
    else:
        voted = P * M
        for _ in range(mid+1,N):
            voted += M

        for v in A[P-1:mid]:
            voted += A[mid]+M-v

        if voted >= M*V:
            left= mid+1
        else:
            right = mid-1

print(left)
T1,T2=map(int,input().split())
A1,A2=map(int,input().split())
B1,B2=map(int,input().split())


if A1>=B1:
    pass
else:
    A1,B1=B1,A1
    A2,B2=B2,A2
D1=(A1-B1)*T1
D2=(A2-B2)*T2

if D1==-D2:
    print("infinity")
elif D1*D2>0:
    print("0")
else:
    assert D1>=0 and D2<=0
    diff = abs(D1+D2)
    D1=abs(D1)
    if D1%diff==0:
        print(D1//diff*2+1)
    else:
        assert 1==2


### FIXED CODE ###

from math import ceil
T1,T2=map(int,input().split())
A1,A2=map(int,input().split())
B1,B2=map(int,input().split())


#A1>=B1にする
if A1>=B1:
    pass
else:
    A1,B1=B1,A1
    A2,B2=B2,A2

D1=(A1-B1)*T1#>=0
D2=(A2-B2)*T2#?

if D1==-D2:
    print("infinity")
elif D1+D2>=0:
    print("0")
else:
    diff = abs(D1+D2)#マイからこれだけ差が開く
    if D1%diff==0:
        print(D1//diff*2)
    else:
        print(ceil(D1/diff)*2-1)
import fractions
from functools import reduce

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

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

n = int(input())
t = [int(input()) for i in range(n)]
print(lcm_list(t))

### FIXED CODE ###

import fractions
from functools import reduce

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

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

n = int(input())
t = [int(input()) for i in range(n)]
print(lcm_list(t))
def q3():
    def lcm(x, y):
        """ xとyの最小公倍数を求める """
        # import math
        import fractions
        return (x * y) // fractions.gcd(x, y)

    A, B = (int(i) for i in input().split())
    print(lcm(A, B))


if __name__ == '__main__':
    q3()


### FIXED CODE ###

def q3():
    """C - Vacation"""
    N = int(input())

    dp = [[0]*N for i in range(3)]
    dp[0][0], dp[1][0], dp[2][0] = (int(i) for i in input().split())

    if N == 1:
        print(max([dp[0][0], dp[1][0], dp[2][0]]))
        return

    a, b, c = (int(i) for i in input().split())
    dp[0][1] = max(dp[1][0], dp[2][0]) + a
    dp[1][1] = max(dp[0][0], dp[2][0]) + b
    dp[2][1] = max(dp[1][0], dp[0][0]) + c

    if N == 2:
        print(max([dp[0][1], dp[1][1], dp[2][1]]))
        return

    for i in range(1, N-1):
        a, b, c = (int(i) for i in input().split())
        dp[0][i+1] = max(dp[1][i], dp[2][i]) + a
        dp[1][i+1] = max(dp[0][i], dp[2][i]) + b
        dp[2][i+1] = max(dp[1][i], dp[0][i]) + c
    print(max([dp[0][-1], dp[1][-1], dp[2][-1]]))


if __name__ == '__main__':
    q3()