import sys
from math import ceil as C, floor as F, sqrt, gcd as G
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n, m = I()

ans = ['*'] * n
done = False
for _ in range(m):
    s, c = I()
    s -= 1
    
    if ans[s] == '*': 
        ans[s] = str(c)

    if ans[s] != str(c):
        print(-1)
        done = True
        break

if not done and ans[0] == '0':
    print(-1)
    done = True

if not done:
    if ans[0] == '*':
        ans[0] = '1'
    for i in range(1, n):
        if ans[i] == '*':
            ans[i] = '0'
    print(''.join(ans))
        
    
    
