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