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

digits = [-1]*n

for _ in range(m):

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

    s -= 1

    if digits[s] == -1 or digits[s] == c:

        digits[s] = c

    else:

        print((-1))

        break

else:

    if n == 1:

        print((0 if digits[0] == -1 else digits[0]))

    else:

        if digits[0] == 0:

            print((-1))

        else:

            ans = ''

            for i, d in enumerate(digits):

                if i == 0 and d == -1:

                    ans += '1'

                elif i > 0 and d == -1:

                    ans += '0'

                else:

                    ans += str(d)

            print(ans)

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

sc = []

for _ in range(m):

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

    s -= 1

    sc.append((s, c))



for nn in range(10**n):

    sn = str(nn)

    if len(sn) != n:

        continue

    for s, c in sc:

        if int(sn[s]) != c:

            break

    else:

        print(nn)

        break

else:

    print((-1))
n, m = list(map(int, input().split()))
digits = [-1] * n
for _ in range(m):
    s, c = list(map(int, input().split()))
    s -= 1
    if digits[s] == -1 or digits[s] == c:
        digits[s] = c
    else:
        print((-1))
        break
else:
    if n == 1:
        print((0 if digits[0] == -1 else digits[0]))
    else:
        if digits[0] == 0:
            print((-1))
        else:
            ans = ""
            for i, d in enumerate(digits):
                if i == 0 and d == -1:
                    ans += "1"
                elif i > 0 and d == -1:
                    ans += "0"
                else:
                    ans += str(d)
            print(ans)

n, m = list(map(int, input().split()))
sc = []
for _ in range(m):
    s, c = list(map(int, input().split()))
    s -= 1
    sc.append((s, c))
for nn in range(10**n):
    sn = str(nn)
    if len(sn) != n:
        continue
    for s, c in sc:
        if int(sn[s]) != c:
            break
    else:
        print(nn)
        break
else:
    print((-1))

-digits = [-1] * n +sc = [] -    if digits[s] == -1 or digits[s] == c: -        digits[s] = c +    sc.append((s, c)) +for nn in range(10**n): +    sn = str(nn) +    if len(sn) != n: +        continue +    for s, c in sc: +        if int(sn[s]) != c: +            break -        print((-1)) +        print(nn) -    if n == 1: -        print((0 if digits[0] == -1 else digits[0])) -    else: -        if digits[0] == 0: -            print((-1)) -        else: -            ans = "" -            for i, d in enumerate(digits): -                if i == 0 and d == -1: -                    ans += "1" -                elif i > 0 and d == -1: -                    ans += "0" -                else: -                    ans += str(d) -            print(ans) +    print((-1))