import bisect
import copy
import heapq
import math
import sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(500000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
lst=[-1]*n

for i in range(m):
    s,c=sc[i]
    if lst[s-1]==-1 or lst[s-1]==c:
        lst[s-1]=c
    else:
        print(-1)
        quit()

for i in range(n):
    if i==0:
        if lst[i]==0:
            print(-1)
            quit()
        elif lst[i]==-1:
            lst[i]=1
    elif lst[i]==-1:
        lst[i]=0

print("".join(map(str,lst)))