if __name__ == '__main__':
    n, m = map(int, input().split())
    ans = [-1]*n
    ansstr =""

    for i in range(m):
        b, c = map(int, input().split())
        if n >1 and b ==1 and c ==0:
            ansstr = "-1"
            break
        elif ans[b-1] != c and ans[b-1] >-1:
            ansstr = "-1"
            break
        else:
            ans[b-1]= c
    if ansstr == "":
        for i in range(n):
            if ans[i] == -1:
                if i == 0:
                    ansstr = ansstr + "1"
                else:
                    ansstr = ansstr + "0"
            else:
                ansstr = ansstr + str(ans[i])
    print(ansstr)
