# import math
# import bisect
# import heapq
# from collections import deque
import numpy as np

n,m = map(int,input().split())
s,c = [0] * m, [0] * m
for i in range(m):
    s[i],c[i] = map(int,input().split())

# replace = [False] * n
ans = list('a'* n)

for i in range(m):

    if len(ans) != 1 and s[i] == 1 and c[i] == 0:
        ans = -1
        break
    elif ans[s[i]-1] != 'a' and str(c[i]) != ans[s[i]-1]:
        ans = -1
        break

    ans[s[i]-1] = str(c[i])
if n == 1 and ans[0] == 0: print(0)

elif not ans == -1:

    for i in range(n):
        if i == 0 and ans[i] == 'a': ans[0] = '1'
        elif ans[i] == 'a': ans[i] = '0'

    print(''.join(ans))

elif : print(-1)
