import sys
input = sys.stdin.readline


def main():
    N, M = map(int, input().split())
    l = [tuple(map(int, input().split())) for _ in range(M)]
    l = list(set(l))
    ans = [1] + [0] * (N - 1)
    s_num = []
    for s, c in l:
        s -= 1
        if s in s_num:
            print(-1)
            exit()
        if s == 0 and c == 0:
            print(-1)
            exit()
        s_num.append(s)
        ans[s] = c
    print(*ans, sep='')



if __name__ == '__main__':
    main()