
def solve():
    n,m = map(int,input().split())
    ans = [None for _ in range(n)]
    for _ in range(m):
        s,c = map(int,input().split())
        if s == 1 and c == 0:#左から一桁めが0のとき
            print(-1)
            return

        if ans[s-1] != None and ans[s-1] != c:#既に値が決まっている桁を再更新する時:
            print(-1)
            return

        ans[s-1] = c


    if ans[0] == None:
        ans[0] = 1
    
    for i in range(1,n):
        if ans[i] == None:
            ans[i] = 0

    print("".join(map(str,ans)))


if __name__ == "__main__":
    solve()

