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



condition = set()

for i in range(M):

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

    condition.add((s, c))



ans = float("inf")

if N == 1:

    for i in range(10):

        num = str(i)

        for s, c in condition:

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

                break

        else:

            print(i)

            exit()       



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

    num = str(i)

    for s, c in condition:

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

            break

    else:

        print(i)

        exit()

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



condition = set()

for i in range(M):

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

    condition.add((s, c))



ans = float("inf")

if N == 1:

    for i in range(10):

        num = str(i)

        for s, c in condition:

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

                break

        else:

            print(i)

            exit()       

else:

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

        num = str(i)

        for s, c in condition:

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

                break

        else:

            print(i)

            exit()

print((-1))
N, M = list(map(int, input().split()))
condition = set()
for i in range(M):
    s, c = list(map(int, input().split()))
    condition.add((s, c))
ans = float("inf")
if N == 1:
    for i in range(10):
        num = str(i)
        for s, c in condition:
            if num[s - 1] != str(c):
                break
        else:
            print(i)
            exit()
for i in range(10 ** (N - 1), 10**N):
    num = str(i)
    for s, c in condition:
        if num[s - 1] != str(c):
            break
    else:
        print(i)
        exit()
print((-1))

N, M = list(map(int, input().split()))
condition = set()
for i in range(M):
    s, c = list(map(int, input().split()))
    condition.add((s, c))
ans = float("inf")
if N == 1:
    for i in range(10):
        num = str(i)
        for s, c in condition:
            if num[s - 1] != str(c):
                break
        else:
            print(i)
            exit()
else:
    for i in range(10 ** (N - 1), 10**N):
        num = str(i)
        for s, c in condition:
            if num[s - 1] != str(c):
                break
        else:
            print(i)
            exit()
print((-1))

-for i in range(10 ** (N - 1), 10**N): -    num = str(i) -    for s, c in condition: -        if num[s - 1] != str(c): -            break -    else: -        print(i) -        exit() +else: +    for i in range(10 ** (N - 1), 10**N): +        num = str(i) +        for s, c in condition: +            if num[s - 1] != str(c): +                break +        else: +            print(i) +            exit()