n,m =map(int, input().split())
s_list = [list(input().split()) for _ in range(m)]
num = ['x']*n
flag = 0
for s in s_list:
    if num[int(s[0])-1] == 'x' or num[int(s[0])-1] == s[1]:
        num[int(s[0])-1] = s[1]
    else:
        flag =1
        break
if flag:
    print(-1)
else:
    if num[0] == '0':
        if num == '0':
            print(0)
        else:
            print(-1)
    else:
        for i in range(len(num)):
            if num[i] == 'x':
                if i == 0:
                    num[i] = '1'
                else:
                    num[i] = '0'
        print(''.join(num))