import sys

input = sys.stdin.readline



def main():



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

    Set = []

    for i in range(M):

        Set.append(list(map(int, input().split())))



    for i in range(10**N):

        num = str(i)

        if len(num) == N and all(num[s-1]==str(c) for s,c in Set):

            print(i)

            break

    else:

        print((-1))





if __name__ == '__main__':

    main()
import sys

input = sys.stdin.readline



def main():



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

    Set = [list(map(int,input().split())) for i in range(M)]



    for i in range(10**N):

        num = str(i)

        if len(num) == N and all(num[s-1]==str(c) for s,c in Set):

            print(i)

            break

    else:

        print((-1))





if __name__ == '__main__':

    main()
import sys

input = sys.stdin.readline


def main():
    N, M = list(map(int, input().split()))
    Set = []
    for i in range(M):
        Set.append(list(map(int, input().split())))
    for i in range(10**N):
        num = str(i)
        if len(num) == N and all(num[s - 1] == str(c) for s, c in Set):
            print(i)
            break
    else:
        print((-1))


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    N, M = list(map(int, input().split()))
    Set = [list(map(int, input().split())) for i in range(M)]
    for i in range(10**N):
        num = str(i)
        if len(num) == N and all(num[s - 1] == str(c) for s, c in Set):
            print(i)
            break
    else:
        print((-1))


if __name__ == "__main__":
    main()

-    Set = [] -    for i in range(M): -        Set.append(list(map(int, input().split()))) +    Set = [list(map(int, input().split())) for i in range(M)]