from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n, m = map(int, input().strip().split())
    # 10**n<=x<10**(n+1)-1

    dict_x = {}
    for i in range(m):
        s_temp, m_temp = map(int, input().strip().split())
        s_temp -= 1
        if s_temp in dict_x and dict_x[s_temp] != str(m_temp):
            print(-1)
            return
        else:
            dict_x[s_temp] = str(m_temp)

    for x in range(10**(n-1), 10**(n)):
        S = str(x)
        failure_flag = 0

        # for all i, if i is in dict_x then S[i] == dict_x[i]
        for i in range(n):
            if i in dict_x:
                if S[i] == dict_x[i]:
                    pass
                else:
                    failure_flag = 1

        # 
        if failure_flag == 0:
            print(x)
            return
        else:
            pass

        # reset flags
        failure_flag = 0

    print(-1)
    return


if __name__ == '__main__':
    main()
