N, M = map(int, input().split())

s_c_dict = {}

for i in range(M):
    s, c = map(int, input().split())
    if N != 1 and s == 1 and c == 0:
        print("-1")
        exit()
    if s in s_c_dict and s_c_dict[s] != c:
        print("-1")
        exit()

    s_c_dict[s] = c

ans = ""
for i in range(1, N+1):
    if i in s_c_dict:
        ans += str(s_c_dict[i])
    elif i == 1:
        ans += "1"
    else:
        ans += "0"
print(int(ans))