import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n, m = map(int,input().split())
    SC = [tuple(map(int,input().split())) for _ in range(m)]
    for i in range(10**n+1):
        i = str(i)
        for s, c in SC:
            s -= 1
            if len(i)!= n: break
            if len(i)<=s: break
            if i[s]!=str(c): break
        else:
            print(i)
            return
    print(-1)
resolve()