#!/usr/bin/env python3

N,M = map(int, input().split())
from collections import defaultdict
d = defaultdict(int)
S = [1]+[0]*(N-1)
for i in range(M):
    s,c = map(int, input().split())
    s -= 1
    if d[s] > 0 and S[s] != c:
        print(-1)
        exit()
    S[s] = c
    d[s] += 1
if S[0] == 0:
    print(-1)
    exit()
if len(S) == 1:
    print("".join([str(s) for s in S]))
else:
    if d[s] == 0:
        x = [1]+[0]*(N-1)
        ans = "".join([str(_) for _ in x])
        print(ans)
    else:
        print("".join([str(s) for s in S]))
