N, M = map(int, input().split())
sc = [[int(i) for i in input().split()] for i in range(M)]

if [1, 0] in sc:
    print(-1)
else:
    check = []
    sc1 = [i for i in sc if i not in check and not check.append(i)]
    s_list = []
    for i in range(len(sc1)):
        s_list.append(sc1[i][0])
    if len(s_list) != len(set(s_list)):
        print(-1)
    else:
        ans = list('1' + '0' * (N-1))
        for s, c in sc:
            ans[s - 1] = str(c)
        print(''.join(ans))