from sys import stdin
N,M = [int(x) for x in stdin.readline().rstrip().split()]
data = []
S = []
for i in range(M):
    s,c = [int(x) for x in stdin.readline().rstrip().split()]
    S.append(s)
    data.append((s,c))
ans = ["1"]+["0"]*(N-1)
 
for i,j in sorted(data)[::-1]:
    ans[i-1] = str(j)

if len(S) != len(set(S)):
    print(-1)
else:
    if M == 0:
        if N == 1:
            print(0)
        elif N == 2:
            print(10)
        elif N == 3:
            print(100)
    else:
        if ans[0] == "0" and N != 1:
            print(-1)

        elif ans[0] == "0" and N == 1:
            print(0)

        else:
            print("".join(ans))