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

if (n == 1 and m == 0):

    print((0))

    exit()

if (m == 0):

    print(('1' + '0' * (n - 1)))

    exit()

dic = {}

for i in range(m):

    s, c = list(map(int, input().split()))

    try:

        _ = dic[s]

    except KeyError:

        if (s == 1 and c == 0 and n >= 2):

            print((-1))

            exit()

        dic[s] = c

    else:

        if (dic[s] != c):

            print((-1))

            exit()



ok = False

if (n == 1):

    start = 0

else:

    start = 10 ** (n - 1)

for i in range(start, 10 ** n):

    for k, v in list(dic.items()):

        if (str(i)[k - 1] == str(v)):

            ok = True

        else:

            ok = False

            break

    else:

        if (ok):

            print(i)

            exit()

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

if (n == 1 and m == 0):

    print((0))

    exit()

if (m == 0):

    print(('1' + '0' * (n - 1)))

    exit()

dic = {}

for i in range(m):

    s, c = list(map(int, input().split()))

    try:

        _ = dic[s]

    except KeyError:

        if (s == 1 and c == 0 and n >= 2):

            print((-1))

            exit()

        dic[s] = c

    else:

        if (dic[s] != c):

            print((-1))

            exit()



ok = False

if (n == 1):

    start = 0

else:

    start = 10 ** (n - 1)

for i in range(start, 10 ** n):

    for k, v in list(dic.items()):

        if (str(i)[k - 1] != str(v)):

            break

    else:

        print(i)

        exit()

n, m = list(map(int, input().split()))
if n == 1 and m == 0:
    print((0))
    exit()
if m == 0:
    print(("1" + "0" * (n - 1)))
    exit()
dic = {}
for i in range(m):
    s, c = list(map(int, input().split()))
    try:
        _ = dic[s]
    except KeyError:
        if s == 1 and c == 0 and n >= 2:
            print((-1))
            exit()
        dic[s] = c
    else:
        if dic[s] != c:
            print((-1))
            exit()
ok = False
if n == 1:
    start = 0
else:
    start = 10 ** (n - 1)
for i in range(start, 10**n):
    for k, v in list(dic.items()):
        if str(i)[k - 1] == str(v):
            ok = True
        else:
            ok = False
            break
    else:
        if ok:
            print(i)
            exit()

n, m = list(map(int, input().split()))
if n == 1 and m == 0:
    print((0))
    exit()
if m == 0:
    print(("1" + "0" * (n - 1)))
    exit()
dic = {}
for i in range(m):
    s, c = list(map(int, input().split()))
    try:
        _ = dic[s]
    except KeyError:
        if s == 1 and c == 0 and n >= 2:
            print((-1))
            exit()
        dic[s] = c
    else:
        if dic[s] != c:
            print((-1))
            exit()
ok = False
if n == 1:
    start = 0
else:
    start = 10 ** (n - 1)
for i in range(start, 10**n):
    for k, v in list(dic.items()):
        if str(i)[k - 1] != str(v):
            break
    else:
        print(i)
        exit()

-        if str(i)[k - 1] == str(v): -            ok = True -        else: -            ok = False +        if str(i)[k - 1] != str(v): -        if ok: -            print(i) -            exit() +        print(i) +        exit()