import sys
from io import StringIO
import unittest

def resolve():
    n, m=list(map(int,input().strip().split()))

    res=[-1 for i in range(n)]

    for i in range(m):
        s,c = list(map(int,input().strip().split()))
        s-=1
        if res[s] == -1:
            res[s]=c
        elif res[s] != c:
            print("-1")
            return

    h=0
    for i in range(n):
        if res[i]==-1:
            if h==0:
                res[i]=1
                h=1
            else:
                res[i]=0
        else:
            h=1
    if res[0]==0:
            print("-1")
            return

    r=""
    for i in range(n):
        r+=str(res[i])
    print(r)
    return

resolve()