#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    n,m=map(int,input().split())
    ans=[-1 for i in range(n)]
    num=0
    for i in range(m):
        s,c=map(int,input().split())
        if ans[s-1]!=-1 and ans[s-1]!=c:
            num=-1
        else:
            ans[s-1]=c
    if ans[0]<=0:
        num=-1
    else:
        for i in range(n):
            if ans[i]==-1 and i>0:
                ans[i]=0
            if ans[i]==-1 and i==0:
                ans[i]=1
    if num==-1:
        print(-1)
    else:
        print("".join(map(str,ans)))
if __name__ == "__main__":
    main()