# -*- coding: utf-8 -*-

#整数値龍力　複数の入力
def input_multiple_number():
    return map(int, input().split())

n,m = input_multiple_number()

ans = [-1]*n

for i in range(m):
    s,c = input_multiple_number()
    if ans[s-1] != -1 and ans[s-1] != c:
        print(-1)
        exit()

    ans[s-1]=c

if ans[0] == 0:
    print(-1)
    exit()

if ans[0] == -1:
    ans[0] = 1

for j in range(n-1):
    if ans[j+1] == -1:
        ans[j+1] = 0

numans = 0
for j in range(n):
    numans += pow(10,n-j-1)*ans[j]

print(numans)
