def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N, M = getNM()
lista = []
for i in range(M):
    s, c = getNM()
    lista.append([s, c])
ans = -1
for i in range(10 ** (N - 1), 10 ** N):
    if i >= 10 ** N:
        break
    flag = True
    for jud in lista:
        if str(i)[jud[0] - 1] != str(jud[1]):
            flag = False
            break
    if flag:
        ans = i
        break
print(ans)