import sys
import math
import copy
import queue
input = sys.stdin.readline
n,m = map(int,input().split())
ans = list('0' * n)
for _ in range(m):
    s,c = input().split()
    ans[int(s)-1] = c

if ans[0] == '0':
    print (-1)
else:
    print (''.join(ans))