#coding:utf-8

def main():
    n, m = map(int, input().split())
    nums = [-1 for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        if nums[a - 1] != -1 and nums[a - 1] != b:
            print('-1')
            return
        nums[a - 1] = b
    if nums[0] == 0:
        print('-1')
        return
    for i in range(n):
        if nums[i] == -1:
            nums[i] = 0
    
    if nums[0] == 0:
        nums[0] = 1
    print(''.join([str(num) for num in nums]))

if __name__ == '__main__':
    main()
