Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

sc.sort(key=lambda x: x[0],reverse=True)
n = len(sc)
for i in range(1,1000):
    i = str(i)
    if len(i) < sc[0][0]:
        continue
    c = n
    for j in range(m):
        if i[sc[j][0]-1] == str(sc[j][1]):
            c -= 1
    if c == 0:
        print(i)
        quit()

print(-1)

Fixed submission:
n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

for i in range(10**n):
    i = str(i)
    flag = True
    if len(i) == n:
        for j in range(m):
            if i[sc[j][0]-1] != str(sc[j][1]):
                flag = False
        if flag:
            print(i)
            quit()

print(-1)

Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
s.sort(key=lambda x: x[0])
if m == 0:
    print(10**(n-1))
for i in range(1,1000):
    num = str(i)
    count = 0
    if s[-1][0] > len(num):
        continue
    for j in range(m):
        if num[s[j][0]-1] == str(s[j][1]):
            count += 1
        else:
            break
    if n == count:
        print(num)
        quit()
print(-1)

Fixed submission:
n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

for i in range(10**n):
    i = str(i)
    flag = True
    if len(i) == n:
        for j in range(m):
            if i[sc[j][0]-1] != str(sc[j][1]):
                flag = False
        if flag:
            print(i)
            quit()

print(-1)

Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
s.sort(key=lambda x: x[0])
for i in range(1,1000):
    num = str(i)
    count = 0
    if s[-1][0] > len(num):
        continue
    for j in range(m):
        if num[s[j][0]-1] == str(s[j][1]):
            count += 1
        else:
            break
    if n == count:
        print(num)
        quit()
print(-1)

Fixed submission:
n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

for i in range(10**n):
    i = str(i)
    flag = True
    if len(i) == n:
        for j in range(m):
            if i[sc[j][0]-1] != str(sc[j][1]):
                flag = False
        if flag:
            print(i)
            quit()

print(-1)

Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
s.sort(key=lambda x: x[0])
for i in range(1,1000):
    num = str(i)
    count = 0
    if s[-1][0] > len(num):
        continue
    for j in range(m):
        if num[s[j][0]-1] == str(s[j][1]):
            count += 1
        if n == count:
            print(num)
            quit()
print(-1)

Fixed submission:
n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

for i in range(10**n):
    i = str(i)
    flag = True
    if len(i) == n:
        for j in range(m):
            if i[sc[j][0]-1] != str(sc[j][1]):
                flag = False
        if flag:
            print(i)
            quit()

print(-1)

Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
s.sort(key=lambda x: x[0])
for i in range(1,1000):
    num = str(i)
    count = 0
    if s[-1][0] > len(num):
        continue
    for j in range(m):
        if num[s[j][0]-1] == str(s[j][1]):
            count += 1
        else:
            break
        if len(num) == count:
            print(num)
            quit()

print(-1)

Fixed submission:
n, m = map(int,input().split())
sc = [list(map(int,input().split())) for _ in range(m)]

for i in range(10**n):
    i = str(i)
    flag = True
    if len(i) == n:
        for j in range(m):
            if i[sc[j][0]-1] != str(sc[j][1]):
                flag = False
        if flag:
            print(i)
            quit()

print(-1)