def f(i, qs):

    ss = str(i)

    for s, c in qs:

        if ss[s-1] != c:

            return False

    return True



def main():

    N, M = list(map(int, input().split()))

    qs = []

    for _ in range(M):

        s, c = input().split()

        qs.append((int(s), c))



    if N == 1:

        if f(0, qs):

            return 0

    for i in range(10**(N-1), 10**N):

        if f(i, qs):

            return i

    return -1



print((main()))

def check(i):

    for s, c in qs:

        if i[s-1] != str(c):

            return False

    return True



N, M = list(map(int, input().split()))

qs = []

for _ in range(M):

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

    qs.append((s,c))



for i in range(0 if N==1 else 10**(N-1), 10**N):

    i = str(i)

    if check(i):

        print(i)

        break

else:

    print((-1))

def f(i, qs):
    ss = str(i)
    for s, c in qs:
        if ss[s - 1] != c:
            return False
    return True


def main():
    N, M = list(map(int, input().split()))
    qs = []
    for _ in range(M):
        s, c = input().split()
        qs.append((int(s), c))
    if N == 1:
        if f(0, qs):
            return 0
    for i in range(10 ** (N - 1), 10**N):
        if f(i, qs):
            return i
    return -1


print((main()))

def check(i):
    for s, c in qs:
        if i[s - 1] != str(c):
            return False
    return True


N, M = list(map(int, input().split()))
qs = []
for _ in range(M):
    s, c = list(map(int, input().split()))
    qs.append((s, c))
for i in range(0 if N == 1 else 10 ** (N - 1), 10**N):
    i = str(i)
    if check(i):
        print(i)
        break
else:
    print((-1))

-def f(i, qs): -    ss = str(i) +def check(i): -        if ss[s - 1] != c: +        if i[s - 1] != str(c): -def main(): -    N, M = list(map(int, input().split())) -    qs = [] -    for _ in range(M): -        s, c = input().split() -        qs.append((int(s), c)) -    if N == 1: -        if f(0, qs): -            return 0 -    for i in range(10 ** (N - 1), 10**N): -        if f(i, qs): -            return i -    return -1 - - -print((main())) +N, M = list(map(int, input().split())) +qs = [] +for _ in range(M): +    s, c = list(map(int, input().split())) +    qs.append((s, c)) +for i in range(0 if N == 1 else 10 ** (N - 1), 10**N): +    i = str(i) +    if check(i): +        print(i) +        break +else: +    print((-1))