N, M = map(int, input().split())
sc_list = [list(map(int, input().split())) for i in range(M)]

res = [-1 for _ in range(N)]

flg = True
for s, c in sc_list:
    if res[s-1] != -1 and res[s-1] != c:
        flg = False
        break
    res[s-1] = c

if flg:
    if N == 1:
        print(res[0])
    else:
        if res[0] == 0:
            print(-1)
        else:
            for i in range(N):
                if res[i] == -1:
                    if i == 0:
                        res[i] = 1
                    else:
                        res[i] = 0
            print("".join(map(str, res)))
else:
    print(-1)
