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

for i in range (10**(n-1),10**n):
    p = str(i)
    flag = 0
    for j in range(m):
        if p[s[j]-1] != str(c[j]):
            flag = 1
            break

    if flag == 0:
        print(i)
        flag = 2
        break

if flag != 2:
    print("-1")

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

flag = 0

if m != 0:
    s, c = [list(i) for i in zip(*sc)]


    if n == 1:
        for i in range (0,10):
            p = str(i)
            flag = 0
            for j in range(m):
                if p[s[j]-1] != str(c[j]):
                    flag = 1
                    break

            if flag == 0:
                print(i)
                flag = 2
                break
    else:
        for i in range (10**(n-1),10**n):
            p = str(i)
            flag = 0
            for j in range(m):
                if p[s[j]-1] != str(c[j]):
                    flag = 1
                    break

            if flag == 0:
                print(i)
                flag = 2
                break

if flag != 2:
    if m == 0:
        if n == 1:
            print("0")
        elif n == 2:
            print("10")
        else:
            print("100")
    else:
        print("-1")

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

for i in range (10**(n-1),10**n):
    p = str(i)
    flag = 0
    for j in range(m):
        if p[s[j]-(4-n)] != str(c[j]):
            flag = 1
            break

    if flag == 0:
        print(i)
        flag = 2
        break

if flag != 2:
    print("-1")

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

flag = 0

if m != 0:
    s, c = [list(i) for i in zip(*sc)]


    if n == 1:
        for i in range (0,10):
            p = str(i)
            flag = 0
            for j in range(m):
                if p[s[j]-1] != str(c[j]):
                    flag = 1
                    break

            if flag == 0:
                print(i)
                flag = 2
                break
    else:
        for i in range (10**(n-1),10**n):
            p = str(i)
            flag = 0
            for j in range(m):
                if p[s[j]-1] != str(c[j]):
                    flag = 1
                    break

            if flag == 0:
                print(i)
                flag = 2
                break

if flag != 2:
    if m == 0:
        if n == 1:
            print("0")
        elif n == 2:
            print("10")
        else:
            print("100")
    else:
        print("-1")

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

for i in range (10**(n-1)+1,10**n):
    p = str(i)
    flag = 0
    for j in range(m):
        if p[s[j]-1] != str(c[j]):
            flag = 1
            break

    if flag == 0:
        print(i)
        flag = 2
        break

if flag != 2:
    print("-1")

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

flag = 0

if m != 0:
    s, c = [list(i) for i in zip(*sc)]


    if n == 1:
        for i in range (0,10):
            p = str(i)
            flag = 0
            for j in range(m):
                if p[s[j]-1] != str(c[j]):
                    flag = 1
                    break

            if flag == 0:
                print(i)
                flag = 2
                break
    else:
        for i in range (10**(n-1),10**n):
            p = str(i)
            flag = 0
            for j in range(m):
                if p[s[j]-1] != str(c[j]):
                    flag = 1
                    break

            if flag == 0:
                print(i)
                flag = 2
                break

if flag != 2:
    if m == 0:
        if n == 1:
            print("0")
        elif n == 2:
            print("10")
        else:
            print("100")
    else:
        print("-1")

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

ans = [10, 10, 10]
flag = 0
sum = 0

for i in range(m):
    if ans[s[i]-1] != c[i]:
        if ans[s[i]-1] == 10:
            ans[s[i]-1] = c[i]
        else:
            print("-1")
            flag = 1
            break

for i in range(3):
    if ans[i] == 10:
        ans[i] = 0


for i in range(n):
    sum += ans[-(i+1)] * (10 ** i)

if flag == 0:
    if n == 2 and ans[1] == 0:
        print("-1")
    elif n == 3 and ans[0] == 0:
        print("-1")
    else:
        print(sum)

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

flag = 0

if m != 0:
    s, c = [list(i) for i in zip(*sc)]


    if n == 1:
        for i in range (0,10):
            p = str(i)
            flag = 0
            for j in range(m):
                if p[s[j]-1] != str(c[j]):
                    flag = 1
                    break

            if flag == 0:
                print(i)
                flag = 2
                break
    else:
        for i in range (10**(n-1),10**n):
            p = str(i)
            flag = 0
            for j in range(m):
                if p[s[j]-1] != str(c[j]):
                    flag = 1
                    break

            if flag == 0:
                print(i)
                flag = 2
                break

if flag != 2:
    if m == 0:
        if n == 1:
            print("0")
        elif n == 2:
            print("10")
        else:
            print("100")
    else:
        print("-1")

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

ans = [10, 10, 10]
flag = 0
sum = 0

for i in range(m):
    if ans[s[i]-1] != c[i]:
        if ans[s[i]-1] == 10:
            ans[s[i]-1] = c[i]
        else:
            print("-1")
            flag = 1
            break

for i in range(3):
    if ans[i] == 10:
        ans[i] = 0


for i in range(n):
    sum += ans[-(i+1)] * (10 ** i)

if flag == 0:
    if n != 1 and ans[2] == 0:
        print("-1")
    else:
        print(sum)

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

flag = 0

if m != 0:
    s, c = [list(i) for i in zip(*sc)]


    if n == 1:
        for i in range (0,10):
            p = str(i)
            flag = 0
            for j in range(m):
                if p[s[j]-1] != str(c[j]):
                    flag = 1
                    break

            if flag == 0:
                print(i)
                flag = 2
                break
    else:
        for i in range (10**(n-1),10**n):
            p = str(i)
            flag = 0
            for j in range(m):
                if p[s[j]-1] != str(c[j]):
                    flag = 1
                    break

            if flag == 0:
                print(i)
                flag = 2
                break

if flag != 2:
    if m == 0:
        if n == 1:
            print("0")
        elif n == 2:
            print("10")
        else:
            print("100")
    else:
        print("-1")