Problem p02761 (python)

Fixed submission:
n,m = map(int,input().split())
s = list(list(map(int,input().split())) for i in range(m))
x = [-1]*n
b = True
for i in range(m):
    if x[s[i][0]-1] == -1 or x[s[i][0]-1] == s[i][1]:
        x[s[i][0]-1] = s[i][1]
    else:
        b = False
for j in range(n):
    if x[j] == -1:
        if len(x) != 1 and j == 0:
            x[j] = 1
        else:
            x[j] = 0
if len(x) != 1 and x[0] == 0:
    b = False

if b:
  S=""
  for o in range(n):
    S+=str(x[o])
  print(int(S))
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[-1]*N
ans=0
L=list(list(map(int,input().split())) for j in range(M))
for i in range(M):
  if A[L[M][0]-1]==-1 or A[L[M][0]-1]==L[M][1]:
    A[L[M][0]-1]==L[M][1]
  else:
    ans=-1
    break
S=""
for k in range(N):
  if A[k]==-1:
    if N!=1 and k==0:
      A[k]=1
    else:
      A[k]=0
  
  if N!=1 and A[0]==0:
    ans=-1
    break
  S+=str(A[i])
if ans=-1:
  print(-1)
else:
  print(int(S))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[-1]*N
L=[]
for j in range(M):
  L.append(list(map(int,input().split())))
for i in range(M):
  if A[L[M][0]-1]==-1 or A[L[M][0]-1]==L[M][1]:
    A[L[M][0]-1]==L[M][1]
  else:
    print(-1)
    exit()
S=""
if N!=1 and A[0]==0:
  print(-1)
  exit()
for k in range(N):
  if A[k]==-1:
    if N!=1 and k==0:
      A[k]=1
    else:
      A[k]=0
  S+=str(A[i])
print(int(S))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[-1]*N
for i in range(M):
  L=list(map(int,input().split()))
  if A[L[0]-1]==-1:
    A[L[0]-1]=L[1]
  else:
    if A[L[0]-1]==L[1]:
      continue
    else:
      print(-1)
      exit()
if N!=1 and A[0]==0:
  print(-1)
else:
  S=""
  if A[0]==-1:
    A[0]=1
  
  if N!=1:
    for i in range(N):
      if A[i]==-1:
        A[i]=0
      S+=str(A[i])
    print(int(S))
  else:
    print(int(A[0])

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[-1]*N
k=0
for i in range(M):
  L=list(map(int,input().split()))
  if A[L[0]-1]==-1:
    A[L[0]-1]=L[1]
  else:
    if A[L[0]-1]!=L[1]:
      k=1
      break
    else:
      continue
if (k==1) or (N!=1 and A[0]==0):
  print(-1)
else:
  S=""
  if A[0]==-1:
    A[0]=1
  if N!=1:
    for i in range(N):
      if A[i]==-1:
        A[i]=0
      S+=str(A[i])
    print(int(S))
  if N==1:
    print(int(A[0])

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[-1]*N
k=0
for i in range(M):
  L=list(map(int,input().split()))
  if A[L[0]-1]==-1:
    A[L[0]-1]=L[1]
  else:
    if A[L[0]-1]!=L[1]:
      k=1
      break
    else:
      continue
if (k==1) or (N!=1 and A[0]==0):
  print(-1)
else:
  S=""
  if A[0]==-1:
    A[0]=1
    
  if N!=1:
    for i in range(N):
      if A[i]==-1:
        A[i]=0
      S+=str(A[i])
      print(int(S))
  else N==1:
    print(int(A[0])

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[-1]*N
k=0
for i in range(M):
  L=list(map(int,input().split()))
  if A[L[0]-1]==-1:
    A[L[0]-1]=L[1]
  else:
    if A[L[0]-1]!=L[1]:
      k=1
      break
    else:
      continue
if (k==1) or (N!=1 and A[0]==0):
  print(-1)
else:
  S=""
  if A[0]==-1:
    A[0]=1
  if N!=1:
    for i in range(N):
      if A[i]==-1:
        A[i]=0
      S+=str(A[i])
  print(int(S))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A=[-1]*N
k=0
for i in range(M):
  L=list(map(int,input().split()))
  if A[L[0]-1]==-1:
    A[L[0]-1]=L[1]
  else:
    if A[L[0]-1]!=L[1]:
      k=1
      break
    else:
      continue
if (k=1) or (N!=1 and A[0]==0):
  print(-1)
else:
  A=""
  if A[0]==-1:
    A[0]=1
  if N!=1:
    for i in range(N):
      if A[i]==-1:
        A[i]=0
      S+=str(A[i])
print(int(S))