#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6+1)
input=stdin.readline

n,m=map(int,input().split())
ans=["" for _ in range(n)]
for _ in range(m):
    s,c=map(int,input().split())
    if ans[s-1]==c:
        continue
    elif ans[s-1]=="":
        ans[s-1]=c
    else:
        print(-1)
        exit()
if ans[0]==0:
    print(-1)
    exit()
for i in range(n):
    if ans[i]=="":
        ans[i]=1
print("".join(map(str,ans)))