Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
s=[0]*M
c=[0]*M

for i in range(M):
  s[i],c[i]= map(int,input().split())
  
max_s=max(s)
ans=-1

for j in range(1000):
  flag=True
  k=str(j)  
  if len(k)<max_s:
    pass
  else:
    if len(k)!=N:
      pass
    else:    
      for l in range(M):
        if int(k[s[l]-1])!=c[l]:
          flag=False
          break
      if flag==True:
        if ans==-1:
          ans=j
        else:
          ans=min(ans,j)
        break
      
print(ans)

Fixed submission:
N,M=map(int,input().split())
s=[0]*M
c=[0]*M

for i in range(M):
  s[i],c[i]= map(int,input().split())

if M==0:
  for j in range(1000):
    k=str(j)
    if len(k)==N:
      ans=j
      break
else:
  max_s=max(s)
  ans=-1
  for j in range(1000):
    flag=True
    k=str(j)
    if len(k)!=N:
      pass
    else:
      for l in range(M):
        if int(k[s[l]-1])!=c[l]:
          flag=False
          break
      if flag==True:
        ans=j
        break
      
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
s=[0]*M
c=[0]*M

for i in range(M):
  s[i],c[i]= map(int,input().split())
  
max_s=max(s)
ans=-1

for j in range(1000):
  flag=True
  k=str(j)  
  if len(k)<max_s:
    pass
  else:
    if len(k)!=N:
      pass
    else:    
      for l in range(M):
        if int(k[s[l]-1])!=c[l]:
          flag=False
          break
      if flag==True:
        ans=j
        break
      
print(ans)

Fixed submission:
N,M=map(int,input().split())
s=[0]*M
c=[0]*M

for i in range(M):
  s[i],c[i]= map(int,input().split())

if M==0:
  for j in range(1000):
    k=str(j)
    if len(k)==N:
      ans=j
      break
else:
  max_s=max(s)
  ans=-1
  for j in range(1000):
    flag=True
    k=str(j)
    if len(k)!=N:
      pass
    else:
      for l in range(M):
        if int(k[s[l]-1])!=c[l]:
          flag=False
          break
      if flag==True:
        ans=j
        break
      
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
s=[0]*M
c=[0]*M

for i in range(M):
  s[i],c[i]= map(int,input().split())
  
max_s=max(s)
ans=-1

for j in range(1000):
  flag=True
  k=str(j)
  if len(k)<max_s:
    pass
  else:    
    for l in range(M):
      if int(k[s[l]-1])!=c[l]:
        flag=False
        break
    if flag==True:
      ans=j
      break
      
print(ans)

Fixed submission:
N,M=map(int,input().split())
s=[0]*M
c=[0]*M

for i in range(M):
  s[i],c[i]= map(int,input().split())

if M==0:
  for j in range(1000):
    k=str(j)
    if len(k)==N:
      ans=j
      break
else:
  max_s=max(s)
  ans=-1
  for j in range(1000):
    flag=True
    k=str(j)
    if len(k)!=N:
      pass
    else:
      for l in range(M):
        if int(k[s[l]-1])!=c[l]:
          flag=False
          break
      if flag==True:
        ans=j
        break
      
print(ans)

Buggy python submission (verdict: Runtime Error):
N,M=map(int,input().split())
s=[0]*M
c=[0]*M

for i in range(M):
  s[i],c[i]= map(int,input().split())
  
max_s=max(s)
ans=-1

for j in range(702,703):
  flag=True
  k=str(j)
  if len(k)<max_s:
    pass
  else:    
    for l in range(M):
      if int(k[s[l]-1])!=c[l]:
        flag=False
        break
    if flag==True:
      ans=j
      break
      
print(ans)

Fixed submission:
N,M=map(int,input().split())
s=[0]*M
c=[0]*M

for i in range(M):
  s[i],c[i]= map(int,input().split())

if M==0:
  for j in range(1000):
    k=str(j)
    if len(k)==N:
      ans=j
      break
else:
  max_s=max(s)
  ans=-1
  for j in range(1000):
    flag=True
    k=str(j)
    if len(k)!=N:
      pass
    else:
      for l in range(M):
        if int(k[s[l]-1])!=c[l]:
          flag=False
          break
      if flag==True:
        ans=j
        break
      
print(ans)