#C
n,m=map(int,input().split())
a_list=[0]*n
for i in range(m):
    s,c=map(int,input().split())
    a_list[s-1]=c
if a_list[0]==0:
    print('-1')
else:
    map = map(str, a_list)
    print(''.join(map))