#!/usr/bin/env python3
(n, _), *m = [[*map(int, i.split())] for i in open(0)]

a = [0] * n

for s, c in m:
    if s==1 and c==0:
        print(-1)
        exit()
    elif a[s - 1] in (0, c):
        a[s - 1] = c
    else:
        print(-1)
        exit()

if a[0]==0:
    a[0]=1
a = int("".join([*map(str, a)]))
print(a)
