N,M = map(int, input().split(' '))
A = []

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

for i in range(M):
  A.append(input().split(' '))

A = get_unique_list(A)

B = {}
for i in range(len(A)):
  if str(A[i][0]) in B:
    print("-1")
    exit()
  B[str(A[i][0])] = A[i][1]
if "1" in B:
  if B['1'] == "0":
    print("-1")
    exit()
ans=""  

for i in range(N):
  if str(i + 1) in B:
    ans = ans + B[str(i + 1)]
    continue
  if i == 0:
    ans = ans + "1"
    continue
  ans = ans + "0"
print(ans)