def main():
    n, m = map(int, input().split())
    sc = [list(map(int, input().split())) for _ in range(m)]
    
    sc = sorted(sc)
    ans = ''
    pre_s =  -1
    pre_c = sc[0][1]
    for s, c  in sc:
        if pre_s == s and pre_c == c:
            continue
        if (s == 1 and c == 0) or (pre_s == s and pre_c != c):
            print('-1')
            return
        if pre_s == -1 and s != 1:
            ans += str(1)
            pre_s += 2
        i = s - pre_s - 1
        ans += str(0) * i
        ans += str(c)
        pre_s = s
        pre_c = c
    ans += str(0) * (n - pre_s)
        
    print(int(ans))
    
if __name__ == '__main__':
    main()