if __name__ == '__main__':
    n, m = map(int, input().split())
    scs = [tuple(map(int, input().split())) for _ in range(m)]
    l = [str(e) for e in range(10 ** (n - 1),10 ** n)]
    a = []
    for i in l:
        if max([e[0] for e in scs]) > m:
            continue
        if len([e for e in scs if int(i[e[0]-1]) == e[1]]) == n:
            print(i)
            break
    print(-1)