#!/usr/bin/env python3
N, M = map(int, input().split())
ans = [None] * N
flag = True
for i in range(M):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] == None:
        ans[s] = str(c)
    elif ans[s] != str(c):
        flag = False
if flag == False or ans[0] == str(0):
    print(-1)
    exit()
for i in range(N):
    if ans[i] == None:
        ans[i] = str(0)
    if (i == 0 and ans[0] == str(0)):
        ans[0] = str(1)
print(''.join(ans))