in1 = input('')
n = int(in1.split(' ')[0])
m = int(in1.split(' ')[1])
l = []
for i in range(0,n):
  l.append("0")

for i in range(0,m):
  in2 = input('')
  idx = int(in2.split(' ')[0])-1
  li = in2.split(' ')[1]
  l[idx] = li

result = ""
for i in range(0,n):
  result += l[i]
if result.startswith("0"):
  result = "-1"
print(result)

