n, m = map(int, input().split())
a = [-1 for i in range(n)]
possibility = True
for i in range(m):
    s, c = map(int, input().split())
    if a[s - 1] == -1:
        a[s - 1] = c
    elif a[s - 1] == c:
        pass
    else:
        possibility = False
if a[0] == 0:
    possibility = False
for i in range(n):
    if a[i] == -1:
        a[i] = 0
if a[0] == 0:
    a[0] = 1
if possibility == True:
    ans = ''
    for i in range(n):

        ans += str(a[i])
    print(ans)
else:
    print('-1')