import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

N, M = list(map(int, sys.stdin.buffer.readline().split()))
SC = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]

ans = 10 ** (N - 1)
E = 10 ** N


def test(n):
    ok = True
    ok &= len(str(n)) == N
    for s, c in SC:
        ok &= str(n)[s - 1] == str(c)
    return ok


i = 0
for i in range(10 ** (N - 1), 10 ** N):
    if test(i):
        print(i)
        exit()
print(-1)
