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())

num = 0
t = 0
s2 = [0]*n

if s == 1:
    for i in range(m):
      for j in range(m):
        if c[i] != c[j] :
            print(-1)
            break
    print(c[0])
    
 
 
else:
    if len(set(s)) != len(s):
  
        for i in range(m):
          for j in range(m):
            if s[i] == s[j] and c[i] != c[j] and i !=j:
                #print(-1)
                t = 1
                break

        #m = len(set(s))
        #s = sorted(set(s), key=s.index)
        #c = sorted(set(c), key=c.index)
        
        for i in range(m):
          s2[s[i]-1] = c[i]
          
        
    for i in range(m):
        
        
        num += 10**(n-(i+1))*s2[i]
        
    if t == 0 and num >= 10**(n-1)-1 and m != 0:
        
    	print(num)
    else :
        print(-1)

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())

num = 0
t = 0
s2 = [0]*n
if n>1:
	s2[0] = 1

if s == 1:
    for i in range(m):
      for j in range(m):
        if c[i] != c[j] :
            print(-1)
            break
    print(c[0])
    
 
else:
    if len(set(s)) != len(s):
  
        for i in range(m):
          for j in range(m):
            if s[i] == s[j] and c[i] != c[j] and i !=j:
                #print(-1)
                t = 1
                break
        
    for i in range(m):
        s2[s[i]-1] = c[i]
          
        
    for i in range(n):
        
        
        num += 10**(n-(i+1))*s2[i]
        
    if t == 0 and num >= 10**(n-1)-1 :
        
    	print(num)
    else :
        print(-1)

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())

num = 0
t = 0
s2 = [0]*n

if s == 1:
    for i in range(m):
      for j in range(m):
        if c[i] != c[j] :
            print(-1)
            break
    print(c[0])
    
 
 
else:
    if len(set(s)) != len(s):
  
        for i in range(m):
          for j in range(m):
            if s[i] == s[j] and c[i] != c[j] and i !=j:
                #print(-1)
                t = 1
                break

        #m = len(set(s))
        #s = sorted(set(s), key=s.index)
        #c = sorted(set(c), key=c.index)
        
        for i in range(m):
          s2[s[i]-1] = c[i]
          
        
    for i in range(m):
        
        
        num += 10**(n-(i+1))*s2[i]
        
    if t == 0 and num >= 10**(n-1)-1 and m != 0:
        
    	print(num)
    else :
        print(-1)

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())

num = 0
t = 0
s2 = [0]*n
if n>1:
	s2[0] = 1

if s == 1:
    for i in range(m):
      for j in range(m):
        if c[i] != c[j] :
            print(-1)
            break
    print(c[0])
    
 
else:
    if len(set(s)) != len(s):
  
        for i in range(m):
          for j in range(m):
            if s[i] == s[j] and c[i] != c[j] and i !=j:
                #print(-1)
                t = 1
                break
        
    for i in range(m):
        s2[s[i]-1] = c[i]
          
        
    for i in range(n):
        
        
        num += 10**(n-(i+1))*s2[i]
        
    if t == 0 and num >= 10**(n-1)-1 :
        
    	print(num)
    else :
        print(-1)

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())

num = 0
t = 0
s2 = [0]*n

if s == 1:
    for i in range(m):
      for j in range(m):
        if c[i] != c[j] :
            print(-1)
            break
    print(c[0])
    
 
 
else:
    if len(set(s)) != len(s):
  
        for i in range(m):
          for j in range(m):
            if s[i] == s[j] and c[i] != c[j] and i !=j:
                #print(-1)
                t = 1
                break

        #m = len(set(s))
        #s = sorted(set(s), key=s.index)
        #c = sorted(set(c), key=c.index)
        
        for i in range(m):
          s2[s[i]-1] = c[i]
          
        
    for i in range(m):
        
        
        num += 10**(n-(i+1))*s2[i]
        
    if t == 0 and num >= 10**(n-1)-1 and m != 0:
        
    	print(num)
    else :
        print(-1)

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())

num = 0
t = 0
s2 = [0]*n
if n>1:
	s2[0] = 1

if s == 1:
    for i in range(m):
      for j in range(m):
        if c[i] != c[j] :
            print(-1)
            break
    print(c[0])
    
 
else:
    if len(set(s)) != len(s):
  
        for i in range(m):
          for j in range(m):
            if s[i] == s[j] and c[i] != c[j] and i !=j:
                #print(-1)
                t = 1
                break
        
    for i in range(m):
        s2[s[i]-1] = c[i]
          
        
    for i in range(n):
        
        
        num += 10**(n-(i+1))*s2[i]
        
    if t == 0 and num >= 10**(n-1)-1 :
        
    	print(num)
    else :
        print(-1)