import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,m=map(int, input().split())
    ansl=[0]*(n+1)
    flag=True
    for i in range(m):
        a,b=map(int, input().split())
        if ansl[a]!=0 and ansl[a]!=b:
            print(-1)
            flag=False
        elif a==1 and b==0:
            print(-1)
            flag=False
        else:
            ansl[a]=b
    if flag:
        if ansl[1]==0:
            ansl[1]==1
        ansl=ansl[1:]
        for i in ansl:
            print(i,end='')
        print()
resolve()