import numpy as np
import math as m

def main(**kwargs):
    r = -1

    for i in range(10 ** n - 1, 10 ** (n - 1) - 1, -1):
        stri = str(i)
        flg = True

        for s, c in zip(S, C):
            if stri[s-1] != str(c):
                flg = False
    
        if flg:
            r = i

    return r

if __name__ == "__main__":
    cin = np.array(input().split(" ")).astype("int")
    n, m, *_ = cin

    S = np.zeros(m, dtype="int")
    C = np.zeros(m, dtype="int")

    for i in range(m):
        cin = np.array(input().split(" ")).astype("int")
        S[i], C[i] = np.array(cin)
    
    cout = main(n=n, m=m, S=S, C=C)
    print(cout)