def change(s, c, index):
    return ans[:index-1] + c + ans[index:]

N, M = list(map(int, input().split()))
ans = 'N' * N

for _ in range(M):
    tmp = input().split()
    s = int(tmp[0])
    c = tmp[1]
    if(ans[s-1] != 'N' and ans[s-1] != c):
        ans = '-1'
        break
    ans = change(ans, c, s)

if ans[0] == 'N':
    ans = change(ans, '1', 1)

ans = ans.replace('N', '0')
if ans.count('0') == N:
    ans = '-1'

print(int(ans))