# -*- coding: utf-8 -*-
"""
Created on Thu May  7 14:36:15 2020

@author: shinba
"""

import sys

N,M = map(int,input().split())
result = {}

for i in range(M):
    s,c = map(int,input().split())
    if s in result:
        if c != result[s]:
            print(-1)
            sys.exit()
    else:
        result[s] = c
        
W = [0]*N
W[0] = 1

for i,j in result.items():
    W[i-1] = j
    
ans = "".join(map(str,W))

if ans == "0" or M == 0:
    print(0)
elif ans[0] == "0":
    print(-1)
else:
    print(ans)



