import sys

N, M = list(map(int, input().split()))

mylist = [0 for _ in range(N)]

for _ in range(M):
    s, c = list(map(int, input().split()))
    mylist[s - 1] = c

if N != 1 and mylist[0] == 0:
    print("-1")
    sys.exit()

ans = 0
for i in range(N):
    ans = ans + mylist[N - 1 - i] * 10 ** i
    
print(ans)
