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

def resolve():
    def main():

        n,m=map(int, input().split())
        l=[list(map(int,input().split())) for i in range(m)]

        for i in range(10**(n-1),10**n):
            flag = True
            for x,y in l:
                z=str(i)
                if int(z[x-1])!=y:
                    flag=False
                    break
            if flag:
                return i

        return -1
    print(main())
resolve()