# -*- coding: utf-8 -*-
n,m = list(map(int,input().split()))
sc = [input().split() for i in range(m)]
def main():
    ret = -1
    for i in range(10**(n-1),10**n):
        flg = True
        i=str(i)
        for s,c in sc:
            s = int(s)
            if i[s-1]!=c:
                flg = False
                break
        if flg:
            ret = i
            return ret
    return ret

if __name__ == '__main__':
    print(main())

