Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
digit = [0]*(m)
value = [0]*(m)
for i in range(m):
    digit[i],value[i] = map(int,input().split())

#全探索
ans = 0
for i in range(keta, 10**3):
    s = str(i)
    if len(s)!=n: continue
    for j in range(m): 
        if int(s[digit[j]-1]) != value[j]:
            break
    else:
        print(i)
        exit()
print('-1')

Fixed submission:
n,m = map(int,input().split())
digit = [0]*(m)
value = [0]*(m)
for i in range(m):
    digit[i],value[i] = map(int,input().split())

#全探索
ans = 0
for i in range(10**3):
    s = str(i)
    if len(s)!=n: continue
    for j in range(m): 
        if int(s[digit[j]-1]) != value[j]:
            break
    else:
        print(i)
        exit()
print('-1')

Buggy python submission (verdict: Runtime Error):
#全探索
ans = 0
keta = 10**(n-1)
for i in range(keta, 10**5):
    s = str(i)
    flag = True
    for j in range(m): 
        if int(s[digit[j]-1]) != value[j]: #違ったらFalse
            flag = False
    if flag:
        ans = i
        break
print(ans if flag else '-1')

Fixed submission:
n,m = map(int,input().split())
digit = [0]*(m)
value = [0]*(m)
for i in range(m):
    digit[i],value[i] = map(int,input().split())

#全探索
ans = 0
for i in range(10**3):
    s = str(i)
    if len(s)!=n: continue
    for j in range(m): 
        if int(s[digit[j]-1]) != value[j]:
            break
    else:
        print(i)
        exit()
print('-1')

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
digit = [0]*(m+1)
value = [0]*(m+1)
for i in range(1,m+1):
    digit[i],value[i] = map(int,input().split())

if m==0:
    print('-1')
    exit()
res = 0
for i in range(1,n+1):
    if i in digit:
        idx = digit.index(i)
        res += value[idx] * 10**(n-i)

for i in range(1,m+1):
    if int(str(res)[digit[i]-1]) != value[i]:
        print('-1')
        exit()
print(res if len(str(res))==n else '-1')

Fixed submission:
n,m = map(int,input().split())
digit = [0]*(m)
value = [0]*(m)
for i in range(m):
    digit[i],value[i] = map(int,input().split())

#全探索
ans = 0
for i in range(10**3):
    s = str(i)
    if len(s)!=n: continue
    for j in range(m): 
        if int(s[digit[j]-1]) != value[j]:
            break
    else:
        print(i)
        exit()
print('-1')

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
digit = [0]*(m+1)
value = [0]*(m+1)
for i in range(1,m+1):
    digit[i],value[i] = map(int,input().split())
res = 0
for i in range(1,n+1):
    if i in digit:
        idx = digit.index(i)
        res += value[idx] * 10**(n-i)
for i in range(1,m+1):
    if int(str(res)[digit[i]-1]) != value[i]:
        print('-1')
        exit()
print(res if len(str(res))==n else '-1')

Fixed submission:
n,m = map(int,input().split())
digit = [0]*(m)
value = [0]*(m)
for i in range(m):
    digit[i],value[i] = map(int,input().split())

#全探索
ans = 0
for i in range(10**3):
    s = str(i)
    if len(s)!=n: continue
    for j in range(m): 
        if int(s[digit[j]-1]) != value[j]:
            break
    else:
        print(i)
        exit()
print('-1')

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
digit = [0]*(m+1)
value = [0]*(m+1)
for i in range(1,m+1):
    digit[i],value[i] = map(int,input().split())
res = 0
for i in range(1,n+1):
    if i in digit:
        idx = digit.index(i)
        res += value[idx] * 10**(n-i)
for i in range(1,m+1):
    if int(str(res)[digit[i]-1]) != value[i]:
        print('No')
        exit()
print('Yes' if len(str(res))==n else 'No')

Fixed submission:
n,m = map(int,input().split())
digit = [0]*(m)
value = [0]*(m)
for i in range(m):
    digit[i],value[i] = map(int,input().split())

#全探索
ans = 0
for i in range(10**3):
    s = str(i)
    if len(s)!=n: continue
    for j in range(m): 
        if int(s[digit[j]-1]) != value[j]:
            break
    else:
        print(i)
        exit()
print('-1')

Buggy python submission (verdict: Runtime Error):
a = [list(map(int, input().split())) for i in range(3)]
aa = list(zip(*a))
n = int(input())
b = [int(input()) for _ in range(n)]
if a[0] in b or a[1] in b or a[2] in b or aa[0] in b or aa[1] in b or aa[2] in b or (a[0][0] in b and a[1][1] in b and a[2][2] in b) or (a[0][2] in b and a[1][1] in b and a[2][0] in b):
    print('Yes')
else:
    print('No')

Fixed submission:
n,m = map(int,input().split())
digit = [0]*(m)
value = [0]*(m)
for i in range(m):
    digit[i],value[i] = map(int,input().split())

#全探索
ans = 0
for i in range(10**3):
    s = str(i)
    if len(s)!=n: continue
    for j in range(m): 
        if int(s[digit[j]-1]) != value[j]:
            break
    else:
        print(i)
        exit()
print('-1')