Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict

N, M = map(int, input().split())
d = defaultdict(int)

for i in range(M):
    s, c = map(int, input().split())
    if (d[s] != 0) & (d[s] != c):  # 数指定に矛盾があったら終わり
        print(-1)
        sys.exit()
    elif ((s == 1) & (c == 0)) & (N > 1):　　# 桁数に矛盾があったら終わり
        print(-1)
        sys.exit()
    elif d[s] == 0:　　# 初めて出会ったものはメモしていく
        d[s] = c
    else:
        continue

# 1桁ならそのまま出す
if N==1:
    print(d[1])
    sys.exit()

# 2桁以上の場合は最も大きい桁を1、それ未満の桁を0で初期化
ans = ["1"] + ["0"] * (N - 1)

# 値更新
for s, c in d.items():
    ans[int(s) - 1] = str(c)

print("".join(ans))

Fixed submission:
import sys
from collections import defaultdict

N, M = map(int, input().split())
d = defaultdict(int)

for i in range(M):
    s, c = map(int, input().split())
    if (d[s] != 0) & (d[s] != c):
        print(-1)
        sys.exit()
    elif ((s == 1) & (c == 0)) & (N > 1):
        print(-1)
        sys.exit()
    elif d[s] == 0:
        d[s] = c
    else:
        continue

if N==1:
    print(d[1])
    sys.exit()

ans = ["1"] + ["0"] * (N - 1)

for s, c in d.items():
    ans[int(s) - 1] = str(c)

print("".join(ans))

Buggy python submission (verdict: Runtime Error):
import sys
from collections import defaultdict

n, m = map(int, input().split())
tmp = [0] * n
memo = defaultdict(int)

for i in range(m):
    s, c = map(int, input().split())
    if i==0:
        memo[s] = c
    elif s in memo & memo[s]!=c:
        print(-1)
        sys.exit()
    elif (n==3 & s==1 & c==0):
        print(-1)
        sys.exit()
    else:
        tmp[s-1] = c
    
print(0) if sum(tmp) == 0 else print(*tmp, sep="")

Fixed submission:
import sys
from collections import defaultdict

N, M = map(int, input().split())
d = defaultdict(int)

for i in range(M):
    s, c = map(int, input().split())
    if (d[s] != 0) & (d[s] != c):
        print(-1)
        sys.exit()
    elif ((s == 1) & (c == 0)) & (N > 1):
        print(-1)
        sys.exit()
    elif d[s] == 0:
        d[s] = c
    else:
        continue

if N==1:
    print(d[1])
    sys.exit()

ans = ["1"] + ["0"] * (N - 1)

for s, c in d.items():
    ans[int(s) - 1] = str(c)

print("".join(ans))

Buggy python submission (verdict: Runtime Error):
import sys
n, m = map(int, input().split())
s = [0] * m
c = [0] * m
tmp = [0] * m

for i in range(m):
    s[i], c[i] = map(int, input().split())
    
for x, y in zip(s, c):
    if tmp[x-1]==0:
        tmp[x-1] = y
    elif tmp[x-1]==y:
        continue
    else:
        print(-1)
        sys.exit()

ans = 0

for i, a in enumerate(tmp[::-1]):
    ans += a*10**(i)

if n==1 & ans==0:
    print(ans)
elif ans // 10**(m-1) < 1:
    print(-1)
    sys.exit()
    
print(ans)

Fixed submission:
import sys
from collections import defaultdict

N, M = map(int, input().split())
d = defaultdict(int)

for i in range(M):
    s, c = map(int, input().split())
    if (d[s] != 0) & (d[s] != c):
        print(-1)
        sys.exit()
    elif ((s == 1) & (c == 0)) & (N > 1):
        print(-1)
        sys.exit()
    elif d[s] == 0:
        d[s] = c
    else:
        continue

if N==1:
    print(d[1])
    sys.exit()

ans = ["1"] + ["0"] * (N - 1)

for s, c in d.items():
    ans[int(s) - 1] = str(c)

print("".join(ans))

Buggy python submission (verdict: Runtime Error):
import sys
n, m = map(int, input().split())
s = [0] * m
c = [0] * m
tmp = [0] * m

for i in range(m):
    s[i], c[i] = map(int, input().split())
    
for x, y in zip(s, c):
    if tmp[x-1]==0:
        tmp[x-1] = y
    elif tmp[x-1]==y:
        continue
    else:
        print(-1)
        sys.exit()

ans = 0
for i, a in enumerate(tmp[::-1]):
    ans += a*10**(i)

if (n==1) & (ans==0):
    print(0)
    sys.exit()

if (n>=2) & (ans < 10**(n-1)):
    print(-1)
    sys.exit()
    
print(ans)

Fixed submission:
import sys
from collections import defaultdict

N, M = map(int, input().split())
d = defaultdict(int)

for i in range(M):
    s, c = map(int, input().split())
    if (d[s] != 0) & (d[s] != c):
        print(-1)
        sys.exit()
    elif ((s == 1) & (c == 0)) & (N > 1):
        print(-1)
        sys.exit()
    elif d[s] == 0:
        d[s] = c
    else:
        continue

if N==1:
    print(d[1])
    sys.exit()

ans = ["1"] + ["0"] * (N - 1)

for s, c in d.items():
    ans[int(s) - 1] = str(c)

print("".join(ans))