import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N, M = map(int, input().split())
    sc = [list(map(int,input().split())) for _ in range(M)]
    # print(N)
    # print(M)
    # print(sc)
    start = 10 ** (N-1)
    end = 10 ** (N)
    for i in range(start, end):
        string_i = str(i)
        # print(string_i)
        for s,c in sc:
            # print(string_i[s-1])
            if string_i[s-1] != str(c):
                break 
        else:
            print(i)
            return
    print(-1)

if __name__ == "__main__":
    main()