import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
from functools import lru_cache
INF = 1 << 60

#ここから書き始める
n, m = map(int, input().split())
num = [-1 for i in range(n)]
if n == 1:
    for i in range(m):
        s, c = map(int, input().split())
        if num[s - 1] != -1 and num[s - 1] != c:
            print(-1)
            sys.exit()
        num[s - 1] = c
    print(str(num[0]))
else:
    for i in range(m):
        s, c = map(int, input().split())
        if s == 1 and c == 0:
            print(-1)
            sys.exit()
        if num[s - 1] != -1 and num[s - 1] != c:
            print(-1)
            sys.exit()
        num[s - 1] = c
    # print(num)
    ans = ""
    for i in range(n):
        if num[i] != -1:
            ans += str(num[i])
        else:
            if i == 0:
                ans += "1"
            else:
                ans += "0"
    print(ans)
