from sys import stdin

import sys

import numpy as np

import collections

from functools import cmp_to_key

import heapq

 

##  input functions for me

def rsa(sep = ''):

    if sep == '' :

        return input().split() 

    else: return input().split(sep)

def rip(sep = ''):

    if sep == '' :

        return list(map(int, input().split())) 

    else: return list(map(int, input().split(sep)))

def ria(sep = ''): 

    return list(rip(sep))

def ri(): return int(eval(input()))

def rd(): return float(eval(input()))

def rs(): return eval(input())

##

def main():

    N, M = rip()

    S = [0] * M

    C = [0] * M

    for i in range(M):

        S[i], C[i] = rip()

 

    for i in range(1000):

        s = str(i)

        if len(s) != N: continue

        chk = True

        for j in range(M):

            chk &= s[S[j] - 1] == str(C[j])

        if chk:

            print(i)

            sys.exit(0)

    

    print((-1))

 

 

if __name__ == "__main__":

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

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



for i in range(0, 10**n):

  str_i = str(i)

  if len(str_i) != n: continue



  chk = True

  for s, c in sc:

    chk &= str_i[s-1] == str(c)

  if chk:

    print(i)

    exit()



print((-1))

     

    

  
from sys import stdin
import sys
import numpy as np
import collections
from functools import cmp_to_key
import heapq

##  input functions for me
def rsa(sep=""):
    if sep == "":
        return input().split()
    else:
        return input().split(sep)


def rip(sep=""):
    if sep == "":
        return list(map(int, input().split()))
    else:
        return list(map(int, input().split(sep)))


def ria(sep=""):
    return list(rip(sep))


def ri():
    return int(eval(input()))


def rd():
    return float(eval(input()))


def rs():
    return eval(input())


##
def main():
    N, M = rip()
    S = [0] * M
    C = [0] * M
    for i in range(M):
        S[i], C[i] = rip()
    for i in range(1000):
        s = str(i)
        if len(s) != N:
            continue
        chk = True
        for j in range(M):
            chk &= s[S[j] - 1] == str(C[j])
        if chk:
            print(i)
            sys.exit(0)
    print((-1))


if __name__ == "__main__":
    main()

n, m = list(map(int, input().split()))
sc = [list(map(int, input().split())) for i in range(m)]
for i in range(0, 10**n):
    str_i = str(i)
    if len(str_i) != n:
        continue
    chk = True
    for s, c in sc:
        chk &= str_i[s - 1] == str(c)
    if chk:
        print(i)
        exit()
print((-1))

-from sys import stdin -import sys -import numpy as np -import collections -from functools import cmp_to_key -import heapq - -##  input functions for me -def rsa(sep=""): -    if sep == "": -        return input().split() -    else: -        return input().split(sep) - - -def rip(sep=""): -    if sep == "": -        return list(map(int, input().split())) -    else: -        return list(map(int, input().split(sep))) - - -def ria(sep=""): -    return list(rip(sep)) - - -def ri(): -    return int(eval(input())) - - -def rd(): -    return float(eval(input())) - - -def rs(): -    return eval(input()) - - -## -def main(): -    N, M = rip() -    S = [0] * M -    C = [0] * M -    for i in range(M): -        S[i], C[i] = rip() -    for i in range(1000): -        s = str(i) -        if len(s) != N: -            continue -        chk = True -        for j in range(M): -            chk &= s[S[j] - 1] == str(C[j]) -        if chk: -            print(i) -            sys.exit(0) -    print((-1)) - - -if __name__ == "__main__": -    main() +n, m = list(map(int, input().split())) +sc = [list(map(int, input().split())) for i in range(m)] +for i in range(0, 10**n): +    str_i = str(i) +    if len(str_i) != n: +        continue +    chk = True +    for s, c in sc: +        chk &= str_i[s - 1] == str(c) +    if chk: +        print(i) +        exit() +print((-1))