import sys
import math
# input処理を高速化する
input = sys.stdin.readline

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)

int_num = int("".join(base))

if len(str(int_num))<N:
    print(-1)
else:
    print(int_num)