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

    for i in range(n):
        if nums[i] == 10:
            nums[i] = 0
    if nums[0] == 0:
        result = '-1'
    else:
        result = ''.join(map(str, nums))
    print(result)


if __name__ == "__main__":
    main()
