import sys

sys.setrecursionlimit(10**7)

input = sys.stdin.readline



n,m = list(map(int, input().split()))

sc = [list(map(int, input().split())) for _ in range(m)]



for i in range(1000):

    flag = True

    for s in sc:

        num = str(i)

        if len(num) >= s[0] and str(s[1]) == num[s[0] - 1]:

            continue

        else:

            flag = False

            break

    if flag and len(str(i)) == n:

        print(i)

        exit()



print((-1))

import sys

sys.setrecursionlimit(10**7)

input = sys.stdin.readline



n,m = list(map(int, input().split()))

v = [list(map(int, input().split())) for _ in range(m)]



for i in range(1000):

    flag = True

    num = str(i)

    for sc in v:

        if len(num) >= sc[0] and str(sc[1]) == num[sc[0] - 1]:

            continue

        else:

            flag = False

            break

    if flag and len(num) == n:

        print(i)

        exit()

print((-1))

import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n, m = list(map(int, input().split()))
sc = [list(map(int, input().split())) for _ in range(m)]
for i in range(1000):
    flag = True
    for s in sc:
        num = str(i)
        if len(num) >= s[0] and str(s[1]) == num[s[0] - 1]:
            continue
        else:
            flag = False
            break
    if flag and len(str(i)) == n:
        print(i)
        exit()
print((-1))

import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n, m = list(map(int, input().split()))
v = [list(map(int, input().split())) for _ in range(m)]
for i in range(1000):
    flag = True
    num = str(i)
    for sc in v:
        if len(num) >= sc[0] and str(sc[1]) == num[sc[0] - 1]:
            continue
        else:
            flag = False
            break
    if flag and len(num) == n:
        print(i)
        exit()
print((-1))

-sc = [list(map(int, input().split())) for _ in range(m)] +v = [list(map(int, input().split())) for _ in range(m)] -    for s in sc: -        num = str(i) -        if len(num) >= s[0] and str(s[1]) == num[s[0] - 1]: +    num = str(i) +    for sc in v: +        if len(num) >= sc[0] and str(sc[1]) == num[sc[0] - 1]: -    if flag and len(str(i)) == n: +    if flag and len(num) == n: