import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    ans = [-1] * N
    ok = True
    for i in range(M):
        s, c = map(int, input().split())
        if ans[s-1] != -1 or (N!=1 and c==0):
            ok = False
        ans[s-1] = c
    if ans[0] == -1:
        ans[0] = 1
    for i in range(1, N):
        if ans[i] == -1:
            ans[i] = 0
    
    if ok:
        print("".join(map(str, ans)))
    else:
        print(-1)



if __name__ == "__main__":
    main()