Harryxun/stf_run huggingface dataset:
s=input()
t=input()
# 
#print("#")

# minimize
mnmz={ch for ch in s} & {ch for ch in t}
if len(mnmz)==0:
    print("")
    exit()
s="".join([ z for z in s if z in mnmz])
t="".join([ z for z in t if z in mnmz])
if len(s)>len(t): s, t = t, s
#print(s)
#print(t)
# init
dp=[0]*len(s)
res={}
#dp
for i in range(len(t)):
    #print(dp)
    prev=dp[0]
    if dp[0]==0 and t[i]==s[0]:
        dp[0]=1
        res[1]=[s[0]]
    for j in range(1, len(s)):
        temp = max(dp[j-1], dp[j])
        if s[j]==t[i]:
            if temp<prev+1:
                temp=prev+1
                res[temp]=res[prev]+[s[j]]
        prev, dp[j] = dp[j], temp
    if dp[len(s)]==len(s): break

#print(dp)

print("".join(res[dp[len(s)-1]]))



### FIXED CODE ###

s=[ord(ch)-97 for ch in input()]
t=[ord(ch)-97 for ch in input()]

# minimize
mnmz={ch for ch in s} & {ch for ch in t}
if len(mnmz)==0:
    print("")
    exit()
s=[ z for z in s if z in mnmz ]
t=[ z for z in t if z in mnmz ]
if len(s)>len(t): s, t = t, s

# init
dp=[[0]*len(s) for _ in range(len(t))]

#dp frame init
for i in range(len(s)): 
    if s[i]==t[0]:
        for j in range(i, len(s)):
            dp[0][j]=1
        break
for i in range(len(t)): 
    if s[0]==t[i]:
        for j in range(i, len(t)):
            dp[j][0]=1
        break
#dp
for i in range(1,len(t)):
    for j in range(1, len(s)):
        if s[j]==t[i]:
            dp[i][j]=dp[i-1][j-1]+1
        else: dp[i][j]=(dp[i][j-1] if dp[i][j-1]>dp[i-1][j] else dp[i-1][j])

#recover string
res=[]
j=len(s)-1
i=len(t)-1
while i>=0 and j>=0:
    if s[j]==t[i]: #and dp[i][j]==dp[i-1][j-1]+1:
        res.append(s[j])
        i=i-1
        j=j-1
        continue
    if i==0 and j==0: break
    if j>0 and dp[i][j]==dp[i][j-1]:
        j=j-1
    else: i=i-1
# last letter (first acually)


print("".join(chr(i+97) for i in reversed(res)))
N = int(input())
D = [int(i) for i in input().split()]
Dlist = [0]*1000000
for d in D:
    Dlist[d-1] += 1


M = int(input())
T = [int(i) for i in input().split()]
    
Tlist = [0]*1000000
for t in T:
    Tlist[t-1] += 1
 
flag = True
 
for i in range(len(Tlist)):
    if Tlist[i] > Dlist[i]:
        flag = False
        break
 
 
if flag:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

from collections import Counter
N = int(input())
D = [int(i) for i in input().split()]
M = int(input())
T = [int(i) for i in input().split()]

cD = Counter(D)

for t in T:
    if cD.get(t,0) == 0:
        print('NO')
        exit()
    else:
        cD[t] -= 1

print("YES")
N=int(input())

if N%7==0 or N%4==0 or N%7==4 or N%4==7 N%11==0 or N%11==4 or N%11==7:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N=int(input())

N4=N
N7=N
while(N4>=0):
  if N4%7==0:
    print('Yes')
    exit()
  N4-=4
while(N7>=0):
  if N7%4==0:
    print('Yes')
    exit()
  N7-=7
print('No')
input()
nums = map(int, input().split())
count = 0
flg = True
while flg:
  for i, n in enumerate(nums):
    if n % 2 == 1:
      flg = False
      break
    else:
      nums[i] = n / 2
      count += 1
print(count)
      

### FIXED CODE ###

kazu = int(input())
nums = list(map(int, input().split()))
count = 0
flg = True
while flg:
  for i in range(kazu):
    if nums[i] % 2 == 1:
      flg = False
      break
    else:
      nums[i] /= 2
  count += 1
count -= 1
print(count)
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0

    A.sort(reverse=True)
    A = tuple(A)

    for i in range(N-1):
        flg = True
        for j in range(i+1, N):
            if A[i] % A[j] == 0:
                flg = False
                break
        if flg == True:
            ans += 1

    if A[N-1] != A[N-2]:
        ans += 1

    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

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

for i in range(5):
    if X[i] == 0:
        ans = i + 1
        print(ans)
# coding: utf-8
# Here your code !
import math

r = int(input())

print("{0:.8f} {1:.8f}".format((r ** 2) * math.pi,2 * math.pi * r))

### FIXED CODE ###

from math import pi

r = float(input())
print(r**2 * pi, 2 * r * pi)
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())))

def check(L):
    return sum(a // L for a in A) <= K

answer=max(A)
lo = 0
hi = answer+1
while lo < hi:
    m = (lo + hi)//2
    ok = check(m)
    if not ok: # 
        lo=m+1
    else:
        answer=m
        hi=m
print(min(max(A), answer))


"""
    while lo < hi:
        mid = (lo+hi)//2
        if a[mid] < x: lo = mid+1
        else: hi = mid
    return lo

    while lo < hi:
        mid = (lo+hi)//2
        if x < a[mid]: hi = mid
        else: lo = mid+1
    return lo
"""


### FIXED CODE ###

import math

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

def check(L):
    return sum(math.ceil(a / L)-1 for a in A) <= K

answer=max(A)
lo = 1
hi = answer+1
while lo < hi:
    m = (lo + hi)//2
    ok = check(m)
    if ok: 
        answer=min(m, answer)
        hi=m
    else:
        lo=m+1
print(answer)
n,q=map(int,input().split())
ki=[[] for i in range(n+1)]
ki[0]="null"
 
for i in range(n-1):
    a,b=map(int,input().split())
    ki[a].append(b)
 
scores=[0 for i in range(n+1)]
scores[0]="null"
for i in range(q):
    p,x=map(int,input().split())
    scores[p]+=x
 
 
ans=[0 for i in range(n+1)]
ans[0]="null"
point=0
 
 
def tansa(n,point):
    point+=scores[n]
    for p in ki[n]:
        try:
            tansa(p,point)
    else:
        ans[n]=point
        
tansa(1,0)
 
ans=ans[1:]
ans=[str(i) for i in ans]
print(" ".join(ans))

### FIXED CODE ###

n,q=map(int,input().split())
L=[[] for i in range(n+1)]
S=[0 for i in range(n+1)]
V=[0 for i in range(n+1)]

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

for _ in range(q):
    p,x=map(int,input().split())
    S[p]+=x


que=[1]
head=0
V[1]=1
while len(que)>head:
    now=que[head]
    head+=1
    for nex in L[now]:
        if V[nex]==0:
            V[nex]=1
            que.append(nex)
            S[nex]+=S[now]

print(" ".join([str(i) for i in S[1:]]))
a, b, c = map(str, raw_input().split(","))
a = int(a)
c = int(c)
if b == "+":
    print a + c
else:
    print a - c


### FIXED CODE ###

a, b, c = map(str, raw_input().split())
a = int(a)
c = int(c)
if b == "+":
    print a + c
else:
    print a - c
nkc=input().split()
K=int(nkc[1])
C=int(nkc[2])
s=input()
workday_list=[]
for i,youso in enumerate(s) :
  if youso=='o' :
    workday_list.append(i+1)
    

s=1

current_num=0
current_num1=1
list1=[]
list1.append(workday_list[0])
while(s<K) :
  
  if current_num1>=len(workday_list):
    break
  elif workday_list[current_num1]-workday_list[current_num]>C :
    current_num=current_num1
    list1.append(workday_list[current_num1])
    s+=1
  else :
    current_num1=current_num1+1
m=1  

current_num2=len(workday_list)-1
current_num3=len(workday_list)-2
list2=[]
list2.append(workday_list[-1])
while(m<K) :
  
  if current_num3<=0:
    break
  elif workday_list[current_num2]-workday_list[current_num3]>C :
    current_num2=current_num3
    list2.append(workday_list[current_num3])
    m+=1
  else :
    current_num3=current_num3-1

list2.reverse()
print(list1)
print(list2)
for i in range(len(list1)) :
  if list1[i]==list2[i] :
    print(list1[i])

### FIXED CODE ###

nkc=input().split()
K=int(nkc[1])
C=int(nkc[2])
s=input()
workday_list=[]
for i,youso in enumerate(s) :
  if youso=='o' :
    workday_list.append(i+1)
    

s=1

current_num=0
current_num1=1
list1=[]
list1.append(workday_list[0])
while(s<K) :
  
  if current_num1>=len(workday_list):
    break
  elif workday_list[current_num1]-workday_list[current_num]>C :
    current_num=current_num1
    list1.append(workday_list[current_num1])
    s+=1
  else :
    current_num1=current_num1+1
m=1  

current_num2=len(workday_list)-1
current_num3=len(workday_list)-2
list2=[]
list2.append(workday_list[-1])
while(m<K) :
  
  if current_num3<0:
    break
  elif workday_list[current_num2]-workday_list[current_num3]>C :
    current_num2=current_num3
    list2.append(workday_list[current_num3])
    m+=1
  else :
    current_num3=current_num3-1

list2.reverse()

flag=True
for i in range(len(list1)) :
  if list1[i]==list2[i] :
    flag=False
    print(list1[i])
if flag :
  print()
a,b,x = map(int,input().split())

ok = 0
ng = 10**9 + 1

def isok(arg):
    return a*arg+b*len(str(arg))

while abs(ng - ok) > 1 :
    mid = (ok+ng)//2
    if isok(mid) <= x:
        ok = mid
    else:
        ng = mid

print(mid)

### FIXED CODE ###

a = {'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1}
s = input()

ans = a.get(s)
print(ans)
def Fib(dan):
    
    if dan == 0:
        return 0
    elif dan == 1:
        return 1
    else:
        return Fib(dan-1)+Fib(dan-2)

N, M = map(int,input().split())
ans = 1
lasthole = 0
if M == 0:
    print(Fib(N+1))
else:
    alist = list()
    for i in range(M):
        alist.append( int(input()))
    for a in alist:
        dan = a - lasthole 
        lasthole = a +1
        ans *= Fib(dan)
    ans *= Fib(N - alist[M-1])
print(ans%1000000007)

### FIXED CODE ###

N, M = map(int,input().split())
alist = list()
for _ in range(M):
    alist.append(int(input()))


li = {}
li[0] = 1

for i in range(1,N+1):
    if len(alist)>=1 and i ==  alist[0]:
        li[i] = 0
        alist.pop(0)
    else:
        if i == 1:
            li[i] = 1
        else:
            li[i] = ((li[i-1] + li[i-2])%(10**9+7))
print(li[N]%(10**9+7))
a=int(input())
if a > 500:
    print((a//500)*1000+((a%500)//5)*5)
else:
    print(a//5*5)

### FIXED CODE ###

a=input()
if a[2] == a[3] and a[4] == a[5]:
    print("Yes")
else:
    print("No")
il = list(map(int,input().split()))

k = il[0]
x = il[1]

minusLimit = x - k + 1
plusLimit = x + k - 1

i = minusLimit

while minusLimit <= i <= pulusLimit :
  str = i + " "
str[:-1]
print(str)

### FIXED CODE ###

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

k = il[0]
x = il[1]

minusLimit = x - k + 1
plusLimit = x + k - 1

i = minusLimit

s = ""

while minusLimit <= i <= plusLimit :
  s =  s + str(i) + " "
  i = i + 1
s[:-1]
print(s)
s = set(map(int, input().split()))
print(len(set))

### FIXED CODE ###

s = set(map(int, input().split()))
n = len(list(s))
print(n)
input()
l = list(map(int,input().split()))
l.sort(reverse　=　True)
ans = 0
for i in range(len(l)):
  if i % == 0:
    ans += l[i]
  else:
    ans -= l[i]
print(ans)

### FIXED CODE ###

input()
l = list(map(int,input().split()))
list.sort(l,reverse=True)
ans = 0
for i in range(len(l)):
  if i % 2 == 0:
    ans += l[i]
  else:
    ans -= l[i]
print(ans)
a,b = map(str , input().split())
if a == "H":
    if b == "H":
        print("H")
    else:
        print("D")
elif b == "H":
        print("D")
    else:
        print("H")


### FIXED CODE ###

a,b = map(str , input().split())
if a == "H":
    if b == "H":
        print("H")
    else:
        print("D")
elif b == "H":
        print("D")
else:
        print("H")
for e in iter(input,'-1'):
 s,w,h=e.split(',')
 float(w)/float(h)**2<25 or print(s)


### FIXED CODE ###

import sys
for e in sys.stdin:
 s,w,h=e.split(',')
 float(w)/float(h)**2<25 or print(s)
import collections

N, M = map(int, input().split())
par = [i for i in range(N+1)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y

for i in range(M):
    X, Y, Z = map(int, input().split())
    unite(X, Y)
    print(par)

res = par[1:]
c = collections.Counter(res)
print(len(c))

### FIXED CODE ###

N, M = map(int,input().split())
par = [i for i in range(N+1)]
size = [1 for _ in range(N+1)]

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    par[x] = y
    size[y] = size[x] + size[y]
    size[x] = 0
    
for i in range(M):
    x, y,  z= map(int,input().split())
    unite(x,y)
    
Ans =0
for j in size[1:]:
    if j != 0:
        Ans +=1
print(Ans)
N, H, W = [int(x) for x in raw_input().split(' ')]
arr = []
for _ in xrange(N):
    r, c, a = [int(x) for x in raw_input().split(' ')]
    arr.append((a, r-1, c+H-1))
arr = sorted(arr)
ans = 0
P = [-1] * (H+W)
C = [1] * (H+W)

def find(a):
    if P[a] < 0:    return a
    t = find(P[a])
    P[a] = t
    return t

def unite(r, c):
    fr, fc = find(r), find(c)
    if fr == fc:  return 0
    C[fr] = C[fc] = C[fr] + C[fc]
    if P[fr] == P[fc]:
        P[fc] = fr
        P[fr] -= 1
    elif P[fr] > P[fc]:
        P[fc] = fr
    else:
        P[fr] = fc
    
while arr:
    a, r, c = arr.pop()
    unite(r, c)
    fr = find(r)
    if C[fr]:
        ans += a
        C[fr] -= 1
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def par(a):
    if P[a] < 0: return a
    t = par(P[a])
    P[a] = t
    return t
def unite(a, b):
    if par(a) == par(b): return 0
    C[par(a)], C[par(b)] = C[par(a)] + C[par(b)], C[par(a)] + C[par(b)]
    if P[par(b)] == P[par(a)]:
        P[par(b)] = par(a)
        P[par(a)] -= 1
    elif P[par(b)] > P[par(a)]:
        P[par(b)] = par(a)
    else:
        P[par(a)] = par(b)
N, H, W = map(int, input().split())
P = [-1 for i in range(H+W)]
C = [1] * (H+W)
X = []
for _ in range(N):
    r, c, a = map(int, input().split())
    X.append((a, r-1, c+H-1))
X = sorted(X)
ans = 0
while X:
    a, r, c = X.pop()
    unite(r, c)
    if C[par(r)]:
        ans += a
        C[par(r)] -= 1
print(ans)
while True:
    m, f, v = [int(n) for n in input().split()]

    if m == f == v == -1:
        break
    sum = m + f
    if m == -1 or f == -1
        print("F")
    elif 80 <= sum:
        print("A")
    elif 65 <= sum < 80:
        print("B")
    elif 50 <= sum < 65:
        print("C")
    elif 30 <= sum < 50:
        if 50 <= v:
            print("C")
        else:
            print("D")
    else:
        print("F")

### FIXED CODE ###

while True:
    m, f, v = [int(n) for n in input().split()]

    if m == f == v == -1:
        break
    sum = m + f
    if m == -1 or f == -1:
        print("F")
    elif 80 <= sum:
        print("A")
    elif 65 <= sum < 80:
        print("B")
    elif 50 <= sum < 65:
        print("C")
    elif 30 <= sum < 50:
        if 50 <= v:
            print("C")
        else:
            print("D")
    else:
        print("F")
n=int(input())
if n[0]==7 or n[1]==7 or n[2]==7:
  print ('Yes')
else:
  print ('No')


### FIXED CODE ###

n=input()
if '7' in n:
  print('Yes')
else:
  print('No')
a,b,c = map(int,input().split())
if a == 5 and b == 7 and c == 7) or (a == 7 and b == 5 and c == 7) or (a == 7 and b == 7 c == 5):
	print("YES")
else:
	print("NO")

### FIXED CODE ###

a = list(str(i) for i in input().split())
if a.count("5") == 2 and a.count("7") == 1:
	print("YES")
else:
	print("NO")
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    print((a+b)%24)
    return

#B
def B():
    n, m = LI()
    ab = LIR(n)
    cd = LIR(m)
    for a, b in ab:
        ans = inf
        an = 0
        for num, cdi in cd:
            c, d = cdi
            if ans > abs(a - c) + abs(b - d):
                an = num
        print(an) 
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    print((a+b)%24)
    return

#B
def B():
    n, m = LI()
    ab = LIR(n)
    cd = LIR(m)
    for a, b in ab:
        ans = inf
        an = 0
        for num, cdi in enumerate(cd):
            c, d = cdi
            if ans > abs(a - c) + abs(b - d):
                ans = abs(a - c) + abs(b - d)
                an = num
        print(an+1) 
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()
import numpy as np

h , w = map(int, input().split())
visited = np.zeros((h,w),dtype=int)

for y in range(h):
    _in = input()
    for x, value in enumerate(_in):
        if value == '.':
            visited[y][x] = 10**9
        else:
            visited[y][x] = 0
            
for i in range(1,h):
    visited[i,:] = np.minimum(visited[i,:],visited[i-1,:]+1)
for i in reversed(range(h-1)):
    visited[i,:] = np.minimum(visited[i,:],visited[i+1,:]+1)
for j in range(1,h):
    visited[:,j] = np.minimum(visited[:,j],visited[:,j-1]+1)
for j in reversed(range(h-1)):
    visited[:,j] = np.minimum(visited[:,j],visited[:,j+1]+1)
print(np.max(visited))

### FIXED CODE ###

import numpy as np

H,W = map(int,input().split())
use = np.zeros((H,W),dtype=int)
for i in range(H):
    s = input()
    for j,st in enumerate(s):
        if st == ".":
            use[i][j] = 10**10
        else:
            use[i][j] = 0

for i in range(1,H):
    use[i,:] = np.minimum(use[i,:],use[i-1,:]+1)
for i in reversed(range(H-1)):
    use[i,:] = np.minimum(use[i,:],use[i+1,:]+1)
for j in range(1,W):
    use[:,j] = np.minimum(use[:,j],use[:,j-1]+1)
for j in reversed(range(W-1)):
    use[:,j] = np.minimum(use[:,j],use[:,j+1]+1)

print(np.max(use))
test = {}

V = list(map(int,input().split()))
C = list(map(int,input().split()))

new_n = 0
for i in range(N):
    if V[i] <=  C[i]:
        continue
    else:
        test[i] = [V[i],C[i]]
        new_n += 1

N = new_n

def calc_cost(com,test,i):
    x = 0
    y = 0
    for j in com:
        x += test[j][0]
        y += test[j][1]
    return x - y

ans = 0




for i in range(N):
    c = itertools.combinations(test.keys(), i+1)
    for j in c:
        ans = max(ans,calc_cost(j,test,i))


print(ans)
        
    

### FIXED CODE ###

import itertools
N = int(input())

test = {}

V = list(map(int,input().split()))
C = list(map(int,input().split()))
new_n = 0
for i in range(N):
    if V[i] <=  C[i]:
        continue
    else:
        test[i] = [V[i],C[i]]
        new_n += 1

N = new_n

def calc_cost(com,test,i):
    x = 0
    y = 0
    for j in com:
        x += test[j][0]
        y += test[j][1]
    return x - y

ans = 0

for i in range(N):
    c = itertools.combinations(test.keys(), i+1)
    for j in c:
        ans = max(ans,calc_cost(j,test,i))


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

dp = [0]*(N+1)
if 1 in a: continue
else: dp[1]=1

for i in range(1,N):
  if i in a: continue
  dp[i+1] = dp[i]+dp[i-1]
  
print(dp[-1])

### FIXED CODE ###

N,M = map(int,input().split())
a = set([int(input()) for _ in range(M)])
mod = 10**9+7
dp=[0]*(N+1)
dp[0]=1


for i in range(N):
  if i+1 not in a:
    dp[i+1]+=dp[i]
    dp[i+1] %= mod
  if i+2 <= N and i+2 not in a:
    dp[i+2]+=dp[i]
    dp[i+2]%=mod
  
print(dp[-1])
n, a, b = map(int, input())
n = list(str(n))

count = 0
for j in range(n):
    l = [n[i] for i in range(len(j))]
    sum = sum(l)
    if a <= sum and sum <= b:
        count += 1
print(count)


### FIXED CODE ###

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

x = []
for j in range(1, m + 1):
    n = list(str(j))
    l = [int(n[i]) for i in range(len(n))]
    if len(l) == 1:
        l.append(0)
    s = sum(l)
    if a <= s and s <= b:
        x.append(j)
print(sum(x))
import sys
from scipy.sparse.csgraph import csgraph_from_dense
from scipy.sparse.csgraph import floyd_warshall
input = sys.stdin.readline


n, m, energy = map(int, input().split())
edges = [[float('INF')]*n for _ in range(n)]

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

G = csgraph_from_dense(edges, null_value=float('INF'))
dist = floyd_warshall(G)

L_edges = [[float('INF')]*n for _ in range(n)]
for i in range(n-1):
    for j in range(i, n):
        if dist[i][j] <= energy:
            L_edges[i][j] = 1
            L_edges[j][i] = 1

G = csgraph_from_dense(L_edges, null_value=0)
answers = floyd_warshall(G)

Q = int(input())
for i in range(Q):
    s, t = map(int, input().split())
    ans = answers[s-1][t-1] - 1
    print(int(ans))

### FIXED CODE ###

from scipy.sparse.csgraph import csgraph_from_dense
from scipy.sparse.csgraph import floyd_warshall

n, m, energy = map(int, input().split())
edges = [[float('INF')]*n for _ in range(n)]

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

G = csgraph_from_dense(edges, null_value=float('INF'))
dist = floyd_warshall(G)

L_edges = [[float('INF')]*n for _ in range(n)]
for i in range(n-1):
    for j in range(i, n):
        if dist[i][j] <= energy:
            L_edges[i][j] = 1
            L_edges[j][i] = 1

G = csgraph_from_dense(L_edges, null_value=float('INF'))
answers = floyd_warshall(G)

Q = int(input())
for i in range(Q):
    s, t = map(int, input().split())
    ans = answers[s-1][t-1] - 1
    if ans == float('INF'):
        ans = -1
    print(int(ans))
while True:
    a, op, b = raw_input().split()
    if op == "?":
        break
    else:
        if op == '+':
            print int(a) + int(b)
        elif op == '-':
            print int(a) - int(b)
        elif op == '*':
            print int(a) * int(b)
        elif op == '/':
            print int(a) / int(b)
        else:
            print "error"

### FIXED CODE ###

while True:
    a, op, b = input().split()
    if op == '?':
        break
    if op == '/':
        op = '//'
    print(eval(a + op + b))
N = int(input())
N_10 = N
S_N = 0
for i in range(10):
  rem = N%10
  S_N += rem
  N_10 //= 10
  if N_10 == 0:
    break
print("Yes" if N%S_N == 0 else "No")


### FIXED CODE ###

N = int(input())
N_10 = N
S_N = 0
for i in range(10):
  rem = N_10%10
  S_N += rem
  N_10 //= 10
  if N_10 == 0:
    break
if S_N == 0:
    answer = "No"
else:
    if N%S_N == 0:
        answer = "Yes"
    else:
        answer = "No"
print(answer)