def main():
    n, m = map(int, input().split())
    indic = {}
    for i in range(m):
        s, c = map(int, input().split())
        if s in indic:
            if indic[s] == c:
                pass
            else:
                print(-1)
                exit()
        else:
            indic[s] = c
    ans = ""
    if indic[1] == 0:
        print(-1)
        exit()
    for i in range(n):
        if i+1 in indic:
            ans += str(indic[i+1])
        else:
            if i == 0:
                ans += "1"
            else:
                ans += "0"
    print(ans)


    
    
if __name__ == "__main__":
    main()
