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

flag = False
if n == 1:
    ans = -1
    for i in range(m):
        s, c = map(int, input().split(' '))
        if ans == -1:
            ans = c
        else:
            if ans == c:
                pass
            else:
                ans = -1
                flag = True
    if flag:
        print('-1')
    else:
        print(ans)

else:
    ans = [-1 for i in range(n)]
    # input
    for i in range(m):
        s, c = map(int, input().split(' '))
        if ans[s-1] == -1:
            ans[s-1] = c
        else:
            if ans[s-1] == c:
                pass
            else:
                flag = True
    # output
    if flag:
        print(-1)
    elif ans[0] == 0:
        print(-1)
    else:
        for i in range(n):
            if ans[i] == -1:
                if i == 0:
                    ans[i] = 1
                else:
                    ans[i] = 0
        print(''.join(map(str, ans)))