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

for i in range(n):
    if i not in dic.keys():
        dic[i] = 0

if ans == -1:
    print('-1')
    exit()
if dic[0] ==0:
    dic[0] = 1
ls = []
for i in range(n):
    ls.append(str(dic[i]))
ans = ''.join(ls)
print(ans)