import numpy as np


def main():
    N, M = [int(x) for x in input().split()]
    d = dict()
    for _ in range(M):
        s, c = [int(x) for x in input().split()]
        if s in d and d[s] != c or (s==1 and c==0):
            print(-1)
            return
        d[s] = c
    nums = [0] * N
    for s, c in d.items():
        nums[s-1] = c
    for i in range(min(d.keys())-1):
        nums[i] = 1
    ans = "".join(map(str, nums))
    print(ans)


if __name__ == '__main__':
    main()