import sys

N,M = map(int, input().split())
S = ["0"]*N
Table = [-1]*N

for _ in range(M):
    s,c = input().split()
    S[int(s)-1]=c
    Table[int(s)-1] = 0

for i in range(N):
    if Table[i]==-1:
        S[i]="0"

if S[0]!="0":
    s = ""
    for i in range(N):
        s = s + S[i]
    print(int(s))
    sys.exit()
print(-1)