#!/usr/bin/env python3
N, M = map(int, input().split())
flag = True
if N == 0 | N == 1:
    ans = [-1]
    for _ in range(M):
        s, c = map(int, input().split())
        if ans[s - 1] != -1 and ans[s - 1] != c:
            flag = False
            break
        ans[s - 1] = c
else:
    ans = [-1 for _ in range(N)]
    for _ in range(M):
        s, c = map(int, input().split())
        if ans[s - 1] != -1 and ans[s - 1] != c:
            flag = False
            break
        ans[s - 1] = c
    if ans[0] == 0:
        flag = False
    for i in range(N):
        if ans[i] == -1:
            if i == 0:
                ans[i] = 1
            else:
                ans[i] = 0
if flag:
    for i in ans:
        print(i, end="")
else:
    print(-1)