#  --*-coding:utf-8-*--

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

    X = [None]*N

    for _ in range(M):
        s, c = map(int, input().split())
        s -= 1
        
        if X[s] != None and X[s] != c:
            print(-1)
            return

        X[s] = c

    if X[0] == 0:
        print(-1)
        return

    if X[0] == None:
        X[0] = 1

    for i in range(N):
        if X[i] == None:
            X[i] = 0

    print(''.join(map(str, X)))


main()
