n, m = map(int, input().split())
nList = ['*'] * n
flag = True
for i in range(m):
    s, c = map(int, input().split())
    if nList[s-1] == '*':
        nList[s-1] = str(c)
    elif nList[s-1] != str(c):
        flag = False
        break
if nList[0] == '0' and n > 2:
    flag = False
if flag:
    for i, num in enumerate(nList):
        if num == '*':
            if i == 0 and n > 2:
                nList[i] = '1'
            else:
                nList[i] = '0'
    print(''.join(nList))
else:
    print('-1')