import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,M = map(int, readline().split())

    ans = [None]*N
    for i in range(M):
        s, c = map(int, readline().split())
        if ans[s-1] is None:
            ans[s-1] = c
        elif c == ans[s-1]:
            continue        
        else:
            print(-1)
            exit()
    
    if ans[0] is None:
        ans[0] = 1
    if ans[1] is None:
        ans[1] = 0
    if ans[2] is None:
        ans[2] = 0

    if N >= 2 and ans[0] == 0:
        print(-1)
        exit()

    print("".join(map(str,ans)))

if __name__ == "__main__":
    main()
