# coding: utf-8
import math
from collections import deque
#n = int(input())
n, m = map(int,input().split())
#A = list(map(int,input().split()))
ans = 0
F = [False] * n
A = [1] + [0] * (n-1)
flg=True
for i in range(m):
    s, c = map(int,input().split())
    if F[s-1] and A[s-1]!=c:
        flg=False
        break
    else:
        A[s-1] = c
        F[s-1]=True
for i in range(n):
    A[i]=str(A[i])
if flg:
    if n!=1 and m==1 and s==1 and c==0:
        print(-1)
    else:
        print(''.join(A))
else:
    print(-1)