Buggy python submission (verdict: Runtime Error):
n, m = map(int,input().split())
li = []
for _ in range(m):
    li.append(list(map(int,input().split())))
li = list(map(list, set(map(tuple, li))))
li = sorted(li)
number = 0
for i in range(len(li)-1):
    if li[i][0] == li[i+1][0]:
        print(-1)
        exit()
    else:
        number += li[i][1] * (10 ** (n-li[i][0])    )
number += li[len(li)-1][1] * (10 ** (n-li[len(li)-1][0])    )
if li[0][0] == 1 and li[0][1] == 0 and n >= 2:
    print(-1)
    exit()
print(number)

Fixed submission:
from sys import stdin
import math

n, m = [int(x) for x in stdin.readline().rstrip().split()]

s = [0] * m
c = [0] * m
for i in range(m):
    s[i], c[i] = [int(x) for x in stdin.readline().rstrip().split()]

result = -1
for nn in range(10 ** n):
    ns = str(nn)
    if len(ns) < n:
        continue
    #ns = ns.zfill(n)
    flag = True
    for i in range(m):
        if ns[s[i]-1] == str(c[i]):
            continue
        else:
            flag = False
            break
    if flag:
        result = nn
        if n > 1 and result == 0:
            result = -1
        break

print(result)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
li = []
itg = 0
flag = True
for _ in range(m):
  li.append(list(map(int,input().split())))
li = sorted(li, key = lambda x:x[0], reverse=True)
for i in range(m-1):
  if li[i][0] == li[i+1][0]:
    if li[i][1] != li[i+1][1]:
      print(-1)
      flag = False
    else:
      li[i][1] = 0
if flag:
  k = li[0][0]
  for l in li:
    itg += l[1] * (10 ** (k-l[0]))
  if len(str(itg)) > n:
    print(-1)
  elif itg == 0 and n >= 2:
    print(-1)
  else:
    print(itg)

Fixed submission:
from sys import stdin
import math

n, m = [int(x) for x in stdin.readline().rstrip().split()]

s = [0] * m
c = [0] * m
for i in range(m):
    s[i], c[i] = [int(x) for x in stdin.readline().rstrip().split()]

result = -1
for nn in range(10 ** n):
    ns = str(nn)
    if len(ns) < n:
        continue
    #ns = ns.zfill(n)
    flag = True
    for i in range(m):
        if ns[s[i]-1] == str(c[i]):
            continue
        else:
            flag = False
            break
    if flag:
        result = nn
        if n > 1 and result == 0:
            result = -1
        break

print(result)

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
li = []
itg = 0
flag = True
for _ in range(m):
  li.append(list(map(int,input().split())))
li = sorted(li, key = lambda x:x[0], reverse=True)
for i in range(m-1):
  if li[i][0] == li[i+1][0]:
    if li[i][1] != li[i+1][1]:
      print(-1)
      flag = False
    else:
      li[i][1] = 0
if flag:
  k = li[0][0]
  for l in li:
    itg += l[1] * (10 ** (k-l[0]))
  print(itg)

Fixed submission:
from sys import stdin
import math

n, m = [int(x) for x in stdin.readline().rstrip().split()]

s = [0] * m
c = [0] * m
for i in range(m):
    s[i], c[i] = [int(x) for x in stdin.readline().rstrip().split()]

result = -1
for nn in range(10 ** n):
    ns = str(nn)
    if len(ns) < n:
        continue
    #ns = ns.zfill(n)
    flag = True
    for i in range(m):
        if ns[s[i]-1] == str(c[i]):
            continue
        else:
            flag = False
            break
    if flag:
        result = nn
        if n > 1 and result == 0:
            result = -1
        break

print(result)