#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)


def solve(N: int, M: int, s: "List[int]", c: "List[int]"):
    ans=[-1]*N
    dame=False
    for i in range(M):
        if s[i]==1 and c[i]==0: dame=True
        if ans[s[i]-1]!=-1 and ans[s[i]-1]!=c[i]: dame=True
        ans[s[i]-1]=c[i]
    for i in range(N):
        if ans[i]==-1:
            if i==0: ans[i]=1
            else: ans[i]=0
        
    print(-1 if dame else "".join(map(str,ans)))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    s = [int()] * (M)  # type: "List[int]"
    c = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        s[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M, s, c)

if __name__ == '__main__':
    main()
