Harryxun/stf_run huggingface dataset:
INFTY = 1 << 21
WHITE = 0
GRAY = 1
BLACK = 2
 
n = int(input())
M = [list(map(int, input().split())) for i in range(n)]
 
d = [INFTY for i in range(n)]
color = [WHITE for i in range(n)]
 
for u in range(n):
    U = list(map(int, input().split()[2:]))
    for j in range(0, len(U), 2):
        M[u][U[j]] = U[j + 1]
        
def dijkstra():
    global M, d, color
    d[0] = 0
    color[0] = GRAY
    while(1):
        minv = INFTY
        u = -1
        for i in range(n):
            if (minv > d[i] and color[i] != BLACK):
                u = i
                minv = d[i]
        if (u == -1):
            break
        color[u] = BLACK
        for v in range(n):
            if (color[v] != BLACK and M[u][v] != INFTY):
                if (d[v] > d[u] + M[u][v]):
                    d[v] = d[u] + M[u][v]
                    color[v] = GRAY
    for i in range(n):
        print(str(i), (-1 if d[i] == INFTY else str(d[i])))
dijkstra()

### FIXED CODE ###

from sys import stdin

INFTY = 1 << 21
WHITE = 0
GRAY = 1
BLACK = 2

n = int(stdin.readline())
M = [[INFTY for i in range(n)] for j in range(n)]

for u in range(n):
    U = list(map(int, stdin.readline().split()[2:]))
    for j in range(0, len(U), 2):
        M[u][U[j]] = U[j+1]

d = [INFTY for i in range(n)]
color = [WHITE for i in range(n)]

def dijkstra():
    global n
    d[0] = 0
    color[0] = GRAY
    while(1):
        minv = INFTY
        u = -1
        for i in range(n):
            if (minv > d[i] and color[i] != BLACK):
                u = i
                minv = d[i]
        if (u == -1):
            break
        color[u] = BLACK
        for v in range(n):
            if (color[v] != BLACK and M[u][v] != INFTY):
                if(d[v] > d[u] + M[u][v]):
                    d[v] = d[u] + M[u][v]
                    color[v] = GRAY
    for i in range(
n):
        print(i, (-1 if d[i] == INFTY else d[i]))
dijkstra()
import fractions
import sys
sys.setrecursionlimit(100000000)
N,M = map(int,input().split())
S = input()
T = input()
X = (N * M) // fractions.gcd(N,M)

div_N = X // N
div_M = X // M  
s = [""] * X

for ss in range(N):
  if ss == 0:
    s[0] = S[0]
    if s[0] != T[0]:
      print(-1)
      exit()
  else:
    s[ss * (div_N)] = S[ss]

for tt in range(M):
  if tt == 0:
    if s[0] != T[tt]:
      print(-1)
      exit()
  else:
    pro = tt * (div_M)
    if s[pro] != "" and s[pro] != T[tt]:
      print(-1)
      exit()
print(X)



### FIXED CODE ###

import fractions
N,M = map(int,input().split())
S = input()
T = input()
G = fractions.gcd(N,M)
L = (N * M) // G
div_N = N // G
div_M = M // G

i = 0
j = 0

while i < N and j < M:
  if S[i] != T[j]:
    print(-1)
    exit()
  else:
    i += div_N
    j += div_M
print(L)
A = [0]*N
for i in range(N):
    a = int(input())
    A[i]=a
    li[i]=[list(map(int,input().split())) for i in range(a)]

counter = 0
for humen in product([0,1],repeat=N):
    flag = True
    for i in range(N):
        if humen[i]==1:
            for s in range(A[i]):
                if not li[i][s][1]==humen[li[i][s][0]-1]:
                    flag=False
                    break
        
                
    if flag :
        counter = max(counter,humen.count(1))


print(counter)


### FIXED CODE ###

from itertools import product

N = int(input())

li = [[] for i in range(N)]
A = [0]*N
for i in range(N):
    a = int(input())
    A[i]=a
    li[i]=[list(map(int,input().split())) for i in range(a)]

counter = 0
for humen in product([0,1],repeat=N):
    flag = True
    for i in range(N):
        if humen[i]==1:
            for s in range(A[i]):
                if not li[i][s][1]==humen[li[i][s][0]-1]:
                    flag=False
                    break
        
                
    if flag :
        counter = max(counter,humen.count(1))


print(counter)
import itertools
import math
MOD = 1000000007
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)% MOD
N,K = map(int,input().split())
for i in range(1,K+1):
    print ((C(N-K+1,i)*C(K-1,i-1))% MOD)


### FIXED CODE ###

import itertools
import math
MOD = 1000000007
def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)% MOD
def X(n, r):
  try:
    return C(n-1,n-r) 
  except:
    return 0
N,K = map(int,input().split())

for i in range(1,K+1):
  if (1==i and K==N):
    print (1)
  else:
    print (X(K,i)*((X(N-K,i+1)+2*X(N-K,i)+X(N-K,i-1)))% MOD)
import numpy as np

h, n = map(int, input().split())
ab = np.array([tuple(map(int, input().split())) for _ in range(n)])

a, b = ab[:, 0], ab[:, 1]
dp = np.zeros(h+1, dtype=int)
for i in range(1, h+1):
    dp[i] = np.min(dp[i-a] + b)

print(dp[-1])

### FIXED CODE ###

import numpy as np

h, n = map(int, input().split())
ab = np.array([tuple(map(int, input().split())) for _ in range(n)])

a, b = ab[:, 0], ab[:, 1]
dp = np.zeros(h+1, dtype=np.int)
for i in range(1, h+1):
    dp[i] = np.min(dp[np.maximum(i-a, 0)] + b)

print(dp[h])
s = {c:list(input()) for c in "abc"}
s = "a"
while S[s]:s = S[s].pop(0)
print(s.upper())

### FIXED CODE ###

S={c:list(input()) for c in "abc"}
s="a"
while S[s]:s=S[s].pop(0)
print(s.upper())
import sys
from fractions import gcd
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]


NN = 10 ** 6 + 100
primes = []
isprime = [True for _ in range(NN + 1)]
min_factor = [-1 for _ in range(NN + 1)]
#エラトステネスの篩
for i in range(2, NN + 1):
    if not isprime[i]:
        continue
    primes.append(i)
    min_factor[i] = i
    for j in range(i * 2, NN + 1, i):
        isprime[j] = False
        if min_factor[j] == -1:
            min_factor[j] = i
def prime_factrize(n):
    res = []
    while n != 1:
        prime = min_factor[n]
        exp = 0
        while min_factor[n] == prime:
            exp += 1
            n //= prime
        res.append([prime, exp])
    return res


n = INT()
a = LIST()
ll = []
for i in range(n):
    aa = prime_factrize(a[i])
    for j in range(len(aa)):
        try:
            idx = [ll[k][0] for k in range(len(ll))].index(aa[j][0])
            ll[idx][1] = max(ll[idx][1], aa[j][1])
        except:
            ll.append(aa[j])
l = 1
for i in range(len(ll)):
    l *= pow(ll[i][0], ll[i][1])
ans = 0
for i in range(n):
    ans += l // a[i]
    ans %= mod
print(ans)


### FIXED CODE ###

import sys
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
a = LIST()
l = 1
for i in a:
    l = lcm(l, i)
l %= mod
ans = 0
for i in a:
    ans += l * pow(i, mod - 2, mod)
print(ans % mod)
import math
n = int(input())
for i in range(5):
  l = int(input())
print(math.ceil(n/min(l))+4)

### FIXED CODE ###

import math
n = int(input())
l=[int(input()) for i in range(5)]
print(math.ceil(n/min(l))+4)
inp = map(int, input().split())
if inp[0] < inp[1] :
  print (0)
else:
  print (10)

### FIXED CODE ###

a, b = map(int, input().split())
if a < b :
  print (0)
else:
  print (10)
x, y = map(int,input().split())
print([-1, x][y%x])

### FIXED CODE ###

x, y = map(int,input().split())
print([x, -1][x%y==0])
n=int(input())
a=[int(input())-1 for _ in range(n)]
ans=-1
l=0
for i in range(n):
    l=a[l]
    cnt[l]+=1
    if l==1:
        ans=i+1
        break
print(ans)

### FIXED CODE ###

n=int(input())
a=[int(input())-1 for _ in range(n)]
ans=-1
l=0
for i in range(n):
    l=a[l]
    if l==1:
        ans=i+1
        break
print(ans)
h,w=map(int,input().split())
if h==1||w==1:
  print(1)
  
else:
  print((h*w+1)//2)

### FIXED CODE ###

h,w=map(int,input().split())
if h==1 or w==1:
  print(1)
  
else:
  print((h*w+1)//2)
input = raw_input()
s = int(input.split()[0])
l = int(input.split()[1])
ans_1 = s*l
ans_2 = 2*(s+l)

print src(ans_1)+" "+src(ans_2)

### FIXED CODE ###

input = raw_input()
s = int(input.split()[0])
l = int(input.split()[1])
ans_1 = s*l
ans_2 = 2*(s+l)

print str(ans_1)+" "+str(ans_2)
n=int(input())

a=list(map(int,input().split()))
  
b=[]
for j in range (n-1):
  c=a[j+1]-a[j]
  b.append(c)

if max(b)>-1:
  print(max(b))
else:
  print(0)
  

### FIXED CODE ###

n=int(input())

a=list(map(int,input().split()))
  
b=[]
if n>1:
  for j in range (n-1):
    c=a[j]-a[j+1]
    if c>-1:
      b.append(c)
      a[j+1]=a[j+1]+c
    else:
      b.append(0)
      
   
  if max(b)>-1:
    print(sum(b))
  else:
    print(0)
    
else:
  print(0)
def stdinput():
    from sys import stdin
    return stdin.readline().strip()

def main():
    n = int(stdinput())
    A = list(sorted(map(int, stdinput().split(' '))))
    q = int(stdinput())
    M = list(map(int, stdinput().split(' ')))

    for m in M:
        if check(m, 0, A):
            print('yes')
        else:
            print('no')

def check(m, a, A):
    # print(f'{m}, {a}, {A}')
    for i, next_a in enumerate(A):
        this_a = a + next_a
        if this_a == m:
            return True
        elif this_a < m:
            if check(m, this_a, A[i+1:]):
                return True
    return False

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')


### FIXED CODE ###

def stdinput():
    from sys import stdin
    return stdin.readline().strip()

def main():
    from itertools import combinations
    n = int(stdinput())
    *A, = map(int, stdinput().split(' '))
    q = int(stdinput())
    *M, = map(int, stdinput().split(' '))

    all_canditee = set([sum(c) for i in range(1, n+1) for c in combinations(A, i)])

    # print(A)
    # print(all_canditee)

    for m in M:
        if m in all_canditee:
            print('yes')
        else:
            print('no')

# can not pass 9/10
def check(m, a, A):
    for i, next_a in enumerate(A):
        this_a = a + next_a
        if this_a == m:
            return True
        elif this_a < m:
            if check(m, this_a, A[i+1:]):
                return True
    return False

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')
predict_weather = list(input())
actual_weather = list(input())
 
count = 0
for i in range(len(predict_weather)):
  if predict_weather[i] == actual_weather[i]:
    count += 1
 
return count


### FIXED CODE ###

predict_weather = list(input())
actual_weather = list(input())
 
count = 0
for i in range(len(predict_weather)):
  if predict_weather[i] == actual_weather[i]:
    count += 1
 
print(count)
n, x = (int(i) for i in input().split())
l_array = [int(i) for i in input().split()]

counter = 0
coordinate = 0

while counter < n+1 and coordinate<=x:
    counter+=1
    if counter = n+1:
        break
    else:
        coordinate += l_array[counter-1]


print(counter)


### FIXED CODE ###

n, x = (int(i) for i in input().split())
l_array = [int(i) for i in input().split()]

counter = 0
coordinate = 0

while counter < n+1 and coordinate<=x:
    counter+=1
    if counter == n+1:
        break
    else:
        coordinate += l_array[counter-1]


print(counter)
ab = input().split()
print(ab[0]*ab[1])

### FIXED CODE ###

a, b = [int(i) for i in input().split()]
print(a*b, (a+b)*2)
test_file = open('C:\\Users\\nanashi\Downloads\\2600-in21.txt')

input = lambda: test_file.readline().rstrip()


N, W, H = [int(x) for x in input().split()]

map_x = [False] * W
count_x = 0
map_y = [False] * H
count_y = 0

wifi_x = []
wifi_y = []
for _ in range(N):
    x, y, w = [int(x) for x in input().split()]
    wifi_x.append((x - w, x + w))
    wifi_y.append((y - w, y + w))
wifi_x.sort(key=lambda a: a[1], reverse=True)
wifi_y.sort(key=lambda a: a[1], reverse=True)


def check_wifi(wifi, l):
    for x1, x2 in wifi:
        if x1 <= l < x2:
            return x2
    return None


ans_x = True
b = 0
for x in range(W):
    if x < b:
        continue

    b = check_wifi(wifi_x, x)
    if not b:
        ans_x = False
        break

if not ans_x:
    b = 0
    for y in range(H):
        if y < b:
            continue

        b = check_wifi(wifi_y, y)
        if not b:
            print('No')
            exit()

print('Yes')

### FIXED CODE ###

N, W, H = [int(x) for x in input().split()]

map_x = [0] * W
map_y = [0] * H

for _ in range(N):
    x, y, w = [int(x) for x in input().split()]
    mx = max(0, x - w)
    map_x[mx] = max(map_x[mx], x + w - mx)
    my = max(0, y - w)
    map_y[my] = max(map_y[my], y + w - my)


def check_wifi(wifi):
    m = 0
    end = len(wifi)

    for i, x in enumerate(wifi):
        if x and i + x > m:
            m = i + x

        if m >= end:
            return True

        if i < m:
            continue

        return False

    return False


print('Yes' if check_wifi(map_x) or check_wifi(map_y) else 'No')
import bisect
import itertools
 
a, b, q = map(int, input().split())
ss, tt = [], []
for _ in range(a):
  ss.append(int(input()))
for _ in range(b):
  tt.append(int(input()))
  
for _ in range(q):
  x = int(input())
  md = pow(10, 15)
  xs, xt = bisect.bisect_left(ss, x), bisect.bisect_left(tt, x)
  ls, rs, lt, rt = ss[max(0, xs-1)], ss[min(a-1, xs)], tt[max(0, xt-1)], tt[min(b-1, xt)]
  for s, t in itertools.product([ls, rs], [lt, rt]):
    if s > t:
      if t > x:
        md = s - x if s - x < md else md
      elif s > x:
        if md > 2 * (s-x) + x-t:
          md = 2 * (s-x) + x-t
        if md > 2 * (x-t) + s-x:
          md = 2 * (x-t) + s-x
      else:
        md = x - t if x - t < md else md
    else:  # t > s
      if s > x:
        md = t - x if t - x < md else md
      elif t > x:
        if md > 2 * (x-s) + t-x:
          md = 2 * (x-s) + t-x
        if md > 2 * (t-x) + x-s:
          md = 2 * (t-x) + x-s
      else:
        md = x - s if x - s < md else md
  print(md)

### FIXED CODE ###

def solve():
  y,m,d = map(int, input().split("/"))
  if y < 2019: 
    return "Heisei"
  elif y > 2019: 
    return "TBD"
    
  if m < 4: 
    return "Heisei"
  elif m > 4: 
    return "TBD"
    
  if d > 30: 
    return "TBD"
  return "Heisei"

print(solve())
l = raw_input().split()
#l=input[0].split()

n = int(l[0])
a = [2147483647]*50000
change = 1

for i in range(0,int(l[1])):
	l = raw_input().split()
#	l=input[i+1].split()
	if int(l[0])==0:
		a[int(l[1])]=int(l[2])
		change = 1
	elif change==l[1]+l[2]:
		print m
	else:
		change = l[1]+l[2]
		m = min(a[int(l[1]):int(l[2])+1])
		print m

### FIXED CODE ###

#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
 
 
def main(init=int(2**31-1), readline=stdin.readline):
    n, q = (int(s) for s in readline().split())
 
    a = [init] * n
    b = [init] * ((n // 100) + 1)
 
    for _ in range(q):
        com, x, y = (int(s) for s in readline().split())
        if com:
            bx = x - (x % 100) + 100
            by = y - (y % 100)
            if bx < by:
                m = min(min(a[x:bx]), min(b[bx//100:by//100]),
                        min(a[by:y+1]))
            else:
                m = min(a[x:y+1])
            print(m)
        else:
            a[x] = y
            bx = x - (x % 100)
            b[x//100] = min(a[bx:bx+100])
 
 
main()
N = int(input())
A = list(max(int, input().split()))

def gcd(x, y):
  if x % y == 0:
    return y
  else:
    gcd(y, x % y)

num = A[0]
for i in range(1, N):
  num = gcd(max(num, A[i]), min(num, A[i]))

print(num)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
 
def gcd(x, y):
  if x % y == 0:
    return y
  else:
    return gcd(y, x % y)
 
num = A[0]
for i in range(1, N):
  num = gcd(max(num, A[i]), min(num, A[i]))
 
print(num)
i=list(map(int, input().split()))
 
if i[0]==i[1] | i[0]==i[2] | i[1]==i[2]:
	if i[0]==i[1] & i[0]==i[2]  & i[1]==i[2]:
    	print('No')
	else:
		print('Yes')
else:
	print('No')

### FIXED CODE ###

i=list(map(int, input().split()))
 
if i[0]==i[1] or i[0]==i[2] or i[1]==i[2]:
	if i[0]==i[1] and i[0]==i[2]:
		print('No')
	else:
		print('Yes')
else:
    print('No')
l=list(map(int(input().strip().split()))
       print(str(l[3]+ " " +l[1]+" "+l[2]))

### FIXED CODE ###

a = list(map(int,input().strip().split()))
print (a[2],a[0],a[1])
import sys

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

if N % 2 != 0:
    if A[0] == 0:
        a = A[1:]
        j = 1
        for i in range(0, N//2 + 1, 2):
            if a[i] == a[i+1] == 2*j:
                j += 1
            else:
                print(0)
                sys.exit()
        print((2**(N//2)) % (10**9+7))
        
    else:
        print(0)
else:
    j = 1
    for i in range(0, N//2+1, 2):
        if A[i] == A[i+i] == 2*j -1:
            j += 1
        else:
            print(0)
            sys.exit()
    print((2**(N//2)) % (10**9+7))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
ans = 1
if N % 2 == 0:
    if len(A) != 2*len(set(A)):
        ans = 0
else:
    if A.count(0) == 1:
        A.remove(0)
        if len(A) != 2*len(set(A)):
            ans = 0
    else:
        ans = 0
if ans == 0:
    print(0)
else:
    print((2**(N//2))%(10**9+7))
s = input().rstrip("\n")
from collections import Counter
count = Counter(s)
print(min(counter.values()) * 2)

### FIXED CODE ###

s = input().rstrip("\n")
from collections import Counter
count = Counter(s)
if len(count.values()) < 2:
  print(0)
else:
  print(min(count.values()) * 2)
N = int(input())
sum = 0
for i in range(0,N):
  sum + i = sum
print(sum)

### FIXED CODE ###

N = int(input())
sum = 0
for i in range(0,N+1):
  sum+=i
print(sum)
print(int(input())/int(input()))


### FIXED CODE ###

T,X=map(int,input().split())
print(T/X)
l=len(s)

ans=0

if s[0]=="0":
    for i in range(1,l):
        if i%2 != 0:
            if s[i] != "1":
                ans+=1
        
        if i%2 == 0:
            if s[i] != "0":
                ans+=1

else:
    for i in range(1,l):
        if i%2 != 0:
            if s[i] != "0":
                ans+=1
        
        if i%2 == 0:
            if s[i] != "1":
                ans+=1

print(ans)

### FIXED CODE ###

s=input()
l=len(s)

ans=0

if s[0]=="0":
    for i in range(1,l):
        if i%2 != 0:
            if s[i] != "1":
                ans+=1
        
        if i%2 == 0:
            if s[i] != "0":
                ans+=1

else:
    for i in range(1,l):
        if i%2 != 0:
            if s[i] != "0":
                ans+=1
        
        if i%2 == 0:
            if s[i] != "1":
                ans+=1

print(ans)
import math
from decimal import Decimal
a,b,c = map(int,input().split())

if Decimal.sqrt(a) + Decimal.sqrt(b) < Decimal.sqrt(c):
    print('Yes')
else:
    print('No')

### FIXED CODE ###

from decimal import Decimal
a,b,c = map(int,input().split())
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
if Decimal.sqrt(a) + Decimal.sqrt(b) < Decimal.sqrt(c):
    print('Yes')
else:
    print('No')
N = int(input())
a = list(map(int, input().split()))
l = a[0]
for i in range(1,N):
  l = l * a[i] // fractions.gcd(l, a[i])
m = l-1
fm = 0
for i in range(N):
  fm += m % a[i]
print(fm)

### FIXED CODE ###

import fractions

N = int(input())
a = list(map(int, input().split()))
l = a[0]
for i in range(1,N):
  l = l * a[i] // fractions.gcd(l, a[i])
m = l-1
fm = 0
for i in range(N):
  fm += m % a[i]
print(fm)
N = input
if n >1000:
    print("ABC")
else:
    print("ABD")



### FIXED CODE ###

N = int(input())
if N <= 999:
    print("ABC")
else:
    print("ABD")
# math.gcd()を使う
import math
N, X = map(int, input().split())
# 一行の入力をリストxに入れる
x = list(map(int, input().split()))
# すべての(x[i]-X)の最大公約数が答え
# 最初の最大公約数
t = abs(x[0] - X)
for a in x:
    # 最大公約数を更新
    t = math.gcd(t, a - X)
print(t)


### FIXED CODE ###

A, B = map(int, input().split())
if A % 2 is 0 or B % 2 is 0:
    print('No')
else:
    print("Yes")
H, W = [int(x) for x in input().split()] A = [[0]*W for i in range(H)] for c in [1, -1]: for i in range(H): arr = [int(x) for x in input().split()] for j in range(W): A[i][j] += arr[j] * c M = 160*80 dp = [[0]*W for i in range(H)] dp[0][0] = 1 << M for i in range(H): for j in range(W): if i > 0: dp[i][j] |= dp[i-1][j] if j > 0: dp[i][j] |= dp[i][j-1] a = abs(A[i][j]) dp[i][j] = (dp[i][j] << a) | (dp[i][j] >> a) ans = M for i in range(2*M): if dp[H-1][W-1] & (1 << i) > 0: ans = min(ans, abs(M-i)) print(ans)


### FIXED CODE ###

H, W = [int(x) for x in input().split()]
 
A = [[0]*W for i in range(H)]
for c in [1, -1]:
    for i in range(H):
        arr = [int(x) for x in input().split()]
        for j in range(W):
            A[i][j] += arr[j] * c
 
M = 160*80
dp = [[0]*W for i in range(H)]
dp[0][0] = 1 << M
for i in range(H):
    for j in range(W):
        if i > 0:
            dp[i][j] |= dp[i-1][j]
        if j > 0:
            dp[i][j] |= dp[i][j-1]
        a = abs(A[i][j])
        dp[i][j] = (dp[i][j] << a) | (dp[i][j] >> a)
 
ans = M
for i in range(2*M):
    if dp[H-1][W-1] & (1 << i) > 0:
        ans = min(ans, abs(M-i))
print(ans)
S = input()
K = int(input())

for i in range(K):
    if S[i] != '1':
        ans = S[i]
        break
print(ans)

### FIXED CODE ###

S = input()
K = int(input())
 
k = min(K,len(S))

ans = 1

for i in range(k):
    if S[i] != '1':
        ans = S[i]
        break
print(ans)
import math
A,B,C,D = map(int,input().split())
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
E = lcm(C, D)
sample = B-A+1
ans = sample - ((B//C-A//C) + (B//D-A//D)-(B//E-A//E))
print(ans)


### FIXED CODE ###

import fractions as f
a,b,c,d = map(int,input().split())
i = abs((a-1)//c-b//c)
j = abs((a-1)//d-b//d)
 
def lcm(x,y):
  return (x*y)//f.gcd(x,y)
l = lcm(c,d)
k = abs((a-1)//l-b//l)
print(b-a+1-(i+j-k))
S = input()
if s[0] == s[1]:
  print(Bad)
elif s[2] == s[1]:
  print(Bad)
elif s[3] == s[2]:
  print(Bab)
else:
  print(Good)

### FIXED CODE ###

s = input()
if s[0] == s[1]:
  print('Bad')
elif s[2] == s[1]:
  print('Bad')
elif s[3] == s[2]:
  print('Bad')
else:
  print('Good')
n = int(input())
ans = 0
A = [i for i in range(n+1)]
A = A[1::2]
for i in range(len(A)):
    a=0
    for j in range(len(A)):
        if A[i] % j == 0:
            a += 1
    if a == 8:
        ans += 1
print(ans)


### FIXED CODE ###

n = int(input())
ans=0
for i in range(1,n+1,2):
    a=0
    for j in range(1,i+1,2):
        if i%j==0:
            a+=1
    if a==8:
        ans+=1
print(ans)
e=input(S)
r=input(T)
x=0
for i in range(3):
    if e[i]==r[i]:
        x+=1
print(x)

### FIXED CODE ###

S=input()
T=input()
x=0
for i in range(3):
    if S[i]==T[i]:
        x += 1
print(x)
n, k = map(int,input().split())
l = [0] + list(map(int,input().split()))
places = [0 for _ in range(n+1)]
to = 1
time_2 = 0

for i in range(10**5+1):
    if places[to] == 1:
        x = to
        y = time_2
        break
    else:
        places[to] = 1
        to = l[to]
        time_2 += 1

to = 1
time_1 = 0
for j in range(y):
    if to == x:
        z = time_1
        break
    else:
        to = l[to]
        time_1 += 1

to = l[1]
if k >= z:
    for p in range(z):
        to = l[p]
    else:
        print(l[to])
else:
    for q in range((k-z)%(y-z)):
        to = l[q]
    else:
        print(l[to])

### FIXED CODE ###

n, k = map(int, input().split())
#print(n,k)
goto = [-1] + list(map(int, input().split()))
#print(goto)

l = [[_, 0] for _ in range(2*n)] # [順番, 町番号]
#print(l)
cnt = [0 for _ in range(n+1)] # カウンター

tmp = 1
for i in range(1, 2*n):
    l[i][1] = tmp
    cnt[l[i][1]] += 1
    tmp = goto[tmp]
    if cnt[l[i][1]] == 2:
        x = l[i]
        break
#print(l)
#print(x)

for j in range(n):
    if l[j][1] == x[1]:
        y = l[j]
        break
#print(y)

if y[0] > k:
    print(l[k+1][1])
else:
    z = (k-y[0]+1) % (x[0]-y[0]) + y[0]
    print(l[z][1])
from functools import reduce

def resolve():
	A,B=map(int,input().split())
	l=list(range(A,B+1))
	print(reduce(lambda a,b:a^b,l))
resolve()

### FIXED CODE ###

def F(n):
	if n%2==1:
		ans=0 if (n+1)%4==0 else 1
	else:
		ans=n^0 if n%4==0 else n^1
	return ans
def resolve():
	A,B=map(int,input().split())
	print(F(A-1)^F(B))
resolve()