n, m = map (int, input().split(" "))
datalist = [-1 for i in range(n)]
result = 99999
for i in range(m):
    keta, value = map (int, input().split(" "))
    if(datalist[keta-1] == -1 or datalist[keta-1] == value):
        datalist[keta-1] = value
    else:
        result = -1

for i in range(n):
    if datalist[i] == -1:
        if(i == 0):
            datalist[i] = 1
        else:
            datalist[i] = 0
if datalist[0] == 0:
    result = -1

if(result == -1):
    print(-1)
else:
    result = 0
    for i in range(n):
        result = result + datalist[n-i-1]*(10**i)
    print(result)