Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
dic = {}
ans = 0
for _ in range(m):
    s,c = map(int,input().split())
    if s not in dic.keys():
        dic[s-1] = c
    elif s in dic.keys() and dic[s-1] !=c:
        ans = -1
        break
if 0 in dic.keys() and dic[0] ==0:
    ans = -1

for i in range(n):
    if i not in dic.keys():
        dic[i] = 0

if ans == -1:
    print('-1')
    exit()
if dic[0] ==0:
    dic[0] = 1
ls = []
for i in range(n):
    ls.append(str(dic[i]))
ans = ''.join(ls)
print(ans)

Fixed submission:
n, m = map(int,input().split())
dic = {}
ans = 0
for _ in range(m):
    s,c = map(int,input().split())
    if s-1 not in dic.keys():
        dic[s-1] = c
    if s-1 in dic.keys() and dic[s-1] !=c:
        ans = -1
        break
    if s == 1 and c == 0 and n!=1:
        ans = -1
        break
if ans == -1:
    print(ans)
    exit()
if 1 not in dic.keys() and n !=1:
    dic[1] = 0
if 2 not in dic.keys() and n ==3:
    dic[2] = 0  
if 0 not in dic.keys() and n!=1:
    dic[0] = 1
if 0 not in dic.keys() and n==1:
    dic[0] = 0
ls = []
for i in range(n):
    ls.append(str(dic[i]))
ans = ''.join(ls)
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
dic = {}
ans = 0
for _ in range(m):
    s,c = map(int,input().split())
    if s not in dic.keys():
        dic[s-1] = c
    elif s in dic.keys() and dic[s-1] !=c:
        ans = -1
        break
for i in range(n):
    if i not in dic.keys():
        dic[i] = 0

if dic[0] ==0:
    ans = -1
if ans == -1:
    print('-1')
    exit()
ls = []
for i in range(n):
    ls.append(str(dic[i]))
ans = ''.join(ls)
print(ans)


Fixed submission:
n, m = map(int,input().split())
dic = {}
ans = 0
for _ in range(m):
    s,c = map(int,input().split())
    if s-1 not in dic.keys():
        dic[s-1] = c
    if s-1 in dic.keys() and dic[s-1] !=c:
        ans = -1
        break
    if s == 1 and c == 0 and n!=1:
        ans = -1
        break
if ans == -1:
    print(ans)
    exit()
if 1 not in dic.keys() and n !=1:
    dic[1] = 0
if 2 not in dic.keys() and n ==3:
    dic[2] = 0  
if 0 not in dic.keys() and n!=1:
    dic[0] = 1
if 0 not in dic.keys() and n==1:
    dic[0] = 0
ls = []
for i in range(n):
    ls.append(str(dic[i]))
ans = ''.join(ls)
print(ans)

Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
dic = {}
for _ in range(m):
    s,c = map(int,input().split())
    if s not in dic.keys():
        dic[s-1] = c
    elif s in dic.keys() and dic[s-1] !=c:
        res = -1
        break
for i in range(n):
    if i not in dic.keys():
        dic[i] = 0

if dic[0] ==0:
    res = -1
if res == -1:
    print('-1')
    exit()
ls = []
for i in range(n):
    ls.append(str(dic[i]))
ans = ''.join(ls)
print(ans)


Fixed submission:
n, m = map(int,input().split())
dic = {}
ans = 0
for _ in range(m):
    s,c = map(int,input().split())
    if s-1 not in dic.keys():
        dic[s-1] = c
    if s-1 in dic.keys() and dic[s-1] !=c:
        ans = -1
        break
    if s == 1 and c == 0 and n!=1:
        ans = -1
        break
if ans == -1:
    print(ans)
    exit()
if 1 not in dic.keys() and n !=1:
    dic[1] = 0
if 2 not in dic.keys() and n ==3:
    dic[2] = 0  
if 0 not in dic.keys() and n!=1:
    dic[0] = 1
if 0 not in dic.keys() and n==1:
    dic[0] = 0
ls = []
for i in range(n):
    ls.append(str(dic[i]))
ans = ''.join(ls)
print(ans)