Detect collisions for each instantiated objects

I want to instantiate cube at a random position when I click mouse and do something (change color or freeze position ..) for each cube when detect collision on the plane.

I tried first few steps:

public Rigidbody cube;  void OnCollisionEnter(Collision collision) {     if (collision.gameObject.name == "Plane")     {         //Do somthing for each cube         cube.constraints = RigidbodyConstraints.FreezePositionY;     } }  void Update() {     Vector3 position = new Vector3(Random.Range(-5f, 5f), 8,Random.Range(-5, 5));      if (Input.GetMouseButtonDown(0))     {         Rigidbody clone;         clone = Instantiate(cube,position, Quaternion.identity);     } }