def main():
    n, m = map(int, input().split())
    nums = [10]*n
    result = None
    for _ in range(m):
        s, e = map(int, input().split())
        if nums[s-1] == 10:
            nums[s - 1] = e
        else:
            if nums[s - 1] != e:
                result = '-1'
                break

    for i in range(n):
        if i == 0 and nums[i] == 10:
            nums[i] = 1
        elif nums[i] == 10:
            nums[i] = 0

    if result == '-1':
        print('-1')
    elif nums[0] == 0:
        print('-1')
    else:
        print(''.join(map(str, nums)))


if __name__ == "__main__":
    main()
