#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-03-23 16:24:22 +0900
# LastModified: 2020-03-24 15:11:24 +0900
#


import os
import sys


def main():
    inf=10
    N, M = map(int, input().split())
    keta = [inf]*N
    for _ in range(M):
        s,c = map(int, input().split())
        if keta[s-1]>c:
            keta[s-1]=c
#    keta_list=[map(int,input().split()) for _ in range(M)]
    for i in range(len(keta)):
        if i==0 and keta[i]==10:
            print(-1)
            return
        elif i==0 and keta[i]==0:
            print(-1)
            return 
        if keta[i] == 10:
            print(0,end="")
        else:
            print(keta[i],end="")
    print()

if __name__ == "__main__":
    main()
