def c():
    N, M = map(int, input().split())
    ans = list('1' + '0' * (N-1))
    digits = {}
    for j in range(M):
        s, c = map(int, input().split())
        if (s, c) == (1, 0) and N > 2:
            print(str(-1))
            return
        if s in digits:
            if digits[s] != c:
                print(str(-1))
                return
            else:
                # do nothing
                pass
        else:
            digits[s] = c
            ans[s-1] = str(c)

    print(''.join(ans))


##########
c()
