#!/usr/bin/python
# -*- coding: utf-8 -*-

# 入力はstringで入る．
# intにしたければ int(input())
# floatで受け取ると 1.0 になる．

import numpy as np

# 入力
N,M = map(int,input().split())

SC = [list(map(int,input().split())) for l in range(M)]

L = np.zeros((10,N,))
counter = 0

if [1,0] in SC:
    print(-1)
else:

    if N > 1:
        for i in range(M):
            L[SC[i][1],SC[i][0]-1] = SC[i][1]

        for k in range(N-1):
            if np.count_nonzero(L[:,N-1-k] > 0) > 1:
                counter = -1
                
        if np.count_nonzero(L[:,0] > 0) > 1:
            counter = -1
        elif np.count_nonzero(L[:,0] > 0) == 0:
            L[1,0] = 1

        if counter == -1:
            print(-1)
        else:
            print("".join([str(int(k)) for k in list(np.sum(L,axis=0))]))

    else:
        if np.count_nonzero(L[:,0] > 0) > 1:
            counter = -1

        if counter == -1:
            print(-1)
        else:
            print(int(np.sum(L,axis=0))))



