N, M = map(int, input().split())
num = [-1 for i in range(N)]
for m in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0 and N != 1:
        print(-1)
        import sys
        sys.exit(0)
    elif num[s-1] == -1:
        num[s-1] = c
    elif num[s-1] != c:
        print(-1)
        import sys
        sys.exit(0)
for n in range(N):
    if n == 0 and num[n] == -1:
        num[0] = 1
    elif num[n] == -1:
        num[n] = 0
print("".join(map(str, num)))
