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

for i,j in sorted(data)[::-1]:
    ans[i-1] = str(j)

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))