n,m = map(int, input().split())
nums = {}
flg = False
for i in range(m):
    key,val = input().split()
    if key in nums.keys() and val != nums[key]:
        flg = True
        break
    else:
        nums[key] = val

if flg:
    print(-1)
else:
    output = ""
    for i in range(1, n + 1):
        if i == 1 and n > 1:
            nums.setdefault(str(i), "1")
        else: 
            nums.setdefault(str(i), "0")
        output = output + nums.get(str(i))
    print(output)