Filling of Matrix A and B