import sys

N,M=list(map(int,input().split()))
num = [None] * N
for i in range(M):
    s,c=list(input().split())
    if num[int(s)-1] is not None and num[int(s)-1] != c:
        print('-1')
        sys.exit()
    else:
        num[int(s)-1] = c
if N > 1 and num[0] == '0':
    print('-1')
    sys.exit()
else:
    for i in range(N):
        if num[i] == None:
            num[i] = '0' if i > 0 else '1'
print(''.join(num))