

n, m = map(int, input().split())

digits = {i: None for i in range(n)}
def main():
    string = ""
    for i in range(m):
        s, c = map(int, input().split())
        if digits[s-1] is not None and digits[s-1] != c:
            return -1
        digits[s-1] = c

    for i, d in digits.items():
        if d is not None:
            if i==0 and d == 0:
                if n==1:
                    return 0
                return -1
            string += str(d)
        else:
            if i==0:
                string+= "1"
            else:
                string += "0"
    return int(string)

print(main())

