n, m = map(int, input().split())
x = [None for _ in range(n)]
ans = 0
for i in range(m):
    s, c = map(int, input().split())
    if x[s - 1] is None:
        x[s - 1] = c
    elif x[s - 1] != c:
        ans = -1

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

if ans == 0:
    ans = ''
    for i, xi in enumerate(x):
        if xi is None:
            if i == 0:
                ans += '1'
            else:
                ans += '0'
        else:
            ans += str(xi)
print(ans)
