# from bisect import bisect_left,bisect_right
# from collections import Counter

# n=int(input())
# s=input()
n,m=map(int,input().split())
cl=[-1]*n
for i in range(m):
    s,c=map(int,input().split())
    if cl[s-1]==-1 or cl[s-1]==c:
        cl[s-1]=c
    else:
        print(-1)
        exit()
if cl[0]==0:
    print(-1)
    exit()
if cl[0]==-1:
    cl[0]=1
for i in range(n):
    if cl[i]==-1:
        cl[i]=0
for i in cl:
    print(i,end="")
    
# h=list(map(int,input().split()))
# l=sorted(list(map(int,input().split())))

