import sys
from bisect import bisect_right as bsr
from collections import Counter as cnt
from collections import defaultdict as dd
from collections import deque
from fractions import gcd
from itertools import combinations as comb
from itertools import permutations as perm
from math import ceil, factorial, floor
from operator import itemgetter as ig
from statistics import mean as avg

sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N, M = input(int, int)
    SC = input([[int, 2], M])

    ans = ["#"] * N
    for s, c in SC:
        if not (ans[s - 1] == "#") and not (ans[s - 1] == str(c)):
            print(-1)
            return
        ans[s - 1] = str(c)
    if ans[0] == "0":
        print(-1)
        return
    ans = "".join(ans)
    print(ans.replace("#", "0"))


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()
