import sys



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



x=[-1]*N

valid=True

for _ in range(M):

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

    if x[s-1]!=-1 and x[s-1]!=c:

        print((-1))

        sys.exit()

    x[s-1]=c



if N>1 and x[0]==0:

    print((-1))

else:

    ans=0

    for i in range(N):

        if x[i]==-1:

            if i>0 or N==1:

                x[i]=0

            else:

                x[i]=1

        ans=ans*10+x[i]

    print(ans)

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



x=[-1]*N

for _ in range(M):

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

    s-=1

    if ((s==c==0 and N>1) or

       x[s]!=-1 and x[s]!=c):

        print((-1))

        exit()

    x[s]=c



if x[0]==-1:

    x[0]=0+(N>1)

for i in range(N):

    if x[i]==-1: x[i]=0



print((''.join(map(str,x))))

import sys

N, M = list(map(int, input().split()))
x = [-1] * N
valid = True
for _ in range(M):
    s, c = list(map(int, input().split()))
    if x[s - 1] != -1 and x[s - 1] != c:
        print((-1))
        sys.exit()
    x[s - 1] = c
if N > 1 and x[0] == 0:
    print((-1))
else:
    ans = 0
    for i in range(N):
        if x[i] == -1:
            if i > 0 or N == 1:
                x[i] = 0
            else:
                x[i] = 1
        ans = ans * 10 + x[i]
    print(ans)

N, M = list(map(int, input().split()))
x = [-1] * N
for _ in range(M):
    s, c = list(map(int, input().split()))
    s -= 1
    if (s == c == 0 and N > 1) or x[s] != -1 and x[s] != c:
        print((-1))
        exit()
    x[s] = c
if x[0] == -1:
    x[0] = 0 + (N > 1)
for i in range(N):
    if x[i] == -1:
        x[i] = 0
print(("".join(map(str, x))))

-import sys - -valid = True -    if x[s - 1] != -1 and x[s - 1] != c: +    s -= 1 +    if (s == c == 0 and N > 1) or x[s] != -1 and x[s] != c: -        sys.exit() -    x[s - 1] = c -if N > 1 and x[0] == 0: -    print((-1)) -else: -    ans = 0 -    for i in range(N): -        if x[i] == -1: -            if i > 0 or N == 1: -                x[i] = 0 -            else: -                x[i] = 1 -        ans = ans * 10 + x[i] -    print(ans) +        exit() +    x[s] = c +if x[0] == -1: +    x[0] = 0 + (N > 1) +for i in range(N): +    if x[i] == -1: +        x[i] = 0 +print(("".join(map(str, x))))