n, m = map(int, input().split())
arr = [input().split() for _ in range(m)]

for x in range(10**(n-1), 10**n):
    num = str(x)
    for s, c in arr:
        if num[int(s)-1] != c:
            break
    else:
        print(num)
        break
else:
    print(-1) 