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

RA = ["0"] * N

for _ in range(M):
    s, c = map(int, input().split())
    RA[s - 1] = str(c)

RR = ''.join(RA)

if len(RR) > 1 and RR[0] == '0':
    print('-1')
else:
    print(RR)
