   std::cout << "\nA matrix \n";
   for (int i=0; i<N; i++){
     for (int j=0; j<M; j++){
-      std::cout << h_a[j*M+i] << " ";
+      std::cout << h_a[j*N+i] << " ";
     }
     std::cout << "\n";
   }

  cudaFree(d_a);
  cudaFree(d_b);
  cudaFree(d_c);



}

  std::cout << "\nB matrix \n";
  for (int i=0; i<M; i++){
    for (int j=0; j<K; j++){
      std::cout << h_b[j*M+i] << " ";
    }
    std::cout << "\n";
  }
