import numpy as np
def getLine():
    return list(map(int, input().split()))
n,m = getLine()
r = np.full(n,-1,dtype=int)
for i in range(m):
    a,b = getLine()
    
    if r[a - 1] == -1:
        r[a - 1] = b
    elif r[a - 1] != b:
        print(-1)
        break
else:
    if (n == 1 and r[0] < 0):
        print(-1)
    else:
        if r[0] == 0 and n == 1:
            print('0')
        else:
            if n > 1 and r[0] == -1:
                r[0] = 1
            r[r == -1] = 0
            r = r.astype(str)
            print(''.join(r))