Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
if m == 0:
    if n == 1:
        print(0)
    else:
        print('1' + '0' * (n - 1))
sc = [list(map(int, readline().split())) for i in range(m)]
sc.sort()
memo = sc[0]
if sc[0] == [1, 0] and n != 1:
    print(-1)
    exit()
for i in range(1, m):
    if memo[0] == sc[i][0]:
        if memo[1] != sc[i][1]:
            print(-1)
            exit()
    else:
        memo = sc[i]
ans = ''
for i in range(n):
    for j in range(m):
        if i + 1 == sc[j][0]:
            ans += str(sc[j][1])
            break
    if len(ans) != i + 1:
        if len(ans) == 0:
            ans += '1'
        else:
            ans += '0'
print(ans)


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
if m == 0:
    if n == 1:
        print(0)
    else:
        print('1' + '0' * (n - 1))
    exit()
sc = [list(map(int, readline().split())) for i in range(m)]
sc.sort()
memo = sc[0]
if sc[0] == [1, 0] and n != 1:
    print(-1)
    exit()
for i in range(1, m):
    if memo[0] == sc[i][0]:
        if memo[1] != sc[i][1]:
            print(-1)
            exit()
    else:
        memo = sc[i]
ans = ''
for i in range(n):
    for j in range(m):
        if i + 1 == sc[j][0]:
            ans += str(sc[j][1])
            break
    if len(ans) != i + 1:
        if len(ans) == 0:
            ans += '1'
        else:
            ans += '0'
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
sc = [list(map(int, readline().split())) for i in range(m)]
sc.sort()
memo = sc[0]
if sc[0] == [1, 0] and n != 1:
    print(-1)
    exit()
for i in range(1, m):
    if memo[0] == sc[i][0]:
        if memo[1] != sc[i][1]:
            print(-1)
            exit()
    else:
        memo = sc[i]
ans = ''
for i in range(n):
    for j in range(m):
        if i + 1 == sc[j][0]:
            ans += str(sc[j][1])
            break
    if len(ans) != i + 1:
        if len(ans) == 0:
            ans += '1'
        else:
            ans += '0'
print(ans)


Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, m = map(int, readline().split())
if m == 0:
    if n == 1:
        print(0)
    else:
        print('1' + '0' * (n - 1))
    exit()
sc = [list(map(int, readline().split())) for i in range(m)]
sc.sort()
memo = sc[0]
if sc[0] == [1, 0] and n != 1:
    print(-1)
    exit()
for i in range(1, m):
    if memo[0] == sc[i][0]:
        if memo[1] != sc[i][1]:
            print(-1)
            exit()
    else:
        memo = sc[i]
ans = ''
for i in range(n):
    for j in range(m):
        if i + 1 == sc[j][0]:
            ans += str(sc[j][1])
            break
    if len(ans) != i + 1:
        if len(ans) == 0:
            ans += '1'
        else:
            ans += '0'
print(ans)