Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

s = [0] * m
c = [0] * m

for i in range(m):
    s[i], c[i] = map(int, input().split())

ans = False
for x in range(10 ** (n - 1), 10 ** n):
    x = list(str(x))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        break

if n == 1:
    x = list(str(0))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        break
    
if ans == False:
    print(-1)


Fixed submission:
n, m = map(int, input().split())

s = [0] * m
c = [0] * m

for i in range(m):
    s[i], c[i] = map(int, input().split())

ans = False

if n == 1:
    x = list(str(0))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        
for x in range(10 ** (n - 1), 10 ** n):
    x = list(str(x))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag and ans == False:
        print(int(''.join(x)))
        ans = True
        break


    
if ans == False:
    print(-1)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

s = [0] * m
c = [0] * m

for i in range(m):
    s[i], c[i] = map(int, input().split())

ans = False
for x in range(10 ** (n - 1), 10 ** n):
    x = list(str(x))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        break

if n == 1:
    x = list(str(0))
        flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        break
    
if ans == False:
    print(-1)


Fixed submission:
n, m = map(int, input().split())

s = [0] * m
c = [0] * m

for i in range(m):
    s[i], c[i] = map(int, input().split())

ans = False

if n == 1:
    x = list(str(0))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        
for x in range(10 ** (n - 1), 10 ** n):
    x = list(str(x))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag and ans == False:
        print(int(''.join(x)))
        ans = True
        break


    
if ans == False:
    print(-1)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

s = [0] * m
c = [0] * m

for i in range(m):
    s[i], c[i] = map(int, input().split())

ans = False
for x in range(10 ** (n - 1), 10 ** n):
    x = list(str(x))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        break

if n = 1:
    x = list(str(0))
        flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        break
    
if ans == False:
    print(-1)


Fixed submission:
n, m = map(int, input().split())

s = [0] * m
c = [0] * m

for i in range(m):
    s[i], c[i] = map(int, input().split())

ans = False

if n == 1:
    x = list(str(0))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag:
        print(int(''.join(x)))
        ans = True
        
for x in range(10 ** (n - 1), 10 ** n):
    x = list(str(x))
    flag = True
    for i in range(m):
        if int(x[s[i]-1]) == c[i]:
            pass
        else:
            flag = False

    if flag and ans == False:
        print(int(''.join(x)))
        ans = True
        break


    
if ans == False:
    print(-1)