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

import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    S = [-1] * (N+1)
    ret = 0
    for i in range(M):
        s, c = map(int, input().split())
        if S[s] != -1 and S[s] != c:
            ret = -1
            break
        elif s==1 and c==0:
            ret = -1
            break
        else:
            S[s] = c
    if ret != -1:
        ret=''
        for i in range(1,N+1):
            if S[i]==-1 and i==1 and N==1:
                ret += '0'
            elif S[i]==-1 and i==1:
                ret += '1'
            elif S[i]==-1:
                ret += '0'
            else:
                ret += str(S[i])
    print(ret)


if __name__ == '__main__':
    main()