


if __name__ == "__main__":
    n,m = (int(x) for x in input().split())
    d = dict()
    pos = True
    for _ in range(m):
        a,b = (int(x) for x in input().split())
        if a in d and d.get(a) != b:
            pos = False
        else:
            d[a] = b
    if d.get(1) == 0 and n != 1:
        pos = False
    ans = []
    for i in range(1,n+1):
        if d.get(i):
            ans.append(d.get(i))
        else:
            ans.append(1 if i == 1 else 0)
    if not pos:
        print(-1)
    else:
        print("".join( map(str,ans) ))
    
    
