def main():
    N, M = list(map(int, input().split()))
    c = []
    for _ in range(M):
        ci = list(map(int, input().split()))
        c.append(ci)
    
    num = -1
    for i in range(10 ** (N - 1), 10 ** N):
        s = str(i)

        cnt = 0
        for ci in c:
            if int(s[ci[0] - 1]) == ci[1]:
                cnt += 1
        
        if cnt == M:
            num = i
            break
    print(num)
            
        

if __name__ == "__main__":
    main()
