from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
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 nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


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

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

    print("".join(ans).replace("x", "0"))


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