Harryxun/stf_run huggingface dataset:
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

ans = 0
for i in range(M):
    ab_list = [[] for i in range(N)]
    for j in range(M):
        if i != j:
            k = ab[j]
            ab_list[k[0] - 1].append(k[1] - 1)
            ab_list[k[1] - 1].append(k[0] - 1)
            
    DFS_list = [0 for i in range(N)]
    DFS_list[i] = 0
    def DFS(v):
        for j in ab_list[v]:
            if DFS_list[j] == 0:
                DFS_list[j] = 1
                DFS(j)
    DFS(i)
    if sum(DFS_list) != N:
        ans += 1
print(ans)


### FIXED CODE ###

def wf(this_graf):
    s = len(graf)
    for k in range(s):
        for i in range(s):
            for j in range(s):
                this_graf[i][j] = min(this_graf[i][j], this_graf[i][k] + this_graf[k][j])
    return this_graf

n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(m)]
graf = [[10 ** 10 for i in range(n)] for j in range(n)]

for i, j in ab:
    graf[i - 1][j - 1] = 1
    graf[j - 1][i - 1] = 1

import copy
cnt = 0

for i, j in ab:
    this_graf = copy.deepcopy(graf)
    tmp = 0
    this_graf[i - 1][j - 1] = 10 ** 10
    this_graf[j - 1][i - 1] = 10 ** 10
    this_graf = wf(this_graf)
    for i in range(n):
        for j in range(n):
            if this_graf[i][j] == 10 ** 10:
                tmp = 1
                break
        if tmp:
            break
    cnt += tmp

print(cnt)
import functools

def sign(x):
    if x>0:
        return 1
    elif x==0:
        return 0
    else:
        return -1
    
def multiply(x,y):
    ans = x*y
    if ans>=10**9+7:
        ans %= 10**9+7
    return ans

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

if A[-1]<0 and K%2==1:
    combi = A[-K:]
    if K >1:
        answer =  functools.reduce(multiply,map(abs,combi[:-1]))
        answer *= combi[-1]
    else:
        answer = combi[0]
    answer %= 10**9+7
else:
    signs = 1
    i,j = 0,0
    for _ in range(K):
        if abs(A[i]) > abs(A[N-j-1]):
            signs *= sign(A[i])
            i += 1
            
        else:
            signs *= sign(A[N-j-1])
            j += 1
    combi = A[N-j:] + A[:i]
    del A[N-j:]
    del A[:i]
    combi = combi[::-1]     
       
    if signs == -1:
        if combi[-1] <0:
            del combi[0]
            combi.append(A[-1])
        else:
            if A[0]>0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]<0 and A[-1] >0:
                if combi[0]*A[0] > combi[-1]*A[-1]:
                    del combi[-1]
                    combi.insert(0,A[0])
                else:
                    del combi[0]
                    combi.append(A[-1])
            else:
                del combi[-1]
                combi.insert(0,A[0]) 

    answer =  functools.reduce(multiply,map(abs,combi))
print(answer)

### FIXED CODE ###

import functools

def sign(x):
    if x>0:
        return 1
    elif x==0:
        return 0
    else:
        return -1
    
def multiply(x,y):
    ans = x*y
    if ans>=10**9+7 or ans<0:
        ans %= (10**9+7)
    return ans

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()

if (A[-1]<0 and K%2==1):
    combi = A[-K:]
    if K >1:
        answer =  functools.reduce(multiply,combi)

elif K == N:
    answer = functools.reduce(multiply,A)
    
else:
    signs = 1
    i,j = 0,0
    for _ in range(K):
        if abs(A[i]) > abs(A[N-j-1]):
            signs *= sign(A[i])
            i += 1
            
        else:
            signs *= sign(A[N-j-1])
            j += 1
    combi = A[N-j:] + A[:i]
    del A[N-j:]
    del A[:i]
    combi = combi[::-1]     
       
    if signs == -1:
        if A:
            if combi[-1]<0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]>=0:
                del combi[0]
                combi.append(A[-1])
            elif A[0]<0 and A[-1] >0:
                if combi[0]*A[0] > combi[-1]*A[-1]:
                    del combi[-1]
                    combi.insert(0,A[0])
                else:
                    del combi[0]
                    combi.append(A[-1])
            elif A[-1] <= 0:
                del combi[-1]
                combi.insert(0,A[0]) 
                
    answer =  functools.reduce(multiply,combi)
print(answer)
import math
num = input().split(" ")
a = int(num[0])-1
b = int(num[1])
c = int(num[2])
d = int(num[3])
e = math.gcd(c, d)
x = b - (b//c) -(b//d) +(b//(c*d/e)) -(a -(a//c) -(a//d) + a//(c*d/e))
print(int(x))

### FIXED CODE ###

def gcd(a, b):
    while b!=0:
        a, b = b, a%b
    return a

num = input().split(" ")
a = int(num[0])-1
b = int(num[1])
c = int(num[2])
d = int(num[3])
e = int(c * d / int(gcd(c, d)))
bb = b - (b//c) -(b//d) +(b//e) 
aa = a - (a//c) -(a//d) + (a//e)
print(int(bb-aa))
n=int(input())
result=1000000000000
for i in range(n):
  nn=n/(i+1)
  if (nn.is_integer() and result>nn+i-1):
    result=nn+i-1
print(result)

### FIXED CODE ###

a,b=map(int,input().split())
if a>9 or b>9:
  print(-1)
else:
  print(a*b)
N = int(input())
for i in range(N):
    for j in range(N-i):
        if j == N-i-1:
            print(N)
        else:
            print(N,end='')

### FIXED CODE ###

A, B = map(int,input().split())
if B % A ==0:
    print(A+B)
else:
    print(B-A)
class SegmentTree:
    def __init__(self, lis, ele, op):
        self.len = len(lis)
        self.n = 1 << ((self.len - 1).bit_length())
        self.op = op
        self.ele = ele
        self.tree = self._build(lis)
    def _build(self, lis):
        res_tree = [self.ele] * (self.n - 1) + lis + [self.ele] * (self.n - self.len)
        for i in range(self.n - 2, -1, -1):
            res_tree[i] = self.op(res_tree[i * 2 + 1], res_tree[i * 2 + 2])
        return res_tree
    def __get__(self, i):
        return self.tree[self.n + i - 1]
    def update(self, i, x):
        i += self.n - 1
        self.tree[i] = x
        while i > 0:
            i -= 1
            i >>= 1
            self.tree[i] = self.op(self.tree[i * 2 + 1], self.tree[i * 2 + 2])
    def query(self, l, r):
        l +=  self.n - 1
        r += self.n - 1
        L = self.ele
        R = self.ele
        while l < r:
            if l & 1 == 0:
                L = self.op(L, self.tree[l])
                l += 1
            if r & 1 == 0:
                r -= 1
                R = self.op(R, self.tree[r])
            l -= 1
            l >>= 1
            r >>= 1
        return self.op(L, R)
n, k = map(int, input().split())
ST = SegmentTree([0] * 200000, 0, max)
for i in range(n):
    a = int(input())
    res = ST.query(max(0, a - k), min(200000, a + k + 1))
    ST.update(a, res + 1)
print(ST.tree[1])

### FIXED CODE ###

class SegmentTree:
    def __init__(self, lis, ele, op):
        self.len = len(lis)
        self.n = 1 << ((self.len - 1).bit_length())
        self.op = op
        self.ele = ele
        self.tree = self._build(lis)
    def _build(self, lis):
        res_tree = [self.ele] * (self.n - 1) + lis + [self.ele] * (self.n - self.len)
        for i in range(self.n - 2, -1, -1):
            res_tree[i] = self.op(res_tree[i * 2 + 1], res_tree[i * 2 + 2])
        return res_tree
    def __get__(self, i):
        return self.tree[self.n + i - 1]
    def update(self, i, x):
        i += self.n - 1
        self.tree[i] = x
        while i > 0:
            i -= 1
            i >>= 1
            self.tree[i] = self.op(self.tree[i * 2 + 1], self.tree[i * 2 + 2])
    def query(self, l, r):
        l +=  self.n - 1
        r += self.n - 1
        L = self.ele
        R = self.ele
        while l < r:
            if l & 1 == 0:
                L = self.op(L, self.tree[l])
                l += 1
            if r & 1 == 0:
                r -= 1
                R = self.op(R, self.tree[r])
            l -= 1
            l >>= 1
            r >>= 1
        return self.op(L, R)
n, k = map(int, input().split())
ST = SegmentTree([0] * 600000, 0, max)
for i in range(n):
    a = int(input())
    res = ST.query(max(0, a - k), min(600000, a + k + 1))
    ST.update(a, res + 1)
print(ST.tree[1])
def main():
    import sys
    from collections import defaultdict
    sys.setrecursionlimit(10**5+2)
    
    N,M=list(map(int,sys.stdin.readline().split()))
    dic=defaultdict(list)
    for i in range(M):
        A,B=list(map(int,sys.stdin.readline().split()))
        dic[A].append(B)
        dic[B].append(A)

    L=[-1]*(N+1)
    R=[-1]*(N+1)

    def dfs(now,count):
        for goto in dic[now]:
            if L[goto]==-1 or count<L[goto]:
                L[goto]=count
                R[goto]=now
                dfs(goto,count+1)

    dfs(1,1)
    if any(x+1 for x in R[2:]):
        print('Yes')
        for x in R[2:]:
            print(x)
    else:
        print('No')
    


main()

### FIXED CODE ###

def main():
    import sys
    from collections import defaultdict,deque
    sys.setrecursionlimit(10**5+2)

    N,M=list(map(int,sys.stdin.readline().split()))
    dic=defaultdict(list)
    for i in range(M):
        A,B=list(map(int,sys.stdin.readline().split()))
        dic[A].append(B)
        dic[B].append(A)
    
    L=[-1]*(N+1)
    R=[-1]*(N+1)


    d = deque()
    d.append((1,1))
    while len(d):
        now,count=d.popleft()
        for goto in dic[now]:
            if L[goto]==-1 or count<L[goto]:
                L[goto]=count
                R[goto]=now
                d.append((goto,count+1))

    if any(x+1 for x in R[2:]):
        print('Yes')
        for x in R[2:]:
            print(x)
    else:
        print('No')
    


main()
s = int(input())
k=[s]
i = 1
while 1:
	if k[-1]%2 == 0:
  		x = int(k[-1]/2)
	else:
  		x = 3*k[-1]+1
    if x in k:
      print(i+1)
      break
    else:
      k.append(x)
      i+=1

### FIXED CODE ###

s = int(input())
ans_list = [s]
i = 1
while 1:
    if ans_list[-1]%2 == 0:
        a = int(ans_list[-1]/2)
    else:
        a = 3 * ans_list[-1] + 1
    if a in ans_list:
        print(i+1)
        break
    else:
        ans_list.append(a)
        i += 1
import sys
 
def main():
  N = int(input())
  L = [0,1,6,8]
  n_last = int(N[-1])
  if n_last == 3:
    print("bon")
  elif (n_last in L):
    print("pon")
  else:
    print("hon")
 
    
main()

### FIXED CODE ###

import sys
 
def main():
  N = str(input())
  L = [0,1,6,8]
  n_last = int(N[-1])
  if n_last == 3:
    print("bon")
  elif (n_last in L):
    print("pon")
  else:
    print("hon")
 
    
main()
# -*- coding: utf-8 -*-
"""
Challenge A
"""

def bus(stations):
    a = np.array(("","",""))
    for i in range(3):
        a[i] = stations[i]
    s = np.unique(a)
    if len(s)==1:
        return "No"
    elif len(s) > 1:
        return "Yes"
    else:
        return "Problem"
        
my_strings = np.array(("AAA","AAB","ABA","BAA","ABB","BBA","BBB"))
for i in my_strings:
    print(i)
    print(bus(i))


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Challenge A
"""
import numpy as np

def bus(stations):
    a = np.array(("","",""))
    for i in range(3):
        a[i] = stations[i]
    s = np.unique(a)
    if len(s)==1:
        return "No"
    elif len(s) > 1:
        return "Yes"
    else:
        return "Problem"
        
"""
my_strings = np.array(("AAA","AAB","ABA","BAA","ABB","BBA","BBB"))
for i in my_strings:
    print(i)
    print(bus(i))
"""
    
i = input()
#print(i)
print(bus(i))
s = str(input())

num_moto = int(len(s))

for ctr in range(500)
    if int(len(s)) == 0:
        break
    s = s.replace('10','')
    s = s.replace('01','')
    
num_kekka = int(len(s))
print(num_moto - num_kekka)

### FIXED CODE ###

s = input()
count_0 = s.count('0')
count_1 = s.count('1')
print(2*min(count_0,count_1))
ar=[int(x) for x in input().split()]
for i in range(n):
  if(ar[i]==0):
    print((i+1))
    break

### FIXED CODE ###

ar=[int(x) for x in input().split()]
for i in range(len(ar)):
    if(ar[i]==0):
        print(i+1)
        break
A, B, N = map(int, input().split())

if B-1>N:
    answer = (A*N/B)//1 - A*((N/B)//1)

if A > B:
    answer = (A*(B-1)/B)//1 - A*(((B-1)/B)//1)

print(int(answer))


### FIXED CODE ###

A, B, N = map(int, input().split())

if B-1>N:
    answer = (A*N/B)//1 - A*((N/B)//1)

else:
    answer = (A*(B-1)/B)//1 - A*(((B-1)/B)//1)

print(int(answer))
x,y=int(input()),int(input())
if y<x:
  x-=1
print(x)

### FIXED CODE ###

x,y=map(int,input().split())
if y<x:
  x-=1
print(x)
k =int(input())
a, b = map(int, input().split())

for i in range(a, b):
    if(i % k == 0):
        break
    
if(i % k == 0):
    print('OK')
else:
    print('NG')

### FIXED CODE ###

k =int(input())
a, b = map(int, input().split())
 
for i in range(a, b+1):
    if (i % k == 0):
        print("OK")
        break
else:
    print("NG")
W = raw_input().lower()
c = 0

while True:
    T = raw_input().lower()
    if T == "END_OF_TEXT":
        break
    Ti = T.split()
    for i in Ti:
        if i == W:
            c += 1

print("%d" % (c, ))

### FIXED CODE ###

W = raw_input().lower()
c = 0

while True:
    T = raw_input()
    if T == "END_OF_TEXT":
        break
    Ti = T.lower().split()
    for i in Ti:
        if i == W:
            c += 1

print("%d" % (c, ))
judge = False
target = [-1 for i in range(N)]
for i in range(M):
    if sc[i][1] + target[sc[i][0]-1] == sc[i][1]-1 or sc[i][1] + target[sc[i][0]-1] == 2*sc[i][1]:
        target[sc[i][0]-1] = sc[i][1]
    else:
        print(-1)
        judge = True
        break

if judge is False:
    for i in range(N):
        if len(target) == 1:
            if target[0] == -1:
                target[0] = 0
        else:
            if i == 0 and target[i] == -1:
                target[i] = 1
            elif target[i] == -1:
                target[i] = 0

    res = 0
    for i in range(N):
        res = res+target[i]*(10**(N-i-1))
    if len(str(res)) != N:
        print(-1)
    else:
        print(res)

### FIXED CODE ###

N,M = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(M)]

s = [sc[i][0] for i in range(len(sc))]
c = [sc[i][1] for i in range(len(sc))]

judge=False
for i in range(len(s)):
    for j in range(len(s)):
        if s[i]==s[j] and c[i] != c[j]:
            print(-1)
            judge=True
            break
        break




target = [0 for i in range(N)]

if N != 1 and target[0]==0:
    target[0]=1

for i in range(M):
    target[sc[i][0]-1] = sc[i][1]

if judge==False:
    res=0
    for i in range(N):
        res = res + target[i]*(10**(N-i-1))
    if len(str(res)) != N:
        print(-1)
    else:
        print(res)
print(int(input())***3)

### FIXED CODE ###

print(int(input())**3)
s=int(input())
two=[]
for i in range(7):
    two.append(2**i)
ans=0
if s in two:
    print(s)
else:
    while s>two[ans]:
        ans+=1
    print(2**(ans-1))

### FIXED CODE ###

s=int(input())
two=[]
for i in range(8):
    two.append(2**i)
ans=0
if s in two:
    print(s)
else:
    while s>two[ans]:
        ans+=1
    print(2**(ans-1))
import math
import numpy
a,b,c = map(int, input().split())
d = c - a - b
if d > 0 and d * D > 4 * a * b:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

import math
import numpy
a,b,c = map(int, input().split())
d = c - a - b
if d > 0 and d * d > 4 * a * b:
    print("Yes")
else:
    print("No")
import bisect
N = int(input())
*A, = map(int,input().split())
B = {}
for a in A:B[a] = B.get(a,0) + 1
B = sorted(map(list,B.items()))
bl = bisect.bisect_left

ans = 0
while 1:
    b,n = B.pop()
    if not B : break
    c = (1<<(len(bin(b))-2)) - b
    i = bl(B,[c,0])
    if B[i][0] == c:
        m = min(n,B[i][1])
        ans += m
        B[i][1] -= m
print(ans)

### FIXED CODE ###

import bisect
N = int(input())
*A, = map(int,input().split())
B = {}
for a in A:B[a] = B.get(a,0) + 1
B = sorted(map(list,B.items()))
bl = bisect.bisect_left

ans = 0
while B:
    b,n = B.pop()
    c = (1<<(len(bin(b))-2)) - b
    if c==b :
        ans += n//2
        continue
    i = bl(B,[c,0])
    if i>=len(B): continue
    if B[i][0] == c:
        m = min(n,B[i][1])
        ans += m
        B[i][1] -= m
print(ans)
str = list(map(int, input().split()))
a = str[0]
b = str[1]
i = 1
if a < b:
  big = b
  small = a
else:
  big = a
  small = b

while i != 0:
  i = big % small
  big = small
  small = i

print (int(a*b/big))

### FIXED CODE ###

a = int(input())
b = int(input())

print (6-a-b)
N=int(input())
H=list(map(int,input().split()))
dp=[0]*N
def cost(n):
    if dp[n-1]:
        return dp[n-1]
    elif n==1:
        return 0
    elif n==2:
        return abs(H[1]-H[0])
    else:
        ans=min(cost(n-2)+abs(H[n-1]-H[n-3]),cost(n-1)+abs(H[n-1]-H[n-2]))
        dp[n-1]=ans
        return ans

print(cost(N))

### FIXED CODE ###

N=int(input())
H=list(map(int,input().split()))
dp=[0]*N
dp[0]=0
dp[1]=abs(H[1]-H[0])

for i in range(2,N):
    dp[i]=min(dp[i-2]+abs(H[i]-H[i-2]),dp[i-1]+abs(H[i]-H[i-1]))

print(dp[N-1])
nums = [int(num) for num in input()]

target = 7

if sum(nums) == target:
    symbols = '+++'
elif nums[0] + nums[1] + nums[2] - nums[3] == target:
    symbols = '++-'
elif nums[0] + nums[1] - nums[2] + nums[3] == target:
    symbols = '+-+'
elif nums[0] + nums[1] - nums[2] - nums[3] == target:
    symbols = '+--'
elif nums[0] - nums[1] + nums[2] + nums[3] == target:
    symbols = '-++'
elif nums[0] - nums[1] + nums[2] - nums[3] == target:
    symbols = '-+-'
elif nums[0] - nums[1] - nums[2] + nums[3] == target:
    symbols = '--+'
elif nums[0] - nums[1] - nums[2] - nums[3] == target:
    symbols = '---'

print(f'{nums[0]}{symbols[0]}{nums[1]}{symbols[1]}{nums[2]}{symbols[2]}{nums[3]}=7')

### FIXED CODE ###

nums = [int(num) for num in input()]

target = 7

if sum(nums) == target:
    symbols = '+++'
elif nums[0] + nums[1] + nums[2] - nums[3] == target:
    symbols = '++-'
elif nums[0] + nums[1] - nums[2] + nums[3] == target:
    symbols = '+-+'
elif nums[0] + nums[1] - nums[2] - nums[3] == target:
    symbols = '+--'
elif nums[0] - nums[1] + nums[2] + nums[3] == target:
    symbols = '-++'
elif nums[0] - nums[1] + nums[2] - nums[3] == target:
    symbols = '-+-'
elif nums[0] - nums[1] - nums[2] + nums[3] == target:
    symbols = '--+'
elif nums[0] - nums[1] - nums[2] - nums[3] == target:
    symbols = '---'

result = ''
for i in range(len(symbols)):
    result += str(nums[i])
    result += symbols[i]
result += str(nums[-1])

print('{}=7'.format(result))
a,b,c = input.split()

if a[-1] == b[0] and b[-1] == c[0]:
  print('YES')
else:
  print('NO')

### FIXED CODE ###

a,b,c = input().split()

if a[-1] == b[0] and b[-1] == c[0]:
  print('YES')
else:
  print('NO')
import sys
from collections import deque
sys.setrecursionlimit(10 ** 5)
input = sys.stdin.readline


def main():
    N, Q = map(int, input().split())
    ans = [[0, deque()] for _ in range(N)]

    for _ in range(N - 1):
        p, c = map(int, input().split())
        ans[p-1][1].append(c-1)
        ans[c-1][1].append(p-1)

    for _ in range(Q):
        p, v = map(int, input().split())
        ans[p-1][0] += v

    def add_value(node, parent):
        val = ans[node][0]
        children = ans[node][1]
        for child in children:
            if child == parent:
                continue
            ans[child][0] += val
            add_value(child, node)

    add_value(0, -1)

    print(' '.join([str(x[0]) for x in ans]))


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import deque

N, Q = map(int, input().split())
edge = [[] for i in range(N)]
ops = []
ans = [0] * N

for _ in range(N - 1):
    a, b = map(int, input().split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
for _ in range(Q):
    ops.append(tuple(map(int, input().split())))

for op in ops:
    node = op[0] - 1
    pnt = op[1]
    ans[node] += pnt

stack = deque()
stack.append((0, -1))

while stack:
    st = stack.pop()
    node, parent = st[0], st[1]
    children = edge[node]
    for child in children:
        if child == parent:
            continue
        ans[child] += ans[node]
        stack.append((child, node))

print(*ans)
import sys
lines = sys.stdin.readlines()

S = str(lines[0])
X = []
A =[]
p =1
for i in range(len(S)):
  A.append(p)
  p = p*10%2019

a = 0
for i in range(len(S)):
  a = (a + int(S[len(S)-i-1])*A[i]) %2019
  X.append(a)

X.sort()
flag =1
n = 0
for i in range(len(X)-1):
  if X[i]==0:
    n +=1
  if X[i]==X[i+1]:
    flag += 1
  else:
    n += flag*(flag-1)//2
    flag = 1
 
print(n)
    



### FIXED CODE ###

S = str(input())

#10**nのmod計算
A = []
p =1
for i in range(len(S)):
  A.append(p)
  p = p*10%2019

#左からi文字以降の数字列のmod計算
X = []
a = 0
for i in range(len(S)):
  a = (a + int(S[len(S)-i-1])*A[i]) %2019
  X.append(a)
X.sort()
flag =1
n = 0

#modが同じになる組み合わせ、またはもともとmodが0になる数字列の個数の総和計算
for i in range(len(X)-1):
  if X[i]==0:
    n +=1
  if X[i]==X[i+1]:
    flag += 1
  else:
    n += int(flag*(flag-1)/2)
    flag = 1
n += int(flag*(flag-1)/2)
if X[len(X)-1]==0:
  n +=1
print(n)
a,b,c=map(int,input())
if a+b+c<=21:
  print('win')
else:
  print('bust')

### FIXED CODE ###

a,b,c=map(int,input().split())
if a+b+c<=21:
  print('win')
else:
  print('bust')
# TLEするので、自前で用意せずに、ライブラリ使おう
# https://juppy.hatenablog.com/entry/2019/02/24/ABC119_-D_Lazy_Faith-_Python_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0_Atcoder

import bisect
A, B, Q = map(int, input().split())
S = sorted([int(input()) for i in range(A)])
T = sorted([int(input()) for i in range(B)])
X = [int(input()) for i in range(Q)]

s_size = A
t_size = B
inf = 99999999999999

for x in X:
  s_index = bisect.bisect_left(S, x)
  s_left = S[s_index - 1] if s_index > 0 else None
  s_right = S[s_index] if s_index < s_size else None
  t_index = bisect.bisect_left(T, x)
  t_left = T[t_index - 1] if t_index > 0 else None
  t_right = T[t_index] if t_index < t_size else None

  ans = inf

  sl = [s_left, s_right]
  tl = [t_left, t_right]

  for s in sl:
    if not s: continue
    c1 = abs(x - s)
    for t in tl:
      if not t: continue
      ans = min(ans, c1 + abs(s-t))


  for t in tl:
    if not t: continue
    c1 = abs(x - t)
    for s in sl:
      if not s: continue
      ans = min(ans, c1 + abs(s-t))

  print(ans)




### FIXED CODE ###

import datetime

s = input()
base = datetime.datetime.strptime("2019/4/30", '%Y/%m/%d')
dt = datetime.datetime.strptime(s, '%Y/%m/%d')
print("Heisei" if base >= dt else "TBD")
a = input()

print(a+pow(a,2)+pow(a,3))


### FIXED CODE ###


a = int(input())

print(a+pow(a,2)+pow(a,3))
a=list(input())
b=[a,b,c]
if sort(a)==b:
  print('Yes')
else:
  print('No')


### FIXED CODE ###

a=input()
if len(set(a))==3:
  print('Yes')
else:
  print('No')
import sys 
c11, c12, c13 = map(int, input().split())
c21, c22, c23 = map(int, input().split())
c31, c32, c33 = map(int, input().split())

N = 101

for i in range(N):
    a1 = i

    b1 = c11 - a1
    b2 = c12 - a1
    b3 = c13 - a1

    a2 = c21 - b1
    a3 = c31 - b1

    if c22 == a2+b2 and c23 == a2 + b3 and c33 == a3+b3:
        print("Yes")
        sys.exit()

print("No")

### FIXED CODE ###

N = int(input())
A = int(input())

#枚数
number=(N//500)

#端数を弾く
Rest = (N-(number*500))

if Rest <= A:
    print("Yes")
else:
    print("No")
N = int(input())
 
ans = ":("
 
for X in range(N-1):
  if int(X * 1.08) = N:
    ans = X
    break
    
print(ans)

### FIXED CODE ###

N = int(input())
 
ans = ":("
 
for X in range(N+1):
  if int(X * 1.08) == N:
    ans = X
    break
    
print(ans)
print(sorted(input().split())).join(' ')

### FIXED CODE ###

print(' '.join(sorted(input().split())))
equa = input().split()
if equa[1] == "+":
    print(int(equa[0]) + int(equa[1]))
else:
    print(int(equa[0]) - int(equa[1]))


### FIXED CODE ###

equa = input().split()
if equa[1] == "+":
    print(int(equa[0]) + int(equa[2]))
else:
    print(int(equa[0]) - int(equa[2]))