Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
ans=[-1]*(N+1)
for i in range(M):
    s,c=map(int,input().split())
    if ans[s]==-1 :
        ans[s]=c
    elif ans[s]==c :
        pass
    else:
        print('-1')
        exit()

if N>=2 and ans[1]==0:
    print('-1')
    exit()    
elif N>=2 and ans[1]==-1: #ここが間違ってた。
    ans[1]==1
elif N==1:
    if ans[1]==-1 0r ans[1]==0:
        print(0)

else:
    pass

for j in range(len(ans)):
    if ans[j] == -1:
        ans[j] = 0

if N==1:
    FA=ans[-1]
elif N==2:
    FA=10*ans[-2]+ans[-1]
else:
    FA=100*ans[-3]+10*ans[-2]+ans[-1]
print(FA)

Fixed submission:
N,M=map(int,input().split())
ans=[-1]*(N+1)
for i in range(M):
    s,c=map(int,input().split())
    if ans[s]==-1 :
        ans[s]=c
    elif ans[s]==c :
        pass
    else:
        print('-1')
        exit()

if N>=2 and ans[1]==0:
    print('-1')
    exit()
elif N>=2 and ans[1]==-1: #ここが間違ってた。
    ans[1]=1
else:
    pass

for j in range(len(ans)):
    if ans[j] == -1:
        ans[j] = 0

if N==1:
    FA=ans[-1]
elif N==2:
    FA=10*ans[-2]+ans[-1]
else:
    FA=100*ans[-3]+10*ans[-2]+ans[-1]
print(FA)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
ans=['A']*(N+1)
for i in range(M):
    s,c=map(str,input().split())
    s=int(s)
    if ans[s]=='A' or ans[s]==c :
        ans[s]=c
    else:
        print('-1')
        exit()
if N>1 and ans[1]=='A':
    print('-1')
FA=''.join(FA)
FA=FA[1:]
if FA.count('A')>0:
    print(FA.replace('A','0'))
print(int(FA))


Fixed submission:
N,M=map(int,input().split())
ans=[-1]*(N+1)
for i in range(M):
    s,c=map(int,input().split())
    if ans[s]==-1 :
        ans[s]=c
    elif ans[s]==c :
        pass
    else:
        print('-1')
        exit()

if N>=2 and ans[1]==0:
    print('-1')
    exit()
elif N>=2 and ans[1]==-1: #ここが間違ってた。
    ans[1]=1
else:
    pass

for j in range(len(ans)):
    if ans[j] == -1:
        ans[j] = 0

if N==1:
    FA=ans[-1]
elif N==2:
    FA=10*ans[-2]+ans[-1]
else:
    FA=100*ans[-3]+10*ans[-2]+ans[-1]
print(FA)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
ans=['A']*(N+1)
for i in range(M):
    s,c=map(str,input().split())
    s=int(s)
    if ans[s]=='A' or ans[s]==c :
        ans[s]=c
    else:
        print('-1')
        exit()
if N>1 and ans[1]=='0':
    print('-1')
FA=ans[1:]
FA=''.join(FA)
if FA.count('A')>0:
    print(FA.replace('A','0'))
print(int(FA))


Fixed submission:
N,M=map(int,input().split())
ans=[-1]*(N+1)
for i in range(M):
    s,c=map(int,input().split())
    if ans[s]==-1 :
        ans[s]=c
    elif ans[s]==c :
        pass
    else:
        print('-1')
        exit()

if N>=2 and ans[1]==0:
    print('-1')
    exit()
elif N>=2 and ans[1]==-1: #ここが間違ってた。
    ans[1]=1
else:
    pass

for j in range(len(ans)):
    if ans[j] == -1:
        ans[j] = 0

if N==1:
    FA=ans[-1]
elif N==2:
    FA=10*ans[-2]+ans[-1]
else:
    FA=100*ans[-3]+10*ans[-2]+ans[-1]
print(FA)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
ans=['A']*(N+1)
for i in range(M):
    s,c=map(str,input().split())
    s=int(s)
    if ans[s]=='A' or ans[s]==c :
        ans[s]=c
    else:
        print('-1')
        exit()
FA=ans[1:]
FA=''.join(FA)
if FA.count('A')>0:
    print(FA.replace('A','0'))
print(int(FA))


Fixed submission:
N,M=map(int,input().split())
ans=[-1]*(N+1)
for i in range(M):
    s,c=map(int,input().split())
    if ans[s]==-1 :
        ans[s]=c
    elif ans[s]==c :
        pass
    else:
        print('-1')
        exit()

if N>=2 and ans[1]==0:
    print('-1')
    exit()
elif N>=2 and ans[1]==-1: #ここが間違ってた。
    ans[1]=1
else:
    pass

for j in range(len(ans)):
    if ans[j] == -1:
        ans[j] = 0

if N==1:
    FA=ans[-1]
elif N==2:
    FA=10*ans[-2]+ans[-1]
else:
    FA=100*ans[-3]+10*ans[-2]+ans[-1]
print(FA)