import math
def main():
    N, M = map(int, input().split())

    ans = {i:0 for i in range(N)}
    for _ in range(M):
        s, c = map(int, input().split())

        ans[s-1] = c
    if ans[0] == 0:
        print(-1)
        return 0

    for v in ans.values():
        print(v, end="")




    return 0
if __name__ == '__main__':
    main()