N, M = [int(i) for i in input().split(" ")]
conds = []
for _ in range(M):
    conds.append([int(i) for i in input().split(" ")])

# 0の場合に注意

exists = True
A = [None for _ in range(N)]
for s, c in conds:
    idx = s-1
    if A[idx] != None and A[idx] != c:
        exists = False
        break
    A[idx] = c


def check():
    if not exists:
        return [-1]

    if N == 1:
        if A[0] == None:
            return [0]
        else:
            return A
    else:
        if A[0] == 0:
            return [-1]

    # 先頭の数値までサーチ
    top_idx = N
    for idx in range(N):
        if A[idx] != None:
            top_idx = idx
            break

    res = []
    for idx in range(N):
        if idx < top_idx:
            if idx == 0:
                res.append(1)
            else:
                res.append(0)
        else:
            if A[idx] == None:
                res.append(0)
            else:
                res.append(A[idx])
    return res


answer = "".join(str(x) for x in check())
if answer == "1":
    print(0)
else:
    print(answer)
