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

num = []
for i in range(n):
    num.append(False)

ans = False
if m == 0:
    if n == 1:
        ans = '0'
    else:
        ans = 10 ** (n-1)
for i in range(m):
    s, c = map(int, input().split())
    if num[s-1]:
        if num[s-1] != c:
            ans = -1
            break
    else:
        num[s-1] = c
if ans:
    print(ans)
else:
    if num[0] == 0:
        if n == 1:
            print(0)
        else:
            print(-1)
    else:
        for i in range(n):
            if i == 0:
                if not num[0]:
                    num[0] = 1
            else:
                if not num[i]:
                    num[i] = 0

        ans = "".join(map(str, num))
        print(ans)


