Sample Relationship from Learning Dynamics Matters for Generalisation