Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
# S = [None] * m
# C = [None] * m
dic = {}
for i in range(m):
    s, c = map(int, input().split())
    try:
        _ = dic[s]
    except KeyError:
        dic[s] = c
    else:
        if (dic[s] != c):
            print(-1)
            exit()

ans = '0' * n
for k, v in dic.items():
    ans = ans[:k - 1] + str(v) + ans[k:]

try:
    digit1 = dic[1]
except KeyError:
    digit1 = 1

if (digit1 == 0 and ans[0] == '0'):
    print(-1)
    exit()
elif (dic[1] == 0):
    ans = '1' + ans[1:]

print(ans)


Fixed submission:
# n, m = map(int, input().split())
# if (m == 0):
#     print('1' + '0' * (n - 1))
#     exit()
# dic = {}
# for i in range(m):
#     s, c = map(int, input().split())
#     try:
#         _ = dic[s]
#     except KeyError:
#         if (s == 1 and c == 0):
#             print(-1)
#             exit()
#         dic[s] = c
#     else:
#         if (dic[s] != c):
#             print(-1)
#             exit()

# ans = '0' * n
# for k, v in dic.items():
#     ans = ans[:k - 1] + str(v) + ans[k:]

# try:
#     digit1 = dic[1]
# except KeyError:
#     digit1 = 1

# if (digit1 == 0):
#     ans = '1' + ans[1:]

# print(ans)
n, m = map(int, input().split())
if (n == 1 and m == 0):
    print(0)
    exit()
if (m == 0):
    print('1' + '0' * (n - 1))
    exit()
dic = {}
for i in range(m):
    s, c = map(int, input().split())
    try:
        _ = dic[s]
    except KeyError:
        if (s == 1 and c == 0 and n >= 2):
            print(-1)
            exit()
        dic[s] = c
    else:
        if (dic[s] != c):
            print(-1)
            exit()

ok = False
if (n == 1):
    for k, v in dic.items():
        print(v)
        exit()
else:
    for i in range(10 ** (n - 1), 10 ** n):
        for k, v in dic.items():
            if (str(i)[k - 1] == str(v)):
                ok = True
            else:
                ok = False
                break
        else:
            if (ok):
                print(i)
                exit()

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
# S = [None] * m
# C = [None] * m
dic = {}
for i in range(m):
    s, c = map(int, input().split())
    try:
        _ = dic[s]
    except KeyError:
        dic[s] = c
    else:
        if (dic[s] != c):
            print(-1)
            exit()

ans = '0' * n
for k, v in dic.items():
    ans = ans[:k - 1] + str(v) + ans[k:]

if (dic[1] == 0 and ans[0] == '0'):
    print(-1)
    exit()
elif (dic[1] == 0):
    ans = '1' + ans[1:]

print(ans)


Fixed submission:
# n, m = map(int, input().split())
# if (m == 0):
#     print('1' + '0' * (n - 1))
#     exit()
# dic = {}
# for i in range(m):
#     s, c = map(int, input().split())
#     try:
#         _ = dic[s]
#     except KeyError:
#         if (s == 1 and c == 0):
#             print(-1)
#             exit()
#         dic[s] = c
#     else:
#         if (dic[s] != c):
#             print(-1)
#             exit()

# ans = '0' * n
# for k, v in dic.items():
#     ans = ans[:k - 1] + str(v) + ans[k:]

# try:
#     digit1 = dic[1]
# except KeyError:
#     digit1 = 1

# if (digit1 == 0):
#     ans = '1' + ans[1:]

# print(ans)
n, m = map(int, input().split())
if (n == 1 and m == 0):
    print(0)
    exit()
if (m == 0):
    print('1' + '0' * (n - 1))
    exit()
dic = {}
for i in range(m):
    s, c = map(int, input().split())
    try:
        _ = dic[s]
    except KeyError:
        if (s == 1 and c == 0 and n >= 2):
            print(-1)
            exit()
        dic[s] = c
    else:
        if (dic[s] != c):
            print(-1)
            exit()

ok = False
if (n == 1):
    for k, v in dic.items():
        print(v)
        exit()
else:
    for i in range(10 ** (n - 1), 10 ** n):
        for k, v in dic.items():
            if (str(i)[k - 1] == str(v)):
                ok = True
            else:
                ok = False
                break
        else:
            if (ok):
                print(i)
                exit()