import sys
sys.setrecursionlimit(1000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import bisect_left, bisect_right
from collections import defaultdict
INF = float("inf")

N, M = map(int, input().split())
num = [-1]*N
flg = 1
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if num[s] == -1:
        num[s] = c
    elif num[s] != c:
        flg = 0
if N == 2:
    if num[0] == 0:
        flg = 0
elif N == 3:
    if num[0] == 0:
        flg = 0
if flg:
    for i in range(N):
        if num[i] == -1:
            if i == 0:
                num[i] = 1
            else:
                num[i] = 0
        print(num[i], end = '')
    print()
else:
    print(-1)
