N,M=map(int,input().split())

base =['0']*N

for i in range(M):
    s_i,c_i =map(int,input().split())

    base[s_i-1]=str(c_i)

str_num = "".join(base)

if str_num[0]=='0':
    print(-1)
else:
    print(int(str_num))