# abc157 c
def ans():
    n, m = [int(i) for i in input().split()]
    if n < m:
        print('-1')
        return 
    digit_dict = {}
    for _ in range(m):
        s, c = [int(i) for i in input().split()]
        if s not in digit_dict:
            digit_dict[s] = c
            continue
        elif digit_dict[s] != c:
            print('-1')
            return

    a = ['1']
    for i in range(n-1):
        a.append('0')
    for i, v in digit_dict.items():
        a[i-1] = str(v)
    if a[0] == '0' and n>=2:
        print('-1')
        return
    print(''.join(a))

if __name__ == '__main__':
    ans()