n, m = map(int,input().split())
dic = {}
ans = 0
for _ in range(m):
    s,c = map(int,input().split())
    if s-1 not in dic.keys():
        dic[s-1] = c
    if s-1 in dic.keys() and dic[s-1] !=c:
        ans = -1
        break
    if s == 1 and c == 0 and n!=1:
        ans = -1
        break
if ans == -1:
    print(ans)
    exit()

if 1 not in dic.keys() and n !=1:
    dic[1] = 0

if 2 not in dic.keys() and n ==3:
    dic[2] = 0  

if 0 not in dic.keys() and not n!=1:
    dic[0] = 1
if 0 not in dic.keys() and not n==1:
    dic[0] = 0
ls = []
for i in range(n):
    ls.append(str(dic[i]))
ans = ''.join(ls)
print(ans)
