Sampling for network motif detection and estimation of Q-matrix and learning trajectories in DINA model