def main():
    N, M = map(int, input().split())
    S = []
    C = []
    for i in range(M):
        s, c = map(int, input().split())
        S.append(s)
        C.append(c)

    for x in range(10 ** N):
        num = str(x)
        ok = True
        for i in range(M):
            if len(num) != N:
                ok = False
                break
            if int(num[S[i] - 1]) != C[i]:
                ok = False
                break
        if ok:
            print(x)
            break
    else:
        print(-1)

if __name__ == '__main__':
    main()
