n = list(map(int,input().split()))
k = [list(map(int,input().split())) for i in range(n[1])]
num = [1]
def has_duplicates(seq):
    return len(seq) != len(set(seq))
def has_duplicates2(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) != len(unique_list)
if has_duplicates([k[l][0] for l in range(len(k))]):
  if has_duplicates2(k):
    m =1
  else:
    print(-1)
    exit()
for l in range(n[0] - 1):
  num.append(0)
for l in range(len(k)):
	num[ k[l][0] - 1 ] = k[l][1]
#print(''.join(map(str, num)))
if len(num) == 1:
  if num[0] == 0:
    print(-1)
  else:
  	print(''.join(map(str, num)))
else:
  if num[0] == 0:
    print(-1)
  else:
    print(''.join(map(str, num)))