n, m = map(int, input().split())
ans = ["O"]*n
data = ""
for i in range(m):
    a, b = map(int, input().split())
    if(ans[a-1] != "O" and int(ans[a-1]) != b):print(-1);exit()
    if(a == 1 and b== 0 and n!=1):print(-1);exit()
    ans[a-1] = str(b)
if(ans[0] == "O"):ans[0] = "1"
for i in ans:
    if(i=='O'):data+="0"
    else:data+=i
print(data)