#coding:utf-8

def main():
    n, m = map(int, input().split())
    cases = []
    for _ in range(m):
        cases.append(list(map(int, input().split())))
    
    for i in range(10 ** (n-1), 10 ** n):
        strnum = str(i)
        for case in cases:
            if case[1] != int(strnum[case[0] - 1]):
                break
        else:
            print(strnum)
            return
    else:
        print(-1)

if __name__ == '__main__':
    main()
