# coding: UTF-8
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    s,c=[0]*M,[0]*M
    d={}
    for i in range(M):
        s,c=map(int,input().split())
        if s in d:
            if c!=d[s]:
                print(-1)
                exit()
        else:
            d[s]=c
    if N!=1 and d[1]==0:
        print(-1)
        exit()
    ans=''
    for i in range(1,N+1):
        if i in d:
            ans+=str(d[i])
        else:
            if i==0:
                ans+='1'
            else:
                ans+='0'
    print(ans)

    

if __name__ == '__main__':
    main()
