n, m = map(int, input().split())
dic = {i: -1 for i in range(1, n + 1)}
for _ in range(m):
    s_, c_ = map(int, input().split())
    if dic[s_] == -1:
        dic[s_] = c_
    else:
        if dic[s_] != c_:
            print(-1)
            exit()
res = ""
if dic[1] == 0:
    print(-1)
    exit()
for k in dic.keys():
    if dic[k] == -1:
        if k == 1:
            res += "1"
        else:
            res += "0"
    else:
        res += str(dic[k])
print(res)