N,M = input().split(' ')
numlist = []
for i in range(int(N)):
    numlist.append('0')
for i in range(int(M)):
    S,C = input().split(' ')
    numlist[int(S)-1] = C
num = ''.join(numlist)
num = int(num)
if int(N) == 1:
    if len(str(num)) == int(N):
        print(int(num))
    else:
        print(0)
else:
    if len(str(num)) == int(N):
        print(int(num))
    else:
        print(-1)
    