N,M = map(int,input().split())
sc = [list(map(int,input().split())) for i in range(M)]

dic = {}
dic2= {}
try:
    for i in range(N):
        dic[i] = 0
    for i in sc:
        if (i[0]-1 not in dic2.keys()):
            dic2[i[0]-1] = i[1]
        elif (i[0]-1 in dic2.keys()) and (i[1] != dic2[i[0]-1]):
            raise ValueError("error!")
            
    if (N > 1) and (0 in dic2) and (dic2[0] == 0):
        raise ValueError("error!")

    dic.update(dic2)
    
    s = ''
    for v in dic.values():
        s += str(v)
    if s[0] == '0':
        s = s.replace('0','1',1)
    print(s)

except ValueError as e:
    print(-1)