import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd

sys.setrecursionlimit(10**7)
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

MAX = 10**(N)-1
MIN = 10**(N-1)
for num in range(MIN, MAX+1):
    strnum = str(num)
    for sci in sc:
        s, c = sci[0], sci[1]
        if strnum[s-1] != str(c):
            break
    else:
        print(num)
        exit()
else:
    print(-1)
