#python3
INF = 100

def main():
    n, m = map(int, input().split())
    d = []
    for _ in range(m):
        x, y = map(int, input().split())
        d.append((x-1, y))
    
    g = [INF for _ in range(n)]

    for i in d:
        if (i[0] == 0) and (i[1] == 0):
            print(-1)
            return
        if g[i[0]] == INF:
            g[i[0]] = i[1]
        if (g[i[0]] != INF) and (g[i[0]] != i[1]):
            print(-1)
            return

    if g[0] == INF:
        g[0] == 1
    
    for i in range(n):
        if i > 0:
            if g[i] == INF:
                g[i] = 0

    ans = []
    for i in range(n):
        ans.append(str(g[i]))
    print(''.join(ans)) 

main()
