import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

N, M = map(int, input().split())

ans = [-1] * N
for i in range(M):
    s, c = map(int, input().split())
    if ans[s - 1] > -1 and ans[s - 1] != c:
        print(-1)
        exit()
    ans[s - 1] = c

if ans[0] == 0:
    print(-1)
    exit()

ans = list(map(lambda x: str(x) if x != -1 else str(0), ans))
if ans[0] == '0':
    ans[0] = '1'
ans = "".join(ans)
print(ans)


