n, m = list(map(int, input().split()))

ans = 10 ** n
num = [-1] * n

for i in range(m):
    s, c = list(map(int, input().split()))
    if num[s - 1] == -1:
        num[s - 1] = c
    elif num[s - 1] != c:
        ans = -1
        break

if ans != -1 and n == 1:
    ans = num[0]
else:
    # 先頭0チェック
    if num[0] == 0:
        ans = -1
    # 先頭1チェック
    elif num[0] == -1:
        num[0] = 1
    # 最小値なので2桁目以降は-1があれば0を代入
    else:
        for j in range(1, n):
            if num[j] == -1:
                num[j] = 0
        ans = int(''.join(list(map(str, num))))

print(ans)
