


def solve():
    ans = ["0"]*len(s)
    ans[0] = "1"
    for i in range(len(s)):
        a = ((s[i]== 1) and c[i]==0)
        b = False
        for j in range(len(s)):
            b = b or (s[i] == s[j] and (not i==j) and not c[i]==c[j])
        if a or b:
            print(-1)
            exit()
        ans[s[i]-1] = str(c[i])
    ans = "".join(ans)
    print(ans)



    return




n, m = [int(s) for s in input().split(" ")]
s = []
c = []
for i in range(m):
    si, ci = [int(s) for s in input().split(" ")]
    s.append(si)
    c.append(ci)
solve()
