Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
d=["a"]*n
ans=""
for i in range(m):
    s,c=map(str,input().split())
    s=int(s)
    if d[s-1]=="a" or d[s-1]==c:
        d[s-1]=c #置き換え
    else:
        ans="-1"
        break
if d[0]=="0":
    print(-1)
elif d[0]=="a":
    d[0]="1"
    if d[2]=="a":
        print(-1)
    else:
        print(("".join(d)))
else:
    print(("".join(d)).replace("a","0"))

Fixed submission:
n,m=map(int,input().split())
d=["a"]*n
ans=""
if n==1 and m==0:
    print(0)
    exit()
for i in range(m):
    s,c=map(str,input().split())
    if s=="1" and c=="0" and n==1:
        print(0)
        exit()
    s=int(s)
    if d[s-1]=="a" or d[s-1]==c:
        d[s-1]=c #置き換え
    else:
        ans="-1"
        print(ans)
        break
if d[0]!="0" and ans!="-1":
    if d[0]=="a" or d[0]=="0":
        print("".join(["1"]+d[1:]).replace("a","0"))
    else:
        print(("".join(d)).replace("a","0"))
elif d[0]=="0":
    print(-1)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=["a"]*n
for i in range(m):
    s,c=map(int,input().split())
    if s>n:
        pans="-1"
        break
    elif ans[s-1]=="a" or ans[s-1]==c:
        ans[s-1]=c 
        pans="0"
        if s==1 and c==0:
            pans="-1"
            break
    else:
        pans="-1"
        break
                
ans = [str(i) for i in ans]
if pans != "-1":
    pans="".join(ans)
    pans=pans.replace("a","0")
    if pans[0]=="0":
        pans='1' + pans[1:]
print(pans)

Fixed submission:
n,m=map(int,input().split())
d=["a"]*n
ans=""
if n==1 and m==0:
    print(0)
    exit()
for i in range(m):
    s,c=map(str,input().split())
    if s=="1" and c=="0" and n==1:
        print(0)
        exit()
    s=int(s)
    if d[s-1]=="a" or d[s-1]==c:
        d[s-1]=c #置き換え
    else:
        ans="-1"
        print(ans)
        break
if d[0]!="0" and ans!="-1":
    if d[0]=="a" or d[0]=="0":
        print("".join(["1"]+d[1:]).replace("a","0"))
    else:
        print(("".join(d)).replace("a","0"))
elif d[0]=="0":
    print(-1)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=["a"]*n
for i in range(m):
    s,c=map(int,input().split())
    if s>n:
        pans="-1"
        break
    if ans[s-1]=="a" or ans[s-1]==c:
        ans[s-1]=c 
        pans="0"
        if s==1 and c==0:
            pans="-1"
            break
    else:
        pans="-1"
        break
                
ans = [str(i) for i in ans]
if pans != "-1":
    pans="".join(ans)
    pans=pans.replace("a","0")
    if pans[0]=="0":
        pans='1' + pans[1:]
print(pans)

Fixed submission:
n,m=map(int,input().split())
d=["a"]*n
ans=""
if n==1 and m==0:
    print(0)
    exit()
for i in range(m):
    s,c=map(str,input().split())
    if s=="1" and c=="0" and n==1:
        print(0)
        exit()
    s=int(s)
    if d[s-1]=="a" or d[s-1]==c:
        d[s-1]=c #置き換え
    else:
        ans="-1"
        print(ans)
        break
if d[0]!="0" and ans!="-1":
    if d[0]=="a" or d[0]=="0":
        print("".join(["1"]+d[1:]).replace("a","0"))
    else:
        print(("".join(d)).replace("a","0"))
elif d[0]=="0":
    print(-1)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=["a"]*n
for i in range(m):
    s,c=map(int,input().split())
    if ans[s-1]=="a" or ans[s-1]==c:
        ans[s-1]=c 
        pans="0"
        if s==1 and c==0:
            pans="-1"
            break
    else:
        pans="-1"
        break
                
ans = [str(i) for i in ans]
if pans != "-1":
    pans="".join(ans)
    if pans[0]=="0":
        pans='1' + pans[1:]
print(pans.replace("a","0"))

Fixed submission:
n,m=map(int,input().split())
d=["a"]*n
ans=""
if n==1 and m==0:
    print(0)
    exit()
for i in range(m):
    s,c=map(str,input().split())
    if s=="1" and c=="0" and n==1:
        print(0)
        exit()
    s=int(s)
    if d[s-1]=="a" or d[s-1]==c:
        d[s-1]=c #置き換え
    else:
        ans="-1"
        print(ans)
        break
if d[0]!="0" and ans!="-1":
    if d[0]=="a" or d[0]=="0":
        print("".join(["1"]+d[1:]).replace("a","0"))
    else:
        print(("".join(d)).replace("a","0"))
elif d[0]=="0":
    print(-1)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
ans=[0]*n
for i in range(m):
    s,c=map(int,input().split())
    ans[s-1]=c
    if c!=0 and ans[s-1]==0:
        ans[s-1]=c 
        pans="0"
    else:
        pans="-1"
                
ans = [str(i) for i in ans]
if pans != "-1":
    pans="".join(ans)
    if pans[0]=="0":
        pans='1' + pans[1:]
print(pans)

Fixed submission:
n,m=map(int,input().split())
d=["a"]*n
ans=""
if n==1 and m==0:
    print(0)
    exit()
for i in range(m):
    s,c=map(str,input().split())
    if s=="1" and c=="0" and n==1:
        print(0)
        exit()
    s=int(s)
    if d[s-1]=="a" or d[s-1]==c:
        d[s-1]=c #置き換え
    else:
        ans="-1"
        print(ans)
        break
if d[0]!="0" and ans!="-1":
    if d[0]=="a" or d[0]=="0":
        print("".join(["1"]+d[1:]).replace("a","0"))
    else:
        print(("".join(d)).replace("a","0"))
elif d[0]=="0":
    print(-1)